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

How to get text justification using Action Manager?

Engaged ,
Nov 06, 2013 Nov 06, 2013

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.

TOPICS
Actions and scripting
2.4K
Translate
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
Adobe
Community Expert ,
Nov 06, 2013 Nov 06, 2013

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.


Translate
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
Engaged ,
Nov 06, 2013 Nov 06, 2013

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?

Translate
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
Guru ,
Nov 07, 2013 Nov 07, 2013

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.

Translate
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
Community Expert ,
Nov 07, 2013 Nov 07, 2013

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.

Translate
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
Engaged ,
Nov 08, 2013 Nov 08, 2013

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,

shot.jpg

Now, if you try to get the font size, you get nothing.

Translate
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
Guest
May 20, 2016 May 20, 2016
LATEST

Photoshop CS6 64Bit, How to get text justification using jsScript?

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.

Translate
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