Use the Ae Expression Source Rect At Time and take control over text alignment too.
In After Effects, the expression Source Rect At Time can return the dimensions of both text and shape layers – Once you understand that, the expression quite common for making the text fit into boxes. Quite a few tutorials exist showing how to do this. What if you wanted to change the alignment of text though? Evan Abrams’ latest tutorial explains just that.
“We take another closer look at the SourceRectAtTime expression. Usually used to make boxes the same size as text layers,” Abrams says. The video is a revisit of a previous one, only expanding the first one a bit to show how to handle aligning the text center, left or right in the vector box. To have that kind of control, you need some maths and expressions to get the text the way that you want.