This content has been marked as final. Show 10 replies
No. Text alignment is determined by the properties of the text layer, meaning that the actual rendered pixels are derived from the contours in relation to the glyph bounding box and kerning info found in the font file. Hence the placement of the anchor point or other text-specific stuff is derived from the true typographical data, which in effect means that the anchor point will almost never be placed in the vertical center because the text engine will respect baseline settings and line spacing. Therefore aligning text automatically is not even possible with the Align&Distribute palette. You could only coerce AE by creating the text in Photoshop and importing the pixel data. In that case you could use Align&Distribute to center the text by creating a comp size solid as reference. You can always convert such text to editable text later.
A, bummer.<br />Well, here's to hoping CS4 will bring better text box options from InDesign... (I know, I won't hold my breathe... <G>).<br />Thanks!<br />k.
It is possible to do this via scripting, but it won't be "live", i.e. you would have to run a script to grab the dimensions of the text layer each time you want to update its vertical alignment.
It is also possible to roughly align text vertically using expressions given three limitations:
1) You'll have to be willing to consider the height of the text layer to only extend from the cap height of the first line to the baseline of the last line, meaning descenders and ascenders wouldn't be counted as part of the height of the text layer.
2) You'll have to manually locate the center of the first line of text.
3) You'll have to be happy with a consistent point size and line spacing throughout.
Given those limitations, vertical alignment can be done as follows:
Add a Position animator to your text layer. Delete the default range selector you won't need it. Next add the Line Spacing property to the newly-created animator (using its "Add" menu). In the Character panel, set your text layer's line spacing to 0 (it will really be set to .01, but the difference shouldn't be noticeable once we're done). In the Line Spacing animator, set the desired line spacing (unfortunately, "Auto" isn't an option).
Now set your Text layer's anchor point such that it falls in the center of the text's cap height (the height of a capital letter with no ascender or descenders).
Next, add the following expression to the Position property of the text animator (NOT the Position property of the text layer's Transform group):
>STA = text.sourceText.split("\r");
>value - [0, (STA.length-1)*propertyGroup(countUp = 2).property.lineSpacing]/2
The second line should be all one line, but the forum insists on wrapping it. Be aware that if you later decide to change the point size of the font, you'll need to temporarily disable the text animator and center up the anchor point again.
You can also use this method to force the text layer to shift up to accommodate new lines by deleting the "/2" at the end of the second line of the expression.
Nice, Aaron. It looks like you've done this one before. :)
BTW, for all folks interested: CS4 scripting will introduce some new methods (not for expressions, unfortunately) that deal with matters of getting the text bounding box, setting font sizes and a few other things, so this might become a bit easier.
Where'd you hear about the scripting additions? Is there any information on the web?
> Where'd you hear about the scripting additions?
A little bird that works in my building probably told him.
> Is there any information on the web?
That same little bird is working on a summary of changes to scripting for After Effects CS4. Stay tuned.
Todd is in a funny mood today... ;-)