Enumerate fonts on your iOS device

When you work with custom fonts in your iOS projects, you’ll need to find out the correct name for your font.

You can do this by looping though all the font families and then use the font family name to loop through all the fonts that belong to the family.

The following function will take care of this and return you a nice list ordered per font family.

- (void)enumerateFonts {
    NSLog(@"--Start enumerating font--");
    for (NSString *fontFamilyStrings in [UIFont familyNames]) {
        NSLog(@"Font family: %@", fontFamilyStrings);

        for (NSString *fontStrings in [UIFont fontNamesForFamilyName:fontFamilyStrings]) {
            NSLog(@"-- Font: %@", fontStrings);
        }
    }
    NSLog(@"--End enumerating font--");
}
Swift

I’ve also created a gist on github You can find it right here.

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts