Let's take a look:
Here's the code:
Import Java.awt.Font;
Import Java.awt.Shape;
Import Java.awt.font.FontRenderContext;
Import Java.awt.font.GlyphVector;
Import Java.awt.geom.AffineTransform;
Public class Test
{
public static void Main (string[] args)
{
Try
{
Font font = new Font ("Blackbody", F Ont. PLAIN, 14);
AffineTransform at = new AffineTransform ();
FontRenderContext FRC = new FontRenderContext (at, true, true);
Glyphvector GV = Font.createglyphvector (FRC, "Su Xinghai wishes You:");//text to display
shape shape = gv.getoutline (5, 22);
int weith = 150;
int height = 25;
boolean[][] view = new Boolean[weith][height];
for (int i = 0; i < weith; i++)
{
for (int j = 0; j < height; j + +)
{
if (Shape.contains (i, J)) br>{
View[i][j] = true;
} else
{
View[i][j] = false;
}
}
}
for (int j = 0; j < height; j + +)
{
for (int i = 0; i < weith; i++)
{
if (view[ I][J])
{
System.out.print ("~");//replace your preferred pattern
} else
{
System.out.print ("");
}
}
System.out.println ();
}
} catch (Exception e)
{
E.printstacktrace ();
}
Font font = new Font ("Blackbody", Font.plain, 16);
AffineTransform at = new AffineTransform ();
FontRenderContext FRC = new FontRenderContext (at, true, true);
Glyphvector gv1 = Font.createglyphvector (FRC, "Happy Dragon Boat Festival!! "); The text to display
Shape shape1 = Gv1.getoutline (2, 12);//distance between top and bottom two graphs
int weith1 = 150;
int height1 = 25;
boolean[][] View1 = new BOOLEAN[WEITH1][HEIGHT1];
for (int i = 0; i < weith1; i++)
{
for (int j = 0; J < height1; J + +)
{
if (Shape1.contains (i, J))
{
VIEW1[I][J] = true;
} else
{
VIEW1[I][J] = false;
}
}
}
for (int j = 0; J < height1; J + +)
{
for (int i = 0; i < weith1; i++)
{
if (View1[i][j])
{
System.out.print ("~");//Replace the pattern you like
} else
{
System.out.print ("");
}
}
System.out.println ();
}
}
}
MyEclipse Console Print Text