Re: Photoshop: Get the height/width of a text layer?
Re: Photoshop: Get the height/width of a text layer?
- Subject: Re: Photoshop: Get the height/width of a text layer?
- From: "Duane L. Mitchell" <email@hidden>
- Date: Thu, 27 Feb 2003 16:14:29 -0500
AFAIK, you can't get the height and width properties of text unless you set
it to "paragraph text" in your script after creating it. Even then you can't
get the *exact* height and width of the text because setting it to paragraph
text enlarges the box. Here's what I've done as a work around.
Create the text layer and then move the text box to a known location. I use
{108,108} for my purposes. At the point the position of the text is
referenced by the bottom left corner of the box. Now convert it to paragraph
text. If you get the position of the text now it will reference the top left
x,y coordinates. Since you originally knew the y location to begin with you
can now subtract the new y from the original y. Now you know the exact
height of the text, not the box.
If you are stepping through your script you should notice that when convert
the text to paragraph text it enlarges both the height and width of the box.
?? Oh well. You can now get the height and width properties but, again, that
is of the box, not the text, the box has been enlarged beyond the text
dimensions. At this point I set the text to fully justified. Now I know that
the text will be forced to fill the box. This puts more space between
characters but...if you have a better idea, let me know. So now I can get
the exact width of the box.
Now you know the x,y of the top left corner, the exact height of the type,
and the exact width of the type. After that you can move it to wherever you
need it.
One more thing. You will need to make sure that Unit Prefeneces are in
points for Ruler, Type and Screen Resolution is set to 72 ppi. You need this
for your calculations. I made this a part of my script by making this an
Action called at the start of the script. I couldn't see any other way to do
it.
-Duane
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Duane L. Mitchell
Next Generation Solutions
31 Granby Road Worcester, MA 01604-1643
email@hidden 508-792-4396
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
How on earth do I this? I need to know the exact dimensions of the text
>
layer so I can accurately place it in the right place in my document
>
>
This does not work (after I rasterize the text):
>
>
set textheight to height of current layer
>
set textwidth to width of current layer
>
>
Neither does this (after I rasterize the text and turn it into a selection):
>
>
set textheight to height of current selection
>
set textwidth to width of current selection
>
>
Help!
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.