Search code examples
javafontsopentype

How to use Open Type Fonts in Java?


Is there a way to read Open Type fonts in Java the same way as I do with TrueType fonts?

This works perfectly for TTF but I did not figure out yet how to do the same with Open Type fonts.

Font f = Font.createFont( Font.TRUETYPE_FONT,
new FileInputStream("f.ttf") );

Please note I cannot rely on installed fonts. I provide the font with my program but don't want to install it system-wide.


Solution

  • I don't think there is Open Type Font support in java (not free atleast), iText claimed to have such support, tried it a few month ago and it didn't work, what worked for me is a program called FontForge which I used to create a ttf from the otf which I then used.