Categories
Java

Loading TTF-Fonts with Java

It is very easy to load some TrueType-Fonts (TTF) with Java.

1
java.awt.Font.createFont(Font.TRUETYPE_FONT, new File("font.ttf"));

But with some files I got the following Exception:

1
java.awt.FontFormatException: Font name not found

You can correct this with a font-editor to add the font names. For Linux I can advise the tool fontforge. It is very powerful also for convertions of fonts. For Debian you can simply install with the following command:

1
apt-get install fontforge