Do Java Fonts work with all unicode code points?

168 Views Asked by At

I am trying to read all glyphs the font has available, in my case 547. Here's what I've done so far:

    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);
    }

And this is the output:

Searching for 547 glyphs!
Missing 160 glyphs!

Well, the problem is obvious: Where have my 160 glyphs gone?

For anyone trying to reproduce, I am using the Cinzel Regular font.

Thanks in advance for any help!

0

There are 0 best solutions below