简体   繁体   English

必须将自定义字体文件添加到 Xcode 中的 info.plist 吗?

[英]Must one add custom font file to info.plist in Xcode?

Just a question about adding a custom font in Xcode.只是关于在 Xcode 中添加自定义字体的问题。 After I add it to my project's resources as a ttf file, I can use it inside a label in my storyboard for example.在我将它作为 ttf 文件添加到我的项目资源后,我可以在我的 storyboard 中的 label 中使用它。 But do I need to add it to the info.plist file too?但是我是否也需要将它添加到 info.plist 文件中?

Yes, you must add custom fonts to your Info.plist. 是的,您必须将自定义字体添加到Info.plist中。 You do this with the UIAppFont Info.plist key (which shows up as Fonts provided by application in the plist editor). 您可以使用UIAppFont Info.plist键(在plist编辑器中显示为Fonts provided by application )来执行此操作。

Here is the relevant documentation . 这是相关文档

And an example: 一个例子:

<key>UIAppFonts</key>
<array>
    <string>SomeFont.otf</string>
    <string>SomeOtherFont.otf</string>
</array>

I have recently done the same thing.我最近做了同样的事情。

  • Goto info.plist from project target.从项目目标转到 info.plist。
  • Add a new property by clicking +通过单击+添加新属性
  • In the key section, write Fonts provided by application在关键部分,写Fonts provided by application
  • As it is an array of key-value pairs, you can add items under it.由于它是一个键值对数组,因此您可以在其下添加项目。
  • Unfold it to add the item for key item-0 .展开它以添加关键item-0的项目。
  • item-0 key can remain as it is. item-0键可以保持原样。 And give the value as font_name.otf.并将值作为 font_name.otf。
  • If you want to add more, just click + under Fonts provided by application .如果要添加更多,只需单击Fonts provided by application下的+即可。 And it will create keys like item-1, item-2 and so on.它将创建像item-1, item-2 and so on.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM