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

后端 未结 2 1449
隐瞒了意图╮
隐瞒了意图╮ 2020-12-20 14:20

I have a PC notebook running Win Vista, when I first bought it, certain Chinese fonts won\'t show up, I could only see rectangles, but I played with the control setting for

相关标签:
2条回答
  • 2020-12-20 15:01

    Lazy version:

    Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()).contains(FONT_NAME)
    
    0 讨论(0)
  • 2020-12-20 15:11

    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).

    0 讨论(0)
提交回复
热议问题