How do I get the font name from an otf or ttf file? How do I get the font name from an otf or ttf file? ios ios

How do I get the font name from an otf or ttf file?


Right click on the TTF -> Get Info

"Full Name" is what you're looking for.

That's what worked for me with TTFs.

Edit:

I just used a font that had a different name from the "Full Name" in Get Info.

For the compilation of this answer, If the quick check above doesn't work, run this code in your project:

for (NSString *fontFamilyName in [UIFont familyNames]) {    for (NSString *fontName in [UIFont fontNamesForFamilyName:fontFamilyName]) {        NSLog(@"Family: %@    Font: %@", fontFamilyName, fontName);    }}

And search for the correct name of the font you want to use.

Swift 3.0 code:

for fontFamilyName in UIFont.familyNames{    for fontName in UIFont.fontNames(forFamilyName: fontFamilyName){        print("Family: \(fontFamilyName)     Font: \(fontName)")    }}


Follow these four easy steps to add and use a new font in your iOS app:

  • Add your_new_font.ttf or your_new_font.otf to your Xcode project
  • In your project's info.plist, add a new entry for your_new_font.ttf or your_new_font.otf to the UIAppFonts array (plain text for this one is 'Fonts provided by application')
  • At this point, I recommend adding this temporary chunk of debug code to dump all fonts that are accessible by your app, including your newly added your_new_font:

//Swift

    for family: String in UIFont.familyNames {        print("\(family)")        for names: String in UIFont.fontNames(forFamilyName: family) {            print("== \(names)")        }    }

//Objective-c

for(NSString *fontfamilyname in [UIFont familyNames]) {    NSLog(@"family:'%@'",fontfamilyname);    for(NSString *fontName in [UIFont fontNamesForFamilyName:fontfamilyname]) {        NSLog(@"\tfont:'%@'",fontName);    }    NSLog(@"-------------");}
  • In the debug output, look for your new font's 'family' and 'font' name. Pass whatever is displayed as the 'font' name corresponding to your new font family (there could be more than one 'font' associated with your new font 'family') to UIFont *myNewFont = [UIFont fontWithName:@"font_name_from_debug_output" size:20] and you should be in business!


  • Install the font
  • Open Font Book app on your Mac
  • Select the font and click on 'info' button
  • The name you're looking for is PostScript name
    • MacOS: View -> Show Font Info

example