gpt4 book ai didi

unicode - 检查字体是否支持某些字符

转载 作者:行者123 更新时间:2023-12-02 21:33:53 24 4
gpt4 key购买 nike

我在 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() 方法,方法是修改 arg 以采用字符串(对于 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;
}

最佳答案

你必须做你自己的事情。也许从规范开始( http://www.microsoft.com/typography/otspec/cmap.htm )

这就是这个工具的作用:http://mihai-nita.net/2007/09/08/charmapex-some-kind-of-character-map/

关于unicode - 检查字体是否支持某些字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5274311/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com