Results 1 to 2 of 2
  1. #1
    eskiom is offline Member
    Join Date
    Sep 2010
    Rep Power

    Default Font trouble in Java 2D

    Hi all,

    I'm trying to write a string on top of a BufferedImage in a non-standard font, loaded via

    Java Code:
    f = Font.createFont(Font.TRUETYPE_FONT,
                                  new File("nashvill.ttf"));
    f = f.deriveFont(36f);
    But if I try, for example

    Java Code:
    g2d.drawString("ABCDEF\nGHIJKLM\nNOPQRST\nUVWXYZ", 50, 50);
    only the letters 'N' and 'Q' will display properly. If I change the argument of the deriveFont method, different letters will display. I have tried different .ttf files, and have found the same problem. I have also installed the .ttf file into /jre/lib/fonts, and loaded the font using

    Java Code:
    new Font("Nashville", Font.PLAIN,36);
    but I still get the same problem. Any ideas?



  2. #2
    Horcrux7 is offline Member
    Join Date
    Sep 2010
    Rep Power


    You can not use newlines in drawString. If you want draw multiple line then you need to call multiple drawString.
    Volker Berlin

Similar Threads

  1. Replies: 0
    Last Post: 08-18-2010, 10:31 AM
  2. Font.PLAIN - won't set font style to PLAIN!
    By Unsub in forum New To Java
    Replies: 3
    Last Post: 03-11-2010, 01:13 PM
  3. Replies: 5
    Last Post: 04-25-2009, 08:00 PM
  4. Replies: 4
    Last Post: 03-10-2009, 07:31 AM
  5. Trouble with Dr Java.
    By davefanelli in forum New To Java
    Replies: 1
    Last Post: 10-22-2008, 06:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts