Custom Fonts iOS Tutorial

In iOS it possible to add custom fonts to Xcode, which could be displayed. This tutorial will display a Text View with a custom font. This tutorial is made with Xcode 10 and built for iOS 12.

Open Xcode and create a new Single View App.


For product name, use IOSCustomFontTutorial and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and choose Next.

Download the custom font and drag it to the project. Make sure the "Copy items if needed" checkbox is selected.

Go to the Storyboard and drag a Text View from the Object Library to the main View. Place the Text View on the top of the main view The Storyboard should look like this.

Select the "Resolve Auto Layout Issues" button at the bottom-right of Interface Builder and select Reset to Suggested Constraints.

Select the Assistant Editor and make sure the ViewController.swift is visible. Ctrl and drag from the Text View to the ViewController class  and create the following Outlet.

The font name is predefined by the font's creator and isn't always the same as the filename. Go to the ViewController.swift file and add the following code at the end of viewDidLoad.

let fontFamilyNames = UIFont.familyNames
    for familyName in fontFamilyNames {
        print("Font Family Name = [\(familyName)]")
        let names = UIFont.fontNames(forFamilyName: familyName as String)
        print("Font Names = [\(names)]")
    }

This will display all available fonts on the system, Build and Run the project, you will see the following font displayed in the console:

Font Family Name = [orange juice]
Font Names = [[orangejuice]]

So the Font Name of our Custom Font is orangejuice. Go to the info.plist file And add the following Array which includes the custom font.

Add the following line to the viewDidLoad method.

topTextView.font = UIFont(name: "orangejuice", size: 20.0)

Build and Run the project, the Text View is displayed with the custom font.

You can download the source code of the IOSCustomFontTutorial at the ioscreator repository on Github.