1

I means, how to get ALL SUPPORTED CHARATCTERS by a font(Font class)?
That's the first question.
I have found the solution:

        var families = Fonts.GetFontFamilies(@"C:\WINDOWS\Fonts\Arial.TTF");
        foreach (var family in families)
        {
            var typefaces = family.GetTypefaces();
            foreach (Typeface typeface in typefaces)
            {
                GlyphTypeface glyph;
                typeface.TryGetGlyphTypeface(out glyph);
                IDictionary<int, ushort> characterMap = glyph.CharacterToGlyphMap;

                foreach (KeyValuePair<int, ushort> kvp in characterMap)
                {
                    Console.WriteLine(String.Format("{0}:{1}", kvp.Key, kvp.Value));
                }

            }
        }

BUT,What's the charaterMap(that IDictionary) contains?
That's the second question.
Thanks.

1
  • If a font is not installed on a windows machine windows will choose automatically a similar font. Similar does not mean all the character will display correctly. You can only use a font that contain all the character you are using.
    – jdweng
    Commented May 3, 2020 at 11:02

1 Answer 1

2

GlyphTypeface.CharacterToGlyphMap returns a dictionary with all entries from the font's 'cmap' table. That is the precisely the table that determines what Unicode characters are supported by the font. Each entry has a Unicode code point as the key and the default glyph ID for that character as the value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.