Copy link to clipboard
Copied
alert(app.activeDocument.activeLayer.textItem.font);
When my text layer uses the font: Adobe Heiti Std, I want to retrieve the property as: AdobeHeitiStd-Regular using this code. However, on some systems, it cannot be retrieved and shows that the text property cannot be obtained. The version being used is PS 2021. Do you have any solutions for this?
What about this?
var ref = new ActionReference();
ref.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('textKey'));
ref.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
var textDesc = executeActionGet(ref).getObjectValue(stringIDToTypeID('textKey'));
var fontName = textDesc.getList(stringIDToTypeID('textStyleRange')).getObjectValue(0).getObjectValue(stringIDToTypeID('textStyle')).getString(stringIDToTypeID('fontPostScriptName'));
alert(fontName);
Copy link to clipboard
Copied
Is the active layer a text layer?
Copy link to clipboard
Copied
Yes, I'm sure it is the active text layer
Copy link to clipboard
Copied
I'm not in front of Photoshop to test, but what do you get with:
font.postscriptName
// or perhaps
font.postScriptName
Copy link to clipboard
Copied
The result I received is: undefined
Copy link to clipboard
Copied
What about this?
var ref = new ActionReference();
ref.putProperty(charIDToTypeID('Prpr'), stringIDToTypeID('textKey'));
ref.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
var textDesc = executeActionGet(ref).getObjectValue(stringIDToTypeID('textKey'));
var fontName = textDesc.getList(stringIDToTypeID('textStyleRange')).getObjectValue(0).getObjectValue(stringIDToTypeID('textStyle')).getString(stringIDToTypeID('fontPostScriptName'));
alert(fontName);
Copy link to clipboard
Copied
Copy link to clipboard
Copied
When I use the font: Adobe Heiti Std, and type text in the image, the code will prompt that it cannot retrieve the text attributes. However, when I use a different font and then switch to Adobe Heiti Std, I can retrieve the text attributes.
Copy link to clipboard
Copied
Can you provide a sample-file?
If the result is faulty only on some stations I am not sure the problem can be isolated except on those stations.
Copy link to clipboard
Copied