Reputation: 32874
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.
Upvotes: 3
Views: 3108
Reputation: 1632
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.
if (characterMap.ContainsKey(CodePoint))
glyphExists = true;
else
glyphExists = false;
Upvotes: 4