Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find all available fonts on OSX using the default shell

I'm trying to write a script for Adobe After Effects using extendscript (a proprietary ECMAScript dialect, but mostly ≈ javascript). I can use an inbuilt command system.callSystem() to execute a command using the default(?) shell, but I can't find a bash one liner, or an AppleScript command I can use to list the available fonts.

Is there a way of getting all the fonts on the command line in OSX?

like image 430
stib Avatar asked Aug 31 '25 03:08

stib


1 Answers

From AppleScript, you can use this ASOC code to get the names of all of the fonts or font families available to the system:

use framework "AppKit"
set fontFamilyNames to (current application's NSFontManager's sharedFontManager's availableFontFamilies) as list
set fontNames to (current application's NSFontManager's sharedFontManager's availableFonts) as list

I'm not sure which of those you want, so I included code for both. If you want to access this script from bash, use the osascript command:

fontFamilyNames=$(osascript << SCPT
    use framework "AppKit"
    set fontFamilyNames to (current application's NSFontManager's sharedFontManager's availableFontFamilies) as list
    return fontFamilyNames
SCPT)
like image 88
Ted Wrigley Avatar answered Sep 02 '25 16:09

Ted Wrigley