Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to set custom font for the UILabel in XCode

I am unable to set custom font for the UILabel in XCode.

This is what I've tried:

  • Download "JennaSue" font -- http://www.dafont.com/jenna-sue.font

  • Open "app-info.plist" under "Supporting Files" folder

  • Add new row in the list with key "Fonts provided by application"

  • In this array add "JennaSue.ttf"

  • Use it in the code like this:

self.someLabel.font = [UIFont fontWithName:@"JennaSue" size:14];

And nothing happens -- the default font is visible.

Why? What am I doing wrong? How can I fix it?

like image 321
FrozenHeart Avatar asked Jul 21 '14 10:07

FrozenHeart


People also ask

How do I add custom fonts to Xcode?

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 change the font of a label in Swift?

Change Font And Size Of UILabel In Storyboard To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.

How do I use custom fonts in SwiftUI?

To use a custom font, add the font file that contains your licensed font to your app, and then apply the font to a text view or set it as a default font within a container view. SwiftUI's adaptive text display scales the font automtically using Dynamic Type.

How do I add Google fonts to SwiftUI?

For this example we went to https://fonts.google.com/ for an opensource list of fonts. Choose the font that you like and download. Usually the file type of the fonts are TTF or OTF format. Once you have your font ready, drag the files to your project, you can put them inside a folder if you create a New Group (.


1 Answers

Be sure your font is in Bundle Resources. For some reason Xcode it is not importing custom font properly most of the time:

enter image description here

enter image description here

enter image description here

I've got the font working:

enter image description here

Example code: here

like image 103
Gabriel.Massana Avatar answered Sep 22 '22 11:09

Gabriel.Massana