List Available Fonts

In the final lesson from Module 1 of the CWC+ Design Course, Chris showed us how to list the fonts available to us in our project.

Output of code.
init() {
    for familyName in UIFont.familyNames {
        print(familyName)
        for fontName in UIFont.fontNames(forFamilyName: familyName) {
            print("-- \(fontName)")
        }
    }
}

If we’ve set it up right, the list of available fonts should include any custom fonts that we’ve added to our project.

In the case of our lesson, we downloaded the font family “Zen Loop” from fonts.google.com and added the “Regular” member of that family to our project.

We can see that particular font at the bottom of the list (it’s listed alphabetically) of the output from the print() command.

%d bloggers like this: