Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode custom font not showing in app

Tags:

xcode

ios

fonts

I have downloaded Open Sans font and added all the .tff files into my Xcode project, and have checked the checkbox in "Target Membership" pane for each file. I have added the UIAppFonts key and values in Info.plist, and I am sure that the values are typo-free. Plus, the .tff files are added to "Copy Bundle Resources", and the custom font is showing up in Interface Builder. And then I changed the font of all the labels to Open Sans in the Interface Builder (no code).

But when I run the app in the simulator, all the labels and buttons are showing the system font in ultra small sizes, like this:

One thing to note is that I am using Xcode 7 beta 5, and the app's Base SDK is iOS 9.

But why is there this problem? Is it a bug? Thanks!

like image 562
Blip Avatar asked Aug 16 '15 20:08

Blip


People also ask

How do I add custom fonts to Xcode?

Add the Font File to Your Xcode Project To add a font file to your Xcode project, select File > Add Files to “Your Project Name” from the menu bar, or drag the file from Finder and drop it into your Xcode project. You can add True Type Font (. ttf) and Open Type Font (. otf) files.

How do I add custom fonts to Xcode 13?

Add the font file to your Xcode project Select File menu > Add Files to "Your Project Name"... from the menu bar, select all the fonts you need to add, then click the Add button. Or drag the file from Finder and drop it into your Xcode project. Drag the font files from Finder and drop it into your Xcode project.


3 Answers

Check That fonts inside the proyect are part of the target. Select fonts, verify the property Target Membership for your app is checked at the right in File Inspector.

That solved the problem for me: Target Membership is in te property inspector at the right

like image 104
Manuel BM Avatar answered Sep 26 '22 08:09

Manuel BM


I recently encountered this problem too. But it only happened for one font-style of a font-family, the others worked fine. I could only solve it by using this font in a button, then the font was also available for other controls such as labels or the large title.

like image 42
Martin Avatar answered Sep 23 '22 08:09

Martin


Blip, here's a photo of what I did in an empty "Single View" project. And, I could see the font on sim and IB editor. Anything look different for your project? Maybe recreate the basics in a new project, just to double check? All of my notes on the image were associated with my original thoughts...just use them for reference as you double check things.

enter image description here

like image 40
Larry B Avatar answered Sep 24 '22 08:09

Larry B