我正在尝试读取字体可用的所有字形,在我的情况下为 547。这是我到目前为止所做的:
private static String getCharacters(Font font) {
final int glyphs = font.getNumGlyphs();
System.out.println("Searching for " + glyphs + " glyphs!");
int[] codePoints = new int[glyphs];
int found = 0;
for (int codePoint = Character.MIN_CODE_POINT; codePoint < Character.MAX_CODE_POINT
&& found < glyphs; codePoint++) {
if (font.canDisplay(codePoint)) {
codePoints[found++] = codePoint;
}
}
System.out.println("Missing " + (font.getNumGlyphs() - found) + " glyphs!");
return new String(codePoints, 0, found);
}
这是输出:
Searching for 547 glyphs!
Missing 160 glyphs!
好吧,问题很明显:我的 160 个字形到哪里去了?
对于任何试图复制的人,我使用的是 Cinzel Regular 字体。
提前感谢您的帮助!