
常见的“解决方案”是:
>将该字体添加到应用程序包中,并将其注册到info.pList文件中.
>使用自定义字体解析和渲染库(如Zynga的FontLabel).
>不能完成
所以问题是:如何在iOS下动态加载字体?
加载字体“动态”是指加载应用程序编译时未知的任何给定字体.
NSData *inData = /* your 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); >你不必把字体放在你的包中.
>您不必在info.pList中明确注册该字体.
也可以看看:
https://developer.apple.com/library/mac/#documentation/Carbon/Reference/CoreText_FontManager_Ref/Reference/reference.html#//apple_ref/doc/uid/TP40008278
https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGFont/Reference/reference.html#//apple_ref/c/func/CGFontCreateWithDataProvider
总结以上是内存溢出为你收集整理的如何在iOS下动态加载字体. (真的)全部内容,希望文章能够帮你解决如何在iOS下动态加载字体. (真的)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)