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?
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)