UIFont returning nil for custom font

Dhruv Sangvikar

I am trying to use the Nunito-ExtraBoldItalic font for my UILabel.

I followed the steps outlined in tutorials and other answers.

  1. Add font to fonts folder. Made sure the target is set to the project. enter image description here
  2. Add the entry to plist. enter image description here
  3. Made sure the font is shown in build phase/copy bundle resources. It is shown.

I am using the following code to create a UIlabel:

uiLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 160, height: 50))
let myfont = UIFont(name: "Nunito-ExtraBoldItalic", size: 14)
uiLabel!.font = myfont
uiLabel!.textColor = UIColor(red: CGFloat(51/255.0), green: CGFloat(33/255.0), blue: CGFloat(32/255.0), alpha: CGFloat(100.0))

But UIFont returns nil.

Postscript name of font is "Nunito-ExtraBoldItalic".

I also tried running the following:

    for familyName:String in UIFont.familyNames {
        print("Family Name: \(familyName)")
        for fontName:String in UIFont.fontNames(forFamilyName: familyName) {
            print("--Font Name: \(fontName)")

My font is not shown.

The font is visible in storyboard and other areas.

enter image description here

I tried using the Nunito-ExtraBoldItalic, Nunito-ExtraBold Italic, Nunito-ExtraBold-Italic as names. None worked.

So I am not sure what the problem is.

  1. Add the font file to the project.

enter image description here

  1. Add "Fonts provided by application" in Info.plist.

    <key>UIAppFonts</key> <array> <string>CarterOne.ttf</string> </array>

  2. Make sure the font file is listed in BuildPhase->Copy Bundle Resources.

enter image description here

  1. Make sure the Target Membership is check.

enter image description here

  1. Do a clean build cmd+option+shift+K

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at


Login to comment