Question

How can I determine from the .NET runtime if, for a given font, if it has the glyph for a character? I want to switch the font to Arial Unicode MS if I have text that the specified font does not have a glyph for (very common for CJK).

Update: I'm looking for a C# (ie all managed code) solution. I think GlyphTypeface may be what I need but I can't see a way in it to ask if a given character has a glyph. You can get the entire map back, but I assume that would be an expensive call.

Was it helpful?

Solution

I've done some unicode tools and the technique I use is getting the map and chache it for each font used.

IDictionary<int, ushort> characterMap = GlyphTypeface.CharacterToGlyphMap

will give you the defined glyph index per codepoint.

msdn ref

if (characterMap.ContainsKey(CodePoint))
    glyphExists = true;
else
    glyphExists = false;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top