首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CoreText: CTFont中的“kern”子表无效

CoreText: CTFont中的“kern”子表无效
EN

Stack Overflow用户
提问于 2010-10-20 05:26:43
回答 2查看 6.8K关注 0票数 9

我使用的是应用于CATextLayer的自定义字体。我使用的是教程和这里的示例代码。http://www.freetimestudios.com/2010/09/13/custom-fonts-on-the-ipad-and-ios-4/

但是,有时我会收到以下错误。似乎没有什么特别的东西会触发它。有人能解释一下这是什么意思吗?要检查什么?

代码语言:javascript
复制
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"}

我使用以下代码加载字体。这段代码取自上面链接中的项目。

代码语言:javascript
复制
- (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;
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-10-21 04:14:20

验证安装的字体显示字体"kern“值有问题。这就是导致问题的原因。

票数 5
EN

Stack Overflow用户

发布于 2013-04-16 23:56:23

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

票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3972915

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档