确定字体是否可以在 Cocoa Touch 中呈现 Unicode 字符

发布于 2024-08-30 04:08:26 字数 62 浏览 2 评论 0原文

有没有办法确定字体是否可以在 Cocoa 中呈现特定的 Unicode 字符?或者,是否可以指定默认替换字符?

Is there a way to determine whether or not a font can render a particular Unicode character in Cocoa? Alternatively, is it possible to specify the default substitute character?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

追风人 2024-09-06 04:08:26

对于旧版本的 iOS (2.0),您可以使用 CGFontGetGlyphWithGlyphName()。 Apple 似乎没有记录字形名称,但我相信它们对应于以下 Adob​​e 列表:

http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt

例如,é (U+00E9) 的字形名为“eacute”,获取的代码字形是:

CFStringRef name = CFStringCreateWithCString(NULL, "eacute", kCFStringEncodingUTF8);
CGGlyph glyph = CGFontGetGlyphWithGlyphName(font, name);

You can use CGFontGetGlyphWithGlyphName() for iOS older versions of iOS (2.0). Apple doesn't seem to document the glyph names but I believe they correspond to this Adobe list:

http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt

For example, the glyph for é (U+00E9) is named "eacute" and the code to get the glyph would be:

CFStringRef name = CFStringCreateWithCString(NULL, "eacute", kCFStringEncodingUTF8);
CGGlyph glyph = CGFontGetGlyphWithGlyphName(font, name);
南风起 2024-09-06 04:08:26

查看 Core Text 框架中的 CTFontGetGlyphsForCharacters。如果它对于给定 Unicode 字符的字形索引返回零,则该字体不支持该字符。如果找不到任何字形,该函数将返回 false。

Check out CTFontGetGlyphsForCharacters in the Core Text framework. If it returns zero for a given Unicode character's glyph index, then that character isn't supported in that font. The function returns false if any of the glyphs couldn't be found.

沉溺在你眼里的海 2024-09-06 04:08:26

由于它是在 iOS 上,您可能需要构建或找到一个应用程序来执行此操作。
最终,如果任何单独字形的信息都存在,那么它就在字体文件本身的表中,这是相当低级的 C 工作。

构建一个检查字体并显示字形和字形索引(CGGlyph 或 NSGlyph 值)然后使用字形索引的工具要容易得多。

Since it is on iOS, you might need to build or find an app that does this.
Ultimately, if the info is present for any individual glyph it is in the tables in the font file itself and that is pretty low level C work.

Much easier to build a tool that inspects the font and shows the glyph and glyph index (CGGlyph or NSGlyph value) then use the glyph index.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文