0 Replies Latest reply: Aug 20, 2013 3:09 AM by ericmacau RSS

    Java Graphics2D draw text with multiple lines problem?




      I am going to draw some text with Graphics2D.

      I referenced the topic at Oracle web site "Drawing Multiple Lines of Text (The Java™ Tutorials > 2D Graphics > 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?


      For example,




      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?


      Best regards,