Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
With DOM code one cannot do everything one can do woth AM code in Photoshop.
For an example you can see
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
It happens quite often! So the full process that I have at the moment is:
1. A Google spreadsheet contains card text (prompts) and colour.
2. A Python script loops through spreadsheet, generating a JSON out of the data.
3. Script loops through JSON, populating the textItem with prompts, and choosing templates according to the amount of blanks in the string.
Here's one of my templates. As you can see, the underscores have small spaces between them that can be fixed by highlighting them and setting the tracking value to -20. However, I'd want this to only affect the underscores themselves. I'd thought I could use regex or thing to find them (each blank is 7 underscores so something like (_{7}) would make it fairly easy to find).
At the end of this, a PNG is exported and saved for each card. Let me know I can provide more information!
Copy link to clipboard
Copied
If it is a certain character you want to apply this to then this can be done in Photoshop.
But the design does not look like a good fit for Photoshop and mor appropriate for Indesign (or Illustrator).
There you could easily create multipage documents and export pdfs, pngs, … for example.
Copy link to clipboard
Copied
I'll bear that in mind! I just used PS because it's what I'm familiar with.
For the sake of completeness, since you mentioned that applying things to certain characters can work in PS, could you show me how you'd go about modifying the tracking value for underscores?
Copy link to clipboard
Copied
https://community.adobe.com/t5/photoshop/how-to-change-font-in-all-paragraph-style-and-character-sty...
https://gist.github.com/akamilkhan/57dfe803aa43ed675eb691563f112520
See if those are a good starting point. You may be able to plug in code from script listener.