Skip to content

Instantly share code, notes, and snippets.

@Maxnelson997
Created February 2, 2019 20:52
Show Gist options
  • Save Maxnelson997/bd4ccf3c1168cb4d91e5b5a5dbf239a8 to your computer and use it in GitHub Desktop.
Save Maxnelson997/bd4ccf3c1168cb4d91e5b5a5dbf239a8 to your computer and use it in GitHub Desktop.
Print all fonts from every font family included in your iOS swift app.
UIFont.familyNames.forEach { (familyName) in
let fontNames = UIFont.fontNames(forFamilyName: familyName)
print(familyName, fontNames)
}
@Maxnelson997
Copy link
Author

Since this prints out a ton of fonts and you might just be looking for the names of a single font family, you can be more specific by targeting a keyword in the font family name like so.

        UIFont.familyNames.forEach { (familyName) in
            if(familyName.contains("Maven")) {
                let fontNames = UIFont.fontNames(forFamilyName: familyName)
                print(familyName, fontNames)
            }
        }

In this example, I'm looking for Maven Pro font names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment