Text layer / mask size

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
b0b
Posts: 4
Joined: February 8th, 2006, 4:46 pm

Does anyone here know how I would go about finding the exact dimensions of a text layer?

My problem: I want to place a mask around a text layer in the same way that Mask -> New Mask works. When you do it via the interface the mask automatically gets set around the bounding resize box of the text.

Unfortunatly when I add a mask via scripting, it gets set to a default of 1,1,0,0 not very useful for me as I need it to surround the text layer in the same way New Mask works.

Anyone here have any suggestions as to how I would go about doing this? I've looked everywhere but I can't seem to find anyone that has done this, nore do the docs provide any useful information.

Thanks!
Mylenium
Posts: 139
Joined: July 20th, 2005, 12:07 am

Not really. Since there are no methods for accessing font data such as font face and size, it's nearly impossible. The only solution I see is to hard-code something if you know which fonts you will be using. With a little trial and error you could create a reference list that gives you the bounding box of each typeface at a given size. Based on that sizes and using typografic units you could then calculate the layer size by parsing the text layer's source text string. However, this still does not factor in kerning and other trickery used for creating good looking text.

Mylenium
[Pour Mylène, ange sur terre]
b0b
Posts: 4
Joined: February 8th, 2006, 4:46 pm

Yeah, I figured this was due to having no access to font data.

The problem with hard coding is as you said, due to kerning et al.

My only choice is to split the script into 2, one to generate all the text, then go into AE and create the masks en-mass then run the second half using those masks, I was trying to avoid that since itterating layers is a pain.

Incidentally, has anyone heard of Adobe releasing the scripting doc for AE7?

Apriciate the response.
vidpat
Posts: 86
Joined: October 21st, 2004, 12:36 am
Location: Phoenix, AZ
Contact:

If it would be acceptable and practical for your purposes to convert the text to paths, you could find the bounding box of all of the resulting masks. Of course, the text would no longer be character-editable and Text Animators would not work.
b0b
Posts: 4
Joined: February 8th, 2006, 4:46 pm

It's possible to do that via scripting?, converting it to paths would be just fine that would help me in calculating the size of the mask.
vidpat
Posts: 86
Joined: October 21st, 2004, 12:36 am
Location: Phoenix, AZ
Contact:

Well, as with most things involving Text Layers, there doesn't seem to be a way to convert the text via script (at least as of 6.5). Of course, there may be some undocumented method.

You would still need to split your script in two. However, I think it would be easier to just convert all of the Text Layers than creating the masks by hand. Let the second half of the script to the work of finding the dimensions and adding the mask.
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

Someone wrote a plugin that told the text bounding box. I think it was only for PC though. I can't seem to find the post where we talked about it. Anyone else remember it?
b0b
Posts: 4
Joined: February 8th, 2006, 4:46 pm

Haha, really? I was *just* looking at the sdk to see if I could do it with a plugin, I could then read those values into my jsx.

The operation I'm trying to do is too simple for a plugin and too complex for an expression, it's really not worth writing an entire plugin for it. Plus I'll lose the simplicity in changing the script and re-running it on a case-by-case basis.

If someone could find that plugin or give any hits as to what it's called or where it may be that would be great!
Mylenium
Posts: 139
Joined: July 20th, 2005, 12:07 am

byronnash wrote:Someone wrote a plugin that told the text bounding box. I think it was only for PC though. I can't seem to find the post where we talked about it. Anyone else remember it?
Yeah, I know what you mean. Haven't got the link handy, though. Wasn't that useful, since it required you to actually change the font size interactively before it would do its magic. so I guess, it's out of the game for this purpose.

Mylenium
[Pour Mylène, ange sur terre]
vidpat
Posts: 86
Joined: October 21st, 2004, 12:36 am
Location: Phoenix, AZ
Contact:

I think the plug-in in question is the one that I wrote a while back. See http://www.aenhancers.com/viewtopic.php?t=150.

Due to the limitations of the effects API, it had some odd behavior. I'm not sure it will provide the information you need to a script, since it calculates the bounding box when the frame is rendered. This is useful for expressions, as they are evaluated per frame. Scripts on the other hand run independent of rendering. Also, because of the way Text Layers are implemented, the plug-in can only determine the bounding box of text that is contained entirely within the comp. You can give it a try, it may do what you need.
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

I've read expression values in a script before. I wonder if you could use that method for this application. I wrote an expression that changed the source text every frame and then read the source text value in my script. I was getting timecode info but I don't see why this wouldn't work.
Post Reply