问题描述
我在我的应用程序中需要OpenSans,因此我导入了整个OpenSans群,包括Bold,ExtraBold,Italic,Regular,Light等。我在Mac上将它们添加到Fontbook(以便在使用它时检查我需要的确切名称),在文件结构中将它们添加到我的项目的Build阶段中。
I need OpenSans in my app and so I imported the whole OpenSans bunch which includes Bold, ExtraBold, Italic, Regular, Light and more. I added them to Fontbook (to check the exact name I need to address them by when using them) on my Mac, to my project in the file structure and added them in Build phases to my project as well.
现在很奇怪;当我在UIFont中使用它们时,只有OpenSans-Bold有效。其余的不起作用。如果我使用OpenSans-Bold(完全是Fontbook给出的标识符),一切正常。但是,如果我将其更改为OpenSans-Regular或OpenSans-Light或该系列中的其他内容,我会使用UIFont获取systemfont,并且在使用Quartz绘制时我什么也得不到。
Now the weird thing; when I use them with UIFont, ONLY OpenSans-Bold works. The rest doesn't work. If I use OpenSans-Bold (exactly the identifier given by Fontbook), everything works fine. If I, however, change it to OpenSans-Regular or OpenSans-Light or something else in that family, I get the systemfont with UIFont and I get nothing when drawing with Quartz.
所有字体都在所有列表中,我检查了Fontbook中的所有标识符(这就是为什么我无法让OpenSans-Bold工作),但现在我在亏损。知道我可能做错了吗?
All fonts are in all lists and I checked all the identifiers from Fontbook (which was why I couldn't get OpenSans-Bold working), but now i'm at a loss. Any idea what I could be doing wrong?
推荐答案
OpenSans Regular只是 OpenSans
,半粗体是 OpenSans-Semibold
等。
OpenSans Regular is just OpenSans
, semi-bold is OpenSans-Semibold
, etc.
在Font Book.app中选择字体并选择 Command +我
会显示字体信息。在顶部的PostScript名称中,您可以看到字体的调用方式以及如何在代码中调用它。
In Font Book.app select the font and choose Command + I
which brings up the font info. In the "PostScript name" in the top you can see what the font is called and how you can call it in your code.
此外,只需确保字体有实际上已经添加到你的包和你的plist中:)
Also, just make sure the font has actually been added in your bundle and your plist :)
这篇关于iOS ttf字体只能部分工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!