问题描述
我有自定义字体的问题.即它是 Tw Cen MT.ttf
I have a problem with custom font. Namely it's Tw Cen MT.ttf
这和这里的问题是一样的:自定义字体不显示在设备上,但在模拟器上显示
It's the same problem as in here:Custom font not showing on device, but does on simulator
除了给定的解决方案对我不起作用.
Except the given solution doesn't work for me.
我已经完成了你应该做的事情:
I have done exactly what you should do:
- 向 Info.plist 添加字体
- 在构建阶段的复制捆绑资源部分添加了字体.
- 通过名称而不是文件名以编程方式使用字体.
还是不行.更有趣的是 - 当我列出可用字体时:
It still doesn't work. What's more interesting - when I list available fonts:
NSLog(@"%@", [UIFont familyNames]);
它在模拟器上显示我的字体,但没有在设备上显示.我在装有 iOS 6 的新 iPad 和 iPhone 4 上对其进行了测试.
It shows me my font on simulator but does not show it on the device. I tested it both on the new iPad and iPhone 4 with iOS 6.
有什么建议吗?
推荐答案
请务必不要将系列名称与字体名称混淆.这是我用来检查字体真实名称的代码.-
Be sure not to confuse the family name with the font name. This is the code I use to check the real name of my fonts.-
NSArray *familyNames = [UIFont familyNames];
for (NSString *aFamilyName in familyNames) {
NSArray *fontNames = [UIFont fontNamesForFamilyName:aFamilyName];
for (NSString *aFontName in fontNames) {
NSLog(@"%@", aFontName);
}
}
这篇关于UIFont 自定义字体未显示在设备上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!