cavi-ai
GitHub ↗

Photoshop fonts

Three Photoshop tools work with fonts: photoshop_fonts, photoshop_text_fonts and photoshop_set_text_font. photoshop_add_text also checks the font it applies.

No tool activates, deactivates or downloads a font. Adobe Fonts are activated in Creative Cloud, in the Creative Cloud desktop app or on fonts.adobe.com. Activate the font there, then call photoshop_fonts again. Photoshop must be running.

photoshop_fonts

ParameterMeaning
familyKeep only the fonts of one family. The match is exact and case-insensitive. 1 to 128 printable characters.

Each entry of fonts has:

FieldMeaning
name, family, styleAs Photoshop reports them
postscript_nameThe exact name to pass as font to photoshop_add_text and photoshop_set_text_font
sourceWhere the font comes from, below
fileThe font file path from Photoshop's font list, or null

The result also has font_list, {path, modified} for the font list file that was read (modified is a UTC timestamp), or null when Photoshop has not written one. runtime and pending_operation are as for photoshop_inspect.

source

ValueThe font file lies in
adobe_fonts~/Library/Application Support/Adobe/CoreSync/plugins/livetype/.r/ or .w/: fonts activated in Creative Cloud
system/System/Library/
local/Library/Fonts/ or ~/Library/Fonts/
applicationThe Photoshop application bundle
unknownAny other location, or the font has no record in the font list

Adobe Fonts are told apart from the other fonts by the location of their font file, which Photoshop records in its font list, ~/Library/Application Support/Adobe/Adobe Photoshop <year>/CT Font Cache/AdobeFnt_OSFonts.lst. The list belongs to the installed Photoshop the server resolves. The server reads only that text file. It never opens a font file. adobe_fonts therefore relies on that list: a font Photoshop lists but the list has no record for is reported as unknown, never guessed, and without a list file every source is unknown and file is null.

The list is refused when it is over 64 MB, is not UTF-8 text, is not a regular file or does not begin with %!Adobe-FontList.

photoshop_text_fonts

ParameterMeaning
session_id*The owned copy

Reads the style runs of every text layer, with the same ownership checks as photoshop_inspect on a session. The result has:

FieldMeaning
layersEach text layer: path, name, native_id and runs
runsEach run: from and to (character offsets), postscript_name and available, whether Photoshop can use the font
missing_fontsThe sorted, unique PostScript names of runs whose font is not available

A run whose font Photoshop cannot use shows available false. At most 2048 layers and 4096 runs are read; a larger document is refused. Nothing in the document changes.

photoshop_set_text_font

ParameterMeaning
session_id*The owned copy
layer_path*, expected_name*The one text layer, as in Photoshop tools
font*An exact PostScript name from photoshop_fonts, 1 to 128 printable characters

Every run of the layer gets the font. The result is the mutation result, with the layer in changed_layers.

ConditionResult
Invalid session_id, layer_path, expected_name or fontRefused before dispatch
The layer is not a text layer, or is lockedRefused
font is not in Photoshop's font listRefused: Exact PostScript font is unavailable; use fonts discovery
After the assignment a run reports another font or available falseUnknown outcome, because the document may already have changed. Resolve it with Recovery and unknown outcomes.

Photoshop does not raise an error when it cannot use a font: the layer silently keeps another one. The tool therefore reads every run back after the assignment.

photoshop_add_text

After the layer is created, every style run must report the requested font as available. A layer that keeps another font is an unknown outcome, as for photoshop_set_text_font.