How to Get True Text Layer Size in After Effects

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:


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

w = targetLayer.sourceRectAtTime().width;

s = targetLayer.transform.scale[0];

p = (s – 100)* .01;

finalSize = w + p * w;




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

h = targetLayer.sourceRectAtTime().height;

s = targetLayer.transform.scale[1];

p = (s – 100)* .01;

finalSize = w + p * h;


Some of the links on lesterbanks are "affiliate links", a link with a special tracking code. This means if you click on an affiliate link and purchase the item, we will receive an affiliate commission. The price of the item is the same whether it is an affiliate link or not. Regardless, we only recommend products or services we believe will add value to our readers. By using the affiliate links, you are helping support our Website, and we genuinely appreciate your support.