How to draw multiple strings in awt (java) and align them -
I need to draw different lengths in three strings or three adjacent lines. I must fit the string in a fixed width, all of which Is normal for To fit the string in the given width, we can increase the font size or reduce it.
I need lines so that there is a parallel to each other.
I have used font matrix, so here is my code
fontmatrix metric = graphics .getFontMetrics (f); Int textWidth = metrics.stringWidth (line1); Double ratio = (double) width / (double) text; Float font size = (float) (font.getSize () * ratio); Font = font.deriveFont (FONTSIZE); Matrix = graphics.gettometmetrics (font); Graphics.drawString (line1, x, y); Y + = metrics.getHeight (); // This is the same thing for the other 2 string
This job is only for some fonts; Some fonts have huge climbing and descent, some of them are desired - / P>
What is a way to do this?
Comments
Post a Comment