Skip to main content
tutorials

How to Get True Text Layer Size in After Effects

By July 19, 2019No Comments

Ukramedia shows a way to get correct text layer size in After Effects with expressions.

SourceRectAtTime is a valuable expression inside of Adobe After Effects. The expression lets you get the width and height of text and shape layers. It’s a great way to set up some dynamic properties that change with the size of the text layer. That is if the text layer’s scale is 100%. If it’s not, the expression doesn’t work as you might think. This new tutorial from Ukramedia shows how you can get the correct text layer size using expressions, even if the source layer isn’t at 100% scale.

The expression compensates for both width and height by adding a couple of extra lines of code:

CODE FOR WIDTH:

targetLayer = thisComp.layer(“Layer Name”);

w = targetLayer.sourceRectAtTime().width;

s = targetLayer.transform.scale[0];

p = (s – 100)* .01;

finalSize = w + p * w;

finalSize

And 

CODE FOR HEIGHT:

targetLayer = thisComp.layer(“Layer Name”);

h = targetLayer.sourceRectAtTime().height;

s = targetLayer.transform.scale[1];

p = (s – 100)* .01;

finalSize = w + p * h;

finalSize

lesterbanks

3D, VFX, design, and typography. Twenty year veteran instructor in all things computer graphics.