UIFont + Enumerate Fonts Category : Rex St John
Sometimes you need to see all the font’s registered in your iOS application. I was struggling with a font which was not being assigned the proper name when I imported it as a TTF.
Tags
- ios
Originally published at rexstjohn.com on April 22, 2013. Recovered from the Internet Archive.
Sometimes you need to see all the font’s registered in your iOS application. I was struggling with a font which was not being assigned the proper name when I imported it as a TTF. This category helped me track down and identify the misnamed font.
To use it: [UIFont enumeratedInstalledFonts] and view the log output.
#import "UIFont+EnumerateFonts.h"
@implementation UIFont (EnumerateFonts)
+(void)enumerateInstalledFonts{
NSArray *familyNames = [UIFont familyNames];
for( NSString *familyName in familyNames ){
printf( "Family: %s \n", [familyName UTF8String] );
NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
for( NSString *fontName in fontNames ){
printf( "\tFont: %s \n", [fontName UTF8String] );
}
}
}
@end