Skip to content

Instantly share code, notes, and snippets.

@frederik-jacques
Created March 10, 2015 10:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save frederik-jacques/b060557e2392f78ebab7 to your computer and use it in GitHub Desktop.
Save frederik-jacques/b060557e2392f78ebab7 to your computer and use it in GitHub Desktop.
A Swift function to loop over all available font families and print out the different font names. You need this if you want to use custom fonts in your app and pass in the name for the UIFont class.
func enumerateFonts(){
for fontFamily in UIFont.familyNames() {
println("Font family name = \(fontFamily as String)");
for fontName in UIFont.fontNamesForFamilyName(fontFamily as String) {
println("- Font name = \(fontName)");
}
println("\n");
}
}
@azizdev
Copy link

azizdev commented Apr 12, 2017

Swift 3

func enumerateFonts()
    {
        for fontFamily in UIFont.familyNames
        {
            print("Font family name = \(fontFamily as String)")
            for fontName in UIFont.fontNames(forFamilyName: fontFamily as String)
            {
                print("- Font name = \(fontName)")
            }
        }
    }

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