How to find, with Java, if a certain font is installed correctly on a machine

我的未来我决定 提交于 2019-11-29 13:20:30

java.awt.GraphicsEnvironment.getAvailableFontFamilyNames() can give you a list of the available fonts installed on the current system. You could also use java.awt.GraphicsEnvironment.getAllFonts() to get java.awt.Font objects.

Then, you can use java.awt.Font.canDisplay(int) to check whether a Unicode character can be displayed in that font (where the int is the integer representation of the multibyte character).

Lazy version:

Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()).contains(FONT_NAME)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!