ios获取ttf字体文件的familyName

废话不多说,直接上代码

NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"方正兰亭纤黑简体" ofType:@"TTF"]];
CGDataProviderRef dataRef = CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
CGFontRef fontRef = CGFontCreateWithDataProvider(dataRef);
CFStringRef fontName = CGFontCopyFullName(fontRef);
NSLog(@"%@",(__bridge NSString *)fontName);
CFRelease(dataRef);
CFRelease(fontRef);
CFRelease(fontName);

你可能感兴趣的:(ios获取ttf字体文件的familyName)