Skip to main content
Participant
October 8, 2020
Question

Using the Photoshop API, can I change the tracking value of a specific text character in my textItem

Is it possible to change specific text properties in PS text using a script? I've gotten the ability to insert text going with a Python wrapper:

doc = psApp.Application.ActiveDocument
layer_scenario_text = doc.ArtLayers["TextLayer"]
text_of_layer = layer_scenario_text.TextItem
text_of_layer.contents = "Text to change"

But is it possible to change say, the tracking value for selected characters with scripting? Looking at the API docs, I've found the textItem.tracking property, but would I be able to have it apply to just ONE part of the string? E.g. the word change in my example would have a tracking of -20 but everything else in the string stays the same?

 

Many thanks!

Ce sujet a été fermé aux réponses.

1 commentaire

c.pfaffenbichler
Community Expert
Community Expert
October 8, 2020

With DOM code one cannot do everything one can do woth AM code in Photoshop. 

For an example you can see 

https://community.adobe.com/t5/photoshop/change-a-certain-color-of-texts-to-a-new-color/td-p/11468654?page=1

 
But I know of no way to assess the selected parts of a Type Layer except with a work-around that’s convoluted and unreliable … hopefully comeone else can offer more advice. 
 
Did you already download ScriptingListener.plugin? 
Participant
October 8, 2020

Thanks for this, this is actually the first I've heard of the Scripting Listener plugin so I'll give that a look.

Oh boy that's some convuluted code that I'd rather not go down...

Since I'm essentially just making a card game, would I better served with trying to achieve this with something like InDesign or Illustrator? Any pointers on how the code would look like for either, if it's easier?

 

c.pfaffenbichler
Community Expert
Community Expert
October 8, 2020

I am afraid text handling is generally more convenient in Indesign and also Illustrator. 

But I am not particularly familiar with either’s DOM. 

 

What is the task you are looking to automate and how often does it arise? 

Could you post a screenshot to illustrate?