1

Single stepping until exit from function __CFTypeCollectionRetain

 NSData *inData =[[NSData alloc] initWithContentsOfFile:@"NafeesWeb.ttf"]; /* your decrypted font-file data */;
    CFErrorRef error;
    CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)inData);
    CGFontRef font = CGFontCreateWithDataProvider(provider);
    if (! CTFontManagerRegisterGraphicsFont(font, &error)) {
        CFStringRef errorDescription = CFErrorCopyDescription(error);
        NSLog(@"Failed to load font: %@", errorDescription);
        CFRelease(errorDescription);
    }
    CFRelease(font);
    CFRelease(provider);

I also want to unregister this font after use.

4

1 回答 1

1

您是否尝试过单步执行或记录inData以确保它不是nil

您应该使用绝对路径initWithContentsOfFile:,因此您可能不会首先加载数据。

尝试:NSData *inData =[[NSData alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"NafeesWeb" ofType:@"ttf"]];

于 2013-01-25T19:13:23.463 回答