简体   繁体   中英

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. I added the font to 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
  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.
  5. Look for "PostScript name" – its your font name.

在此输入图像描述

  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]];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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