Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当代码点适合 64 位值时,确定特定 Unicode 字体是否包含代码点的字形相对容易。
if (CTFontGetGlyphsForCharacters(ctFont, chars, glyphs, 1)) { // It exists }
但是 CTFontGetGlyphsForCharacters 需要一个 UniChar 数组,它是 16 位类型。是否有一种方法可以确定字形是否可用于超出此范围的字符?例如,U+1F4A9?
这就是我最终使用的(其中 codePoint 是您要测试的 32 位代码点):
UniChar characters[2]; CFIndex length = (CFStringGetSurrogatePairForLongCharacter(codePoint, characters) ? 2 : 1); CGGlyph glyphs[2]; if (CTFontGetGlyphsForCharacters(ctFont, characters, glyphs, length)) { // It Exists }