[英]Adding custom font to project, programmatically add item to plist
I want to add some font to my project. 我想在项目中添加一些字体。 I have directory in my project contains fonts.
我的项目中有包含字体的目录。 So i can access to my font by:
因此,我可以通过以下方式访问我的字体:
NSString* path = [[NSBundle mainBundle] pathForResource:@"res_name" ofType:@"res_type" inDirectory:@"res_directory"];
But how to add it to my project so i will be able to call it like this: 但是如何将其添加到我的项目中,这样我就可以像这样调用它:
[UIFont fontWithName:@"Font-Name" size:14.0]
I'm only interest how to do this programmatically I'm assume that I have to add it to my plist, but can i do this programmatically? 我只对如何以编程方式执行此操作感兴趣,我假设我必须将其添加到我的plist中,但是我可以以编程方式执行此操作吗?
I understand o have to use a in plist: 我了解o必须在plist中使用a:
<key>UIAppFonts</key>
<array>
<string>swellfont.ttf</string>
</array>
But i cannot do this in Xcode manually. 但是我无法在Xcode中手动执行此操作。 I want to check what fonts i included in my project in resource directory and add them programmatically from code.
我想检查资源目录中项目中包含的字体,然后从代码中以编程方式添加它们。
The UIAppFonts key in Info.plist. UIAppFonts键在Info.plist中。
You can take a look at the Core Text Font Manager to see if registering fonts by URL make them loadable with +[UIFont fontWithName:]
. 您可以看一下Core Text Font Manager,以查看通过URL注册字体是否可以使用
+[UIFont fontWithName:]
加载它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.