• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Photoshop Scripting - textItem Properties

Explorer ,
Jan 22, 2021 Jan 22, 2021

Copy link to clipboard

Copied

I'm looking for a way to get the text properties of each character of a Photoshop text layer.

The Photoshop scripting guide doesn't show how to gain access to substring properties of a text layer.

 

For example:

 

Given a Photoshop document with a text layer named "TEXT" that contains the text "Hello World!" where "Hello" is set with the font of Helvetica Bold and "World!" is set with the font of Futura.

 

When you run the following script it returns "Helvetica-Bold"

 

 

alert(app.activeDocument.layers.getByName("TEXT").textItem.font);

 

 

How do you gain access to the text properties of "World!"

It seems that all properties returned of a textItem are based on the first character of the textItem contents.

TOPICS
Actions and scripting

Views

1.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Guide , Jan 22, 2021 Jan 22, 2021

You need to work with text styles in ActionManager. For example, a similar task was discussed here: Superscript text font change using script

Votes

Translate

Translate
People's Champ , Jan 22, 2021 Jan 22, 2021

Try this method

 

 

var r = new ActionReference();
var d = new ActionDescriptor();

r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("json"));
r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);

d.putBoolean(stringIDToTypeID("includeAncestors"), false);
d.putBoolean(stringIDToTypeID("getTextStyles"), true)

d.putBoolean(stringIDToTypeID("selectedLayers"), true);

eval("var json="+exe
...

Votes

Translate

Translate
Adobe
Guide ,
Jan 22, 2021 Jan 22, 2021

Copy link to clipboard

Copied

You need to work with text styles in ActionManager. For example, a similar task was discussed here: Superscript text font change using script

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 22, 2021 Jan 22, 2021

Copy link to clipboard

Copied

Try this method

 

 

var r = new ActionReference();
var d = new ActionDescriptor();

r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("json"));
r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);

d.putBoolean(stringIDToTypeID("includeAncestors"), false);
d.putBoolean(stringIDToTypeID("getTextStyles"), true)

d.putBoolean(stringIDToTypeID("selectedLayers"), true);

eval("var json="+executeAction(stringIDToTypeID("get"), d, DialogModes.NO).getString(stringIDToTypeID("json")));

alert(json.toSource())

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 22, 2021 Jan 22, 2021

Copy link to clipboard

Copied

LATEST

jazz-y and r-bin,

 

This is perfect! Thank you I really appreciate it!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines