我可以在捆绑中嵌入自定义字体并从ios框架访问它吗? [英] Can I embed a custom font in a bundle and access it from an ios framework?

查看:265
本文介绍了我可以在捆绑中嵌入自定义字体并从ios框架访问它吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个带有的ios 框架,用于打包资源(笔尖,图片,字体),我正在尝试嵌入自定义字体在捆绑包中,但我无法从框架加载它,是否可能?

I'm creating an ios framework with its bundle for packaging ressources (nib, images, fonts) and I'm trying to embed a custom font in the bundle but I'm not able to load it from the framework, is it possible ?

1)我可以用以下方法本地化字体文件:
objc
NSString * fontPath = [[NSBundle frameworkBundle] pathForResource:@MyCustomFontofType:@ttf];

2)但我无法在我的字体列表中找到它:
objc
NSArray * array = [UIFont姓氏];

我在包的plist中包含了我的字体名称,其中包含应用程序提供的字体,但没有成功,也尝试在app info plist中,将其包含在框架资源中没有成功。

1) I can localize the font file with this: objc NSString *fontPath = [[NSBundle frameworkBundle] pathForResource:@"MyCustomFont" ofType:@"ttf"]; 2) But I can't get it in my fonts lists: objc NSArray * array = [UIFont familyNames]; I included my font name in the bundle's plist with a "Fonts provided by application", without success, tried also in the app info plist, include it in the framework ressource without success.

我可以从包中加载nib和图像(通过前缀包的名称),但不能加载字体。有什么想法?

I can load the nib and images from the bundle (by prefixing with the bundle's name) but not for the font. Any thought ?

编辑:我看到以下帖子:我可以在iPhone应用程序中嵌入自定义字体吗?,但问题是我可以嵌入自定义字体吗?一个iPhone应用程序?不是我可以在外部框架/捆绑包中嵌入自定义字体吗?它还引用了一个有趣的动态加载,但它使用私有api,这对于框架来说不是一个有用的解决方案。

EDIT : I saw the following post : Can I embed a custom font in an iPhone application?, but the question is just "Can I embed a custom font in an iPhone application?" not "Can I embed a custom font in an external framework/bundle ?" It also makes references to a dynamic loading which is interesting but it is using private api, which is not usable solution for a framework.

谢谢

推荐答案

这是一种新方法,可让您动态加载字体而无需将其放入Info.plist中: http://www.marco.org/2012/12/21/ios-dynamic-font-loading

This is a new method that lets you load fonts dynamically without putting them in your Info.plist: http://www.marco.org/2012/12/21/ios-dynamic-font-loading

这篇关于我可以在捆绑中嵌入自定义字体并从ios框架访问它吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆