ios - 核心文本 : Invalid 'kern' Subtable In CTFont

标签 ios core-text

我正在使用应用于 CATextLayer 的自定义字体。我正在使用此处找到的教程和示例代码。 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;
}

最佳答案

我遇到了同样的问题,解决方案是我使用了错误的子集。我最初从 Google Fonts 下载了 Open Sans这导致了与上述相同的错误。我从 Font Squirrel 下载了 Open Sans使用 MacRoman 子集并修复了我的错误。

关于ios - 核心文本 : Invalid 'kern' Subtable In CTFont,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3972915/

相关文章:

iphone - 内存使用随着 CTFontCreateWithName 和 CTFramesetterRef 的增加而增长

iphone - CTFrameGetLineOrigins的来源不正确

ios - 使用容器 ViewController,如何在 subview Controller 之间添加交互式动画?

ios - 如何使用 Swift 在 ios 中使用 Navigation Controller 导航应用程序的所有 View (我使用的是 Xib 而不是 Storyboard)

ios - willEnterForeground 随机重启应用

cocoa - 如何使用 Core Text 从文件加载字体 (TTF)?

ios - UITableviewCell 内容中的核心文本重叠、重复并叠加在其他单元格上

ios - 拒绝访问 : UserXXX is missing the Overall/Read permission

ios - 如何去除大标题导航栏的底部边框?

objective-c - RE : autorotating, 带有属性字符串的滚动、带项目符号、缩进的 UIScrollView