Jd's Exceptions

Xcode, custom font is not registered

1.Regist Custom font, Two ways

void registFont(const string& file_name)
{
    // get ttf file path
    NSString* basePath = [NSString stringWithUTF8String:file_name.c_str()];
    NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
    NSString* fullPath = [resourcePath stringByAppendingPathComponent:basePath];

    // regist the font
    CGDataProviderRef fontDataProvider = CGDataProviderCreateWithFilename([fullPath UTF8String]);
    CGFontRef customFont = CGFontCreateWithDataProvider(fontDataProvider);
    CGDataProviderRelease(fontDataProvider);
    CFErrorRef error;
    if (! CTFontManagerRegisterGraphicsFont(customFont, &error)) {

    CFStringRef errorDescription = CFErrorCopyDescription(error);
    NSLog(@"Failed to load font %s: %@", file_name.c_str(), errorDescription);
    CFRelease(errorDescription);
    }
    else
    Log::info_print("registFont %s success", file_name.c_str());

    CGFontRelease(customFont);
}

2.Xcode Bug