确定字体是否可以在 Cocoa Touch 中呈现 Unicode 字符
有没有办法确定字体是否可以在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于旧版本的 iOS (2.0),您可以使用 CGFontGetGlyphWithGlyphName()。 Apple 似乎没有记录字形名称,但我相信它们对应于以下 Adobe 列表:
http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt
例如,é (U+00E9) 的字形名为“eacute”,获取的代码字形是:
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:
查看 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.由于它是在 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.