Quantcast
Channel: Adobe Community : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 238792

How can I read paragraph box scale?

$
0
0

Hi,

 

I am trying to read the values off some text boxes in photoshop for an exporter script that I am working on. I ran into an issue that I can't  figure out, hopefully it's just a small thing.

When reading the values from paragraph text, there are some instances in which the values will come out wrong. For example:

 

I have a layer with paragraph text in it that says its paragraph size (text box) is 400 px by 400 px and the font size is 60 pt.

If I run a script similar to this:

 

[code]

// get the text layer and save ir to a variable named layer //

if (layer.textItem.kind == TextType.PARAGRAPHTEXT)

{

     log("Width: " +  layer.textItem.width.as('px'));

     log("Height: " + layer.textItem.height.as('px'));

     log("Font size: " + layer.textItem.size.as('pt'));

}

[/code]

 

My output reads:

 

[code]

Width: 200

Height: 200

Font size: 30

[/code]

 

Which is obviously wrong because all the values are half of what they should be. I have other paragraph text layers in the same file that print out the correct values!

After trying a bunch of different things I figured a way to reproduce the error, but not a way to correct it, here it is:

 

- Create a new paragraph text layer by clicking and dragging using the text tool, make the text box roughly 200 px by 200 px

- Type some text in the box

- Select the text and make it 30 pt in size

- Finish editing the text

- Make sure the text layer is selected

- Press command+t (ctrl+t in windows)

- In the free transform parameters, manually type 200% for both with and height

- Accept the transformation changes

- Use the text tool and select the text from the layer

 

At this point you will notice that the text box reports its size as 400 px by 400 px and the font size says 60 pt, so far everything makes sense, the issue comes when you look at the info tab, the scale is reported as 200% for both width and height and if I use the previous script the sizes printed are the original sizes of the text box: 200 px by 200 px and 30 pt for the font size.

 

At first I though it would be as easy as using the verticalScale and horizontalScale properties of TextItem like so:

 

[code]

log("Vertical scale: " + layer.textItem.verticalScale);

log("Horizontal scale: " + layer.textItem.horizontalScale);

[/code]

 

But even though we know the scale is 200% the output reads:

 

[code]

Vertical scale: 100

Horizontal scale: 100

[/code]

 

Unfortunatelly I do not have control over how the content is created so I can't avoid the use of the transform tool on pararaph text, or all text for that matter (this issue also affects the font size in single line text layers). So I need to find a reliable way to either read the correct values from the text or to read the scale which is affecting the text within my layer.

 

Any help would be appreciated. Thank you in advance.

 

 

 

Dario Segura


Viewing all articles
Browse latest Browse all 238792

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>