Font trouble in Java 2D
I'm trying to write a string on top of a BufferedImage in a non-standard font, loaded via
But if I try, for example
f = Font.createFont(Font.TRUETYPE_FONT,
f = f.deriveFont(36f);
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
g2d.drawString("ABCDEF\nGHIJKLM\nNOPQRST\nUVWXYZ", 50, 50);
but I still get the same problem. Any ideas?
new Font("Nashville", Font.PLAIN,36);
You can not use newlines in drawString. If you want draw multiple line then you need to call multiple drawString.