Skip to main content
Participant
February 20, 2025
Answered

How to have the text resize automatically to fit a shape

  • February 20, 2025
  • 1 reply
  • 905 views

Hi all, I've seen tons of tutorials on how to have the shape layer auto resize around the text, but I can't seem to find a tutorial for the text that auto-resizes based on the shape. The few tutorials I've found didn't work for some reason, I swear I re-verified the expressions so many times. Can anyone help? the shape is a circle by the way.

Correct answer Dan Ebberts

A scale expression like this should size the text to fit the circle:

d = thisComp.layer("Shape Layer 1").content("Ellipse 1").content("Ellipse Path 1").size[0]; // circle diameter
r = sourceRectAtTime(time,false);
w = r.width;
h = r.height;
angle = Math.atan2(h,w);
wNew = d*Math.cos(angle); // desired text width
sf = wNew/w; //scale factor
[sf,sf]*100

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
February 20, 2025

A scale expression like this should size the text to fit the circle:

d = thisComp.layer("Shape Layer 1").content("Ellipse 1").content("Ellipse Path 1").size[0]; // circle diameter
r = sourceRectAtTime(time,false);
w = r.width;
h = r.height;
angle = Math.atan2(h,w);
wNew = d*Math.cos(angle); // desired text width
sf = wNew/w; //scale factor
[sf,sf]*100
Participant
March 7, 2025

How can I use it please help me

Dan Ebberts
Community Expert
Community Expert
March 7, 2025

If you have a circle shape layer and a text layer, you would apply the expression to the text layer's scale property and it should scale the text so that it will just fit inside the circle. That's all it does.