Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何检查字体是否支持字符_Ios_Objective C_Fonts_Uifont_Emoji - Fatal编程技术网

Ios 如何检查字体是否支持字符

Ios 如何检查字体是否支持字符,ios,objective-c,fonts,uifont,emoji,Ios,Objective C,Fonts,Uifont,Emoji,我正在开发一个带有文本字段的应用程序。在这个领域写的文字将被打印,我有一个像表情符号,汉字等字符的问题。。。因为字体不提供这些字符 这就是为什么我想获得字体提供的所有字符(下载字体是为了直接处理文件或UIFont对象) 我听说了CTFontGetGlyphsForCharacters,但我不确定这个函数是否能满足我的需要,我无法让它工作 这是我的密码: CTFontRef fontRef = CTFontCreateWithName((CFStringRef)font.fontName, fon

我正在开发一个带有文本字段的应用程序。在这个领域写的文字将被打印,我有一个像表情符号,汉字等字符的问题。。。因为字体不提供这些字符

这就是为什么我想获得字体提供的所有字符(下载字体是为了直接处理文件或UIFont对象)

我听说了
CTFontGetGlyphsForCharacters
,但我不确定这个函数是否能满足我的需要,我无法让它工作

这是我的密码:

CTFontRef fontRef = CTFontCreateWithName((CFStringRef)font.fontName, font.pointSize, NULL);
NSString *characters = @"I finally solve it :

- (BOOL)isCharacter:(unichar)character supportedByFont:(UIFont *)aFont
{
    UniChar characters[] = { character };
    CGGlyph glyphs[1] = { };
    CTFontRef ctFont = CTFontCreateWithName((CFStringRef)aFont.fontName, aFont.pointSize, NULL);
    BOOL ret = CTFontGetGlyphsForCharacters(ctFont, characters, glyphs, 1);
    CFRelease(ctFont);
    return ret;
}
CTFontRef-fontRef=CTFontCreateWithName((CFStringRef)font.fontName,font.pointSize,NULL);
NSString*characters=@“我终于解决了它:


使用“abc”尝试的可能重复。是否使用单个字符“a”进行了尝试?是的,但我得到了相同的结果。非常确定,即使在ARC中,您仍然需要在返回之前释放该字体。CF类型不受ARC的影响。当然,这一切都意味着CTFontGetGlyphsForCharacters中存在错误?您不必每次都创建CTFont。..