简体   繁体   中英

Open Type Font for Graphic2d Java7 Issue

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM