自定义字体引用

将字体路径导入工程

工程会先注册字体

-(UIFont*)customFontWithPath:(NSString*)path size:(CGFloat)size

{

NSURL *fontUrl = [NSURL fileURLWithPath:path];

CGDataProviderRef fontDataProvider = CGDataProviderCreateWithURL((__bridge CFURLRef)fontUrl);

CGFontRef fontRef = CGFontCreateWithDataProvider(fontDataProvider);

CGDataProviderRelease(fontDataProvider);

CTFontManagerRegisterGraphicsFont(fontRef, NULL);

NSString *fontName = CFBridgingRelease(CGFontCopyPostScriptName(fontRef));

UIFont *font = [UIFont fontWithName:fontName size:size];

CGFontRelease(fontRef);

return font;

}

你可能感兴趣的:(自定义字体引用)