Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Font Visible in Storyboard but not Simulator

For some reason, the font that I have added to the Xcode Project is showing in the Storyboard but not in the Simulator.

Here is the Storyboard.Storyboard Image

Here is the Simulator. Simulator Image

As you can see, the two fonts are not the same. I have seen similar posts on Stack Overflow, but all of these posts suggest solutions that I already have tried or made sure are enabled. I have made sure that the project is the target, it is in copy bundled resources, and it has been added to the info.plist. Here are some more screenshots: <code>P List</code> Image Target Membership Image <code>Copy Bundled Resources</code> Image

As this is a brand new project and I have only worked in storyboard mode, no code could be interfering with the text.

like image 876
Patrick Haertel Avatar asked Oct 21 '18 20:10

Patrick Haertel


2 Answers

Thanks to @Ashley Mills, I was able to determine that the issue was I added the fonts in a folder and not independently. Adding the fonts separately fixed the issue.

like image 68
Patrick Haertel Avatar answered Nov 05 '22 07:11

Patrick Haertel


Troubleshooting

You can do this adding custom font to your project following:

  • Add all font files to your project navigator.
  • Add font names(with the file extension) to info.plist. (or do it in code, comment to ask me how)
  • Check if the font name matches the font name, not it's file name!
  • Check if each font is added to target.
  • Use following code to print out all fonts in the app:

anywhere after app lunched

for familyName in UIFont.familyNames {
    for fontName in UIFont.fontNames(forFamilyName: familyName) {
        print(fontName)
    }
}
like image 39
Mojtaba Hosseini Avatar answered Nov 05 '22 07:11

Mojtaba Hosseini