自定义字体不显示在设备上,但在模拟器上 [英] Custom font not showing on device, but does on simulator
问题描述
我一直在使用iOS中的自定义字体,并且它的大部分已经确定除了自定义字体将不会显示在我的任何设备上。
- 我已将字体添加到项目文件的根目录。
- 将其添加到数组下的info.plist文件或应用程序提供的字体
- 检查原始文件和我添加到info.plist文件中的文件大小写是否相同。
- 使用
[playMenuBtn.titleLabel setFont:[UIFont fontWithName:@fontnamesize:40]];
以使字体正常。
当我在模拟器中运行我的应用程序,一切似乎很好,工作。但是,一旦我在物理设备上运行它,它会显示默认字体的默认大小。
如果我使用:
UIFont * font = [UIFont fontWithName:@VINCASTENCILsize:20];
NSLog(@Font:%@,font);
然后模拟器返回:
2012-04-07 01:10:41.544 AppName [47412:f803]字体:< UICFFont:0x683e040> font-family:VINCA STENCIL; font-weight:normal; font-style:normal; font-size:20px
设备返回的位置:
2012-04-07 00: 42:56.358 AppName [5079:707] Font:(null)
我已经尝试过一切,包括尝试FontBook告诉我的所有名字该字体可以命名。我知道它是免费的,没有许可证。
任何帮助将非常感谢,因为它驱动我坚果,我真的不想使用图像
对,我刚刚设法得到这个工作。我所做的一切是正确的,但由于某种原因,它没有添加我的字体文件到'Targets' - >'构建阶段' - >'复制捆绑资源'。通过手动将它添加到此列表,字体会显示在设备上。
这是第二次这个项目没有自动添加文件我添加了一个类,它没有)所以我认为这是我的项目错误,或Xcode中的错误。
感谢大家的建议和帮帮我。 :-D
I've been playing around with custom fonts in iOS and have got most of it figured out apart from the custom font won't show on any of my devices.
- I have added the font to the root of the project file.
- Added it to the info.plist file under the array or "Fonts provided by application"
- Checked that the case sensitivity of both the original file and what I added to the info.plist file are the same.
- Used
[playMenuBtn.titleLabel setFont:[UIFont fontWithName:@"fontname" size:40]];
to make the font work.
When I run my app in the Simulator it all appears fine and works. However as soon as I run it on a physical device, it displays the default font with the default size.
If I use:
UIFont *font = [UIFont fontWithName:@"VINCASTENCIL" size:20];
NSLog(@"Font:%@", font);
Then the simulator returns:
2012-04-07 01:10:41.544 AppName[47412:f803] Font:<UICFFont: 0x683e040> font-family: "VINCA STENCIL"; font-weight: normal; font-style: normal; font-size: 20px
Where as the device returns:
2012-04-07 00:42:56.358 AppName[5079:707] Font:(null)
I have tried everything, including trying all the names that FontBook tells me the font could be named. I know it's free and there isn't a licence on it.
Any help would be greatly appreciated as it's driving me nuts and I really don't want to use images for al of these as localisation would then be a pain!
Right, I've just managed to get this working. Everything I was doing was correct but for some reason it wasn't adding my font file to 'Targets' -> 'Build Phases' -> 'Copy Bundle Resources'. By manually adding it to this list, the font then shows on the device.
This is the second time this project has not added a file here automatically (it's done it previously with a class I added, and it didn't) so I think it's something wrong with my project, or a bug in Xcode.
Thanks to everyone for your suggestions and help. :-D
这篇关于自定义字体不显示在设备上,但在模拟器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!