Modify Expression " Auto Scale Text"

Moderators: Disciple, zlovatt

Post Reply
Posts: 1
Joined: February 2nd, 2020, 6:41 pm

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.

Posts: 3
Joined: February 16th, 2020, 5:03 am

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

Post Reply