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 layers, which is useful when setting up some dynamic properties that change with size – like font-size or letter spacing for example! This new tutorial from Ukramedia shows how to make sure your Source Rectangle always has correct dimensions in order for this calculation function to work smoothly. After watching it let me know what parts stood out most important for creating awesome graphics on screen/print.

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

https://youtube.com/watch?v=UHPNfT9YpiA