Multiline text drawing with Graphics2D?
I am going to draw some text with Graphics2D.
I referenced the topic at Oracle web site "Drawing Multiple Lines of Text (The Java&trade; Tutorials &gt; 2D Graphics &gt; Working w…".
But I have some problem that if my String contains different fonts, how to determine the line break with a specific dimension of drawing region?
String s = "Hello World, It is a Java Duke!";
In above string, Hello World uses Font "Arial", and the remaing parts of the string use Font "Courier".
How to use "AttributedString", "TextLayout", etc to draw multiple lines with this case?
Would you please to teach me, please?
Re: Multiline text drawing with Graphics2D?
You have to do the calculations yourself. Check out the FontMetrics class.