0

I have added a custom font to my project, but its not showing up.

I have done the following to solve the issue without luck:

  • add it to bundle resources
  • added in info.plist
  • made sure target membership is checked.
  • deleted app from simulator + cleaned and rebuild

The weird thing is I can use the font just fine in IB but as soon as I run it in the simulator it won't work.

also I used the following code to confirm that the font family is loaded just fine.

for family in UIFont.familyNames {
    print("\(family)")
    for name: String in UIFont.fontNames(forFamilyName: family) {
        print("== \(name)")
    }
}

any ideas if this is a known bug?

shallowThought
  • 19,212
  • 9
  • 65
  • 112
Reshad
  • 2,570
  • 8
  • 45
  • 86
  • I don't think it's a bug. It works just fine with me. Stupid question : are you sure your fonts aren't misspelled ? If you setup your font programmatically `let font = UIFont(name: "your_font", size: 16)` and print (or anything else) it with a force unwrap `print(font!)` does it crash ? – Eva Sahz Nov 20 '16 at 01:21
  • well, not sure if it can be misspelled since I used IB – Reshad Nov 20 '16 at 01:23
  • I tried unwrapping it but it didn't crash. I just get the font printed so it is inserted in the project I guess. – Reshad Nov 20 '16 at 01:28
  • Well I don't use IB so I don't know. But maybe IB just take the name from your plist without any consideration for your actual file name. – Eva Sahz Nov 20 '16 at 01:30
  • alright I had to test a little bit more and found out that this is only the case in my launchscreen.storyboard. It works fine in normal UIViews. after a little google work I found out custom fonts are not working in launch screen and need to be a image instead... thanks for the help! – Reshad Nov 20 '16 at 01:37
  • how it is in real device?@Reshad – aircraft Nov 20 '16 at 01:45
  • The launch screen is a loading screen. It is displayed before your assets, including your fonts, are loaded. That's why you cannot use custom views or custom fonts there and there are some other limitations, too. – Sulthan Nov 20 '16 at 15:00

0 Answers0