Copy link to clipboard
Copied
I would like to let the user choose a font in Photoshop then run a script and get the currently selected font to use with a text layer. How can I get the currently selected font from Photoshop? Thanks.
...var r = new ActionReference();
r.putClass(stringIDToTypeID("typeCreateOrEditTool"));
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool"));
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var font = executeActionGet(r).getObjectValue(stringIDToTypeID("current
Copy link to clipboard
Copied
var r = new ActionReference();
r.putClass(stringIDToTypeID("typeCreateOrEditTool"));
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("tool"));
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var font = executeActionGet(r).getObjectValue(stringIDToTypeID("currentToolOptions")).getObjectValue(stringIDToTypeID("textToolCharacterOptions")).getObjectValue(stringIDToTypeID("textStyle")).getString(stringIDToTypeID("fontName"));
alert(font);
Copy link to clipboard
Copied
Thanks. Two more questions.
1) How can I get the PostScript font name, which I need to set the font in a script.
2) Where can I find information on the properties of the typeCreateOrEditTool object and other PS tools.
Thanks again.
Copy link to clipboard
Copied
1. Instead of stringIDToTypeID ("fontName") use stringIDToTypeID("fontPostScriptName");
2. I do not know. This is my personal research.
Copy link to clipboard
Copied
Thanks very much. You have saved me a lot of time.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more