我在StackOverflow上找到了这个:Is there a way to programmatically determine if a font file has a specific Unicode Glyph?
但是,我还需要检查UTF-32字符。我试图做的是在unicode.org上解析Unihan数据,并忽略"Arial Unicode MS“不支持的所有字符。我首先对CheckIfCharInFont()方法进行了修改,使其接受一个字符串(对于utf-32),并检查它是否是一个代理对。然后我通过执行char.ConvertToUtf32(surrogate1,surrogate2)获得Int32,但问题是当前的CheckIfCharInFont()方法只支持Uint16……您可以看到我在哪里放置了一个"Debugger.Break“,这是一个小问题。有没有专家能帮我解决这个问题?
谢谢
public static bool CheckIfCharInFont(string character, Font font)
{
UInt16 value = 0;
int temp = 0;
if (character.Length > 1) //UTF-32
{
temp = char.ConvertToUtf32(character[0], character[1]);
}
else
{
temp = (int)character[0];
}
if (temp > UInt16.MaxValue)
{
Debugger.Break();
return false;
}
value = (UInt16)temp;
//UInt16 value = Convert.ToUInt16(character);
List<FontRange> ranges = GetUnicodeRangesForFont(font);
bool isCharacterPresent = false;
foreach (FontRange range in ranges)
{
if (value >= range.Low && value <= range.High)
{
isCharacterPresent = true;
break;
}
}
return isCharacterPresent;
}发布于 2011-10-07 18:07:48
你将不得不做你自己的事情。也许从规格开始(http://www.microsoft.com/typography/otspec/cmap.htm)
这就是这个工具的作用:http://mihai-nita.net/2007/09/08/charmapex-some-kind-of-character-map/
https://stackoverflow.com/questions/5274311
复制相似问题