我正在使用应用于 CATextLayer 的自定义字体。我正在使用此处找到的教程和示例代码。http://www.freetimestudios.com/2010/09/13/custom-fonts-on-the-ipad-and-ios-4/ http://www.freetimestudios.com/2010/09/13/custom-fonts-on-the-ipad-and-ios-4/
但是,我经常会收到以下错误。似乎没有什么特别的东西可以触发它。有人可以解释一下这意味着什么吗?需要检查什么?
CoreText: Invalid 'kern' Subtable In CTFont <name: Intellect, size: 20.000000, matrix: 0x0>
CTFontDescriptor <attributes: <CFDictionary 0xac07a80 [0x38295d98]>{type = mutable, count = 1, capacity = 3, pairs = (
0 : <CFString 0x3833f750 [0x38295d98]>{contents = "NSFontNameAttribute"} = <CFString 0x159af0 [0x38295d98]>{contents = "Intellect"}
我使用以下代码加载字体。该代码取自上面链接中的项目。
- (CTFontRef)newCustomFontWithName:(NSString *)fontName
ofType:(NSString *)type
attributes:(NSDictionary *)attributes
{
NSString *fontPath = [[NSBundle mainBundle] pathForResource:fontName ofType:type];
NSData *data = [[NSData alloc] initWithContentsOfFile:fontPath];
CGDataProviderRef fontProvider = CGDataProviderCreateWithCFData((CFDataRef)data);
[data release];
CGFontRef cgFont = CGFontCreateWithDataProvider(fontProvider);
CGDataProviderRelease(fontProvider);
CTFontDescriptorRef fontDescriptor = CTFontDescriptorCreateWithAttributes((CFDictionaryRef)attributes);
CTFontRef font = CTFontCreateWithGraphicsFont(cgFont, 0, NULL, fontDescriptor);
CFRelease(fontDescriptor);
CGFontRelease(cgFont);
return font;
}
我遇到了同样的问题,解决方案是我使用了错误的子集。我最初从以下位置下载 Open Sans:谷歌字体 http://www.google.com/fonts/这导致了与上面相同的错误。我从以下位置下载了 Open Sans:松鼠字体 http://www.fontsquirrel.com/fonts/open-sans使用 MacRoman 子集修复了我的错误。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)