Apple - How can I get the PostScript name of a TTF font installed in OS X?

Open the Font Book application. (It should be in your Applications folder.)

Select the font you need the Postscript Name for.

Select Show Font Info from the Preview Menu. ( Or use +i).

screenshot:fontbook font info

If you are seeing only a preview ensure you click on the i enter image description here


Your assumption is correct. iOS requires that you identify a font based on its Postscript name (or Fullname), which is not always the same as the font's actual Filename.

You can get the PostScript name using FontBook (as shown on the accepted answer here), but there are other ways.

From directly inside XCode, you can extract the PostScript Name from the project's installed fonts via UIFont. Simply run this to print the PostScript names of your installed project fonts :

In Objective-C (source):

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

Or Swift 3.0 (source)

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

Or from the terminal, from inside the directory where you have your font files, you can run this script to print all the PostScript names of the fonts inside the current directory (uses the fc-scan utility from fontconfig which is probaly already installed) (source):

for file in "$arg"*.{ttf,otf}; do fc-scan --format "%{postscriptname}\n" $file; done

Here is a screenshot of the above command running on my ~/Library/Fonts directory:

enter image description here

The script above will run through all the .ttf and .otf files in the current directory, then print out the PostScript Name for each font which you can use to reference the font file in XCode or elsewhere.

If you want to get fancy with some additional information (PostScriptName, Filename) and some color coding, you can run this alternative script:

for file in "$arg"*.{ttf,otf}; do 
    postscriptname=$(fc-scan --format "%{postscriptname}\n" $file);
    printf "\033[36m PostScript Name:\033[0m %s \e[90m(%s)\033[0m\n" "$postscriptname" "$file";
done

enter image description here

This is a bit faster than copy-pasting code inside of your AppDelegate.m file to print out the names every time you want to add a new font file, which is the popular method, and it's also faster than opening the Font in FontBook to inspect the PostScript Name.

USEFUL TIP: If you alias the above script in your terminal so that all you need to do is type a single command to get all the PostScript font names for all the files in the current directory, then you will save time in your development workflow and have this handy script ready to use when you need it.

Hope this helps!


Came across a slightly different use case that I thought I should share for others:

A font file that I bought and downloaded is restricted to app use only. I usually use FontBook, like the accepted answer, to grab the PostScript name. However, because of the app use restriction I was unable to import the font into FontBook.

What worked for me was to right click the font file and select "Get Info". The value in the "Full name" field under the General tab is what worked for me and appears to be the PostScript name. Verified this with a few other font files I knew for sure the PostScript name of.

Easy and doesn't involve opening another app.

Tags:

Macos

Font