문제

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.

도움이 되었습니까?

해결책

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top