简体   繁体   English

找不到添加到xcode 7的自定义字体的名称

[英]can't find the name of custom font added to xcode 7

I am having trouble with getting the name of my custom font. 我在获取自定义字体的名称时遇到问题。 I added font to my project with copy if needed option checked. 如果需要选中选项,我在我的项目中添加了字体。 I added the font name to the info.plist tag Fonts provided by an application. 我将字体名称添加到应用程序提供的info.plist标记字体中。 I added the font to Copy Bundle Resources. 我将字体添加到Copy Bundle Resources。

The font appears in storyboard under custom tab. 字体显示在自定义选项卡下的故事板中。 But when I try to find the name of this font with code, it doesn't work. 但是当我试图用代码找到这个字体的名称时,它不起作用。 Really strange because that normally works. 真奇怪,因为这通常有效。 What could be the reason for this? 这可能是什么原因?

Storyboard image of font: 故事板图片的字体:

在此输入图像描述

Code to find the name programatically: 用于以编程方式查找名称的代码:

viewDidLoad(){
// there is no PTSans family in the debugger. 
for family: String in UIFont.familyNames()
        {
            print("\(family)")
            for names: String in UIFont.fontNamesForFamilyName(family)
            {
                print("== \(names)")
            }
        }
}
  1. Search For "Font Book" app in your SpotLight Search 在SpotLight搜索中搜索“Font Book”应用程序
  2. Select All Fonts, and look for your phone (I believe you have already installed it in your system, if not do so by double clicking on font and then follow the steps). 选择所有字体,然后查找您的手机(我相信您已经在系统中安装了它,如果不是通过双击字体然后按照步骤安装)。
  3. If you have font installed, click on your font. 如果您安装了字体,请单击您的字体。
  4. Click on (i) info icon. 单击(i)信息图标。
  5. Look for "PostScript name" – its your font name. 查找“PostScript名称” - 它的字体名称。

在此输入图像描述

  1. You can always access to your custom font by providing this name. 您始终可以通过提供此名称来访问自定义字体。

Btw, see the difference in example, the font name has a space, in actual there isn't. 顺便说一句,看到例子中的区别,字体名称有空格,实际上没有。

你尝试过这样的事情:

[yourlabel setFont:[UIFont fontWithName:@"PT Sans" size:20]];

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

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