CoreText: Invalid 'kern' Subtable In CTFont
Asked Answered
R

2

9

I am using a custom font applied to a CATextLayer. I am using the tutorial and sample code found here. http://www.freetimestudios.com/2010/09/13/custom-fonts-on-the-ipad-and-ios-4/

However, every so often, I get the following error. Nothing in particular seems to trigger it. Can someone shed some light as to what this means? What to check for?

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"}

I load the font using the following code. This code is taken from the project in the link above.

- (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;
}
Radiosensitive answered 19/10, 2010 at 21:26 Comment(0)
R
5

Validating the installed font showed there was a problem with the fonts "kern" values. This was what was causing the problem.

Radiosensitive answered 20/10, 2010 at 20:14 Comment(8)
So did the validation fix it?Penance
@Penance No it did not. I had to download the font from another site, validate, and make sure it was fine. The kern I believe has to do with the spacing, sometimes a problem with a custom font.Radiosensitive
I have this problem. Except validations pass. I'm using OpenSans by the way...anyone know how to fix this?Alrich
Also using open sans and having the same problem!Threepence
Yep, same here. Open Sans.Eyeglass
Looks like @Chris O's answer might solve the Open Sans ProblemUnhook
Yep using OpenSans on OS X and seeing the same errors. Wonder if Google knows about thisBossy
Guys, did somebody found a solution? I use OpenSans for my mobile application and OpenSans-Regular causes the error.Hallux
C
9

I had the same problem and the solution was that I was using the wrong subset. I initially downloaded Open Sans from Google Fonts which caused the same error as above. I downloaded Open Sans from Font Squirrel using the MacRoman subset and that fixed my error.

Characteristic answered 16/4, 2013 at 15:56 Comment(1)
Worked for me, had to make sure to clean the product first also.Erwin
R
5

Validating the installed font showed there was a problem with the fonts "kern" values. This was what was causing the problem.

Radiosensitive answered 20/10, 2010 at 20:14 Comment(8)
So did the validation fix it?Penance
@Penance No it did not. I had to download the font from another site, validate, and make sure it was fine. The kern I believe has to do with the spacing, sometimes a problem with a custom font.Radiosensitive
I have this problem. Except validations pass. I'm using OpenSans by the way...anyone know how to fix this?Alrich
Also using open sans and having the same problem!Threepence
Yep, same here. Open Sans.Eyeglass
Looks like @Chris O's answer might solve the Open Sans ProblemUnhook
Yep using OpenSans on OS X and seeing the same errors. Wonder if Google knows about thisBossy
Guys, did somebody found a solution? I use OpenSans for my mobile application and OpenSans-Regular causes the error.Hallux

© 2022 - 2024 — McMap. All rights reserved.