Page 1 of 1

Modify Expression " Auto Scale Text"

Posted: February 2nd, 2020, 7:03 pm
by nuwanz

Hello enhancers, This forum helped me to solve a lot of script-based problems in ae.
This is my first time posting a question.

Need expert help in modifying auto-scale text script.
I want below auto-scale text expression to work on both width and height.

Right now it only works for text length(width).
When increasing the text length script decrease the text size automatically.
But when increasing text height(or adding more text lines) it doesn't work.

resize = (w/Math.round(thisLayer.sourceRectAtTime().width))*100;

if (Math.round(thisLayer.sourceRectAtTime().width) > w){




Can you help me to modify it as ".width-100.height-200"

Thank you so much,
Nuwan T.

Re: Modify Expression " Auto Scale Text"

Posted: February 25th, 2020, 12:23 am
by s.kargar78

i think if you use this on your text it will solves your problem:

apply to anchor point:
sourceSize = thisLayer.sourceRectAtTime(time, false);
T =;
L = sourceSize.left;
W = sourceSize.width;
H = sourceSize.height;
([L+ W/2,T+H/2])

apply to position:
H = thisComp.height;
W = thisComp.width;
[W/2, H/2]

apply to scale:
layerW = thisLayer.sourceRectAtTime(time).width;
compW = thisComp.width;
maxW = compW;
s = maxW / layerW * 100;

i find this in
thanks Dan Ebbert