Copy link to clipboard
Copied
Hi All,
I have been trying get several properties of a text layer using action script in Photoshop CS6 and CC. But here I encounterd an issue which is a Photoshop bug. I see that when I create a text layer using the default values and then try to get some values like the text justification, I get an exception. I had encountered a similar issue earlier and had resolved it by getting the properties using Action Manager.
How can I get the text justification, alignment, leading, tracking values using Action Manager?
Please help.
Copy link to clipboard
Copied
We need a better description from you. Point text or textarea? Characters or words or simple lines or whole paragraphs? What output is desired? How much text layers etc. etc.
At the best - show some samples.
Otherwise - is "normal" javascript also ok for you?
Try something like this:
var aLay = app.activeDocument.activeLayer;
if(aLay.textItem && aLay.textItem.contents != "")
alert(aLay.textItem.justification);
alert("tracking: "+aLay.textItem.tracking);
if (!aLay.textItem.useAutoLeading)alert("leading: "+aLay.textItem.leading)
else alert("AutoLeading with: "+Math.round (aLay.textItem.autoLeadingAmount)+"%" );
Should also work in CS6/CC.
Copy link to clipboard
Copied
Hi,
The above code that you suggested won't work on CS6 and CC if you do the following,
1. Create a text layer in a new document.
2. Change the alignment of the text.
3. Change the tracking value.
Now, if you try to get the font size, the script will give an exception.
I tried getting the font size by aLay.textItem.fontSize. It gives an undefined result.
I don't know why but it doesn't work.
Can you suggest anything else?
Copy link to clipboard
Copied
When Adobe introduced text styles they changed what was already a difficult scripting problem into a rats nest.
I think what is happing is if the text has a style override( noted by the + in the style name ) then you can't access most of the text properties using the DOM.
The Action Descriptors change radically if the style has an override. For example the justification setting is found in different in different descriptors depending on if the style has an override.
I think with enough work you should be able to get the info using Action Manager. It's on my list of things to do when I have the time.
Copy link to clipboard
Copied
poortip87 schrieb:
… I tried getting the font size by aLay.textItem.fontSize. It gives an undefined result.I don't know why but it doesn't work.
Can you suggest anything else?
Is this the right code in CS6/CC ???
In other versions I use: aLay.textItem.size
And I tested my code at work with CS6 (without paragraph style) today. Changed the justification and so on. It works for me.
You know, that you should read some properties like justification
only line for line to get the correct result? Because of you can get every line a different justification.
Copy link to clipboard
Copied
Hi
Doesn't work with aLay.textItem.size. Comes up empty. This is when you change the justification from the Paragraph panel. Here is a screenshot,
Now, if you try to get the font size, you get nothing.
Copy link to clipboard
Copied
Anyone know? Now solved?
if (currArtlayer.kind == LayerKind.TEXT ){
var justificationType= currArtlayer.textItem.justification;//error !get nothing.
}
I want to export the game interface code.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now