如何判断特定字体是否具有> 64k的特定字形 [英] How to tell if a particular font has a specific glyph >64k

查看:87
本文介绍了如何判断特定字体是否具有> 64k的特定字形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当代码点符合64位值时,确定特定Unicode字体是否包含代码点的字形相对容易。

It's relatively easy to determine if a particular Unicode font contains a glyph for a code point when the code point fits into a 64 bit value.

if (CTFontGetGlyphsForCharacters(ctFont, chars, glyphs, 1)) {
    // It exists
}

但CTFontGetGlyphsForCharacters采用UniChar数组,这是一个16位类型。有没有一种方法可以确定字形是否可用于超出此范围的字符?例如,U + 1F4A9?

But CTFontGetGlyphsForCharacters takes an array of UniChar, which is a 16 bit type. Is there a method for determining whether a glyph is available for a character beyond this? For example, U+1F4A9?

推荐答案

这就是我最后使用的东西(其中codePoint是你想要的32位代码点)测试):

This is what I wound up using (where codePoint is the 32 bit code point you want to test for):

    UniChar characters[2];
    CFIndex length = (CFStringGetSurrogatePairForLongCharacter(codePoint, characters) ? 2 : 1);

    CGGlyph glyphs[2];
    if (CTFontGetGlyphsForCharacters(ctFont, characters, glyphs, length)) {
        // It Exists
    }

这篇关于如何判断特定字体是否具有> 64k的特定字形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆