0

I have gone through many topics related to this issue. It seems like Open type font is supported for Swing, but isn't supported for Graphics2D in Java7. It still allow me to create new font based on a .otf file but it doesn't generate text when I try to write it to an image.

Font font = Font.createFont(Font.TRUETYPE_FONT, new File("font.otf"));

Has anyone faced the same? Please share your solution.

UPDATE

As said in this link, Open Type Font is supported but I can't find any toppic show how to use this font in practice.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
nguyentaijs
  • 160
  • 8
  • OTF is not a TrueType Font. This question is a duplicate of https://stackoverflow.com/questions/872569/how-to-use-open-type-fonts-in-java – Aly Dec 26 '17 at 13:14
  • Possible duplicate of [How to use Open Type Fonts in Java?](https://stackoverflow.com/questions/872569/how-to-use-open-type-fonts-in-java) – Aly Dec 26 '17 at 13:14
  • As in this oracle bug report https://bugs.java.com/view_bug.do?bug_id=6954424. OTF is supported, there must be some ways to use it but I can't find out how. – nguyentaijs Dec 27 '17 at 01:56

1 Answers1

0

For those who faced the same problem. I found out that my current Java version (1.7.0_151) couldn't handle OTF file.
I upgrade to JDK 7 b97 (or older), then the problem is gone.

nguyentaijs
  • 160
  • 8