Can I embed a custom font in a bundle and access it from an ios framework?(我可以在包中嵌入自定义字体并从 ios 框架访问它吗?)
问题描述
我正在创建一个 ios framework 及其 bundle 用于打包资源(笔尖、图像、字体),并且我正在尝试嵌入 自定义字体 在捆绑包中,但我无法从框架中加载它,这可能吗?
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) 我可以用这个本地化字体文件:<代码>objcNSString *fontPath = [[NSBundle frameworkBundle] pathForResource:@"MyCustomFont" ofType:@"ttf"];代码>2)但我无法在我的字体列表中得到它:<代码>objcNSArray * 数组 = [UIFont familyNames];代码>我将我的字体名称与应用程序提供的字体"一起包含在捆绑的 plist 中,但没有成功,也在应用程序信息 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.
我可以从包中加载笔尖和图像(通过以包的名称为前缀),但不能加载字体.有什么想法吗?
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 框架访问它吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我可以在包中嵌入自定义字体并从 ios 框架访问它吗?


基础教程推荐
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01