Skip to main content
Participant
fev. 20, 2025 2:11 AM UTC
Respondido

How to have the text resize automatically to fit a shape

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.

Dan Ebberts
Dan EbbertsResposta
Community Expert
fev. 20, 2025 7:37 AM UTC

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

4 Respostas

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertResposta
Community Expert
fev. 20, 2025 7:37 AM UTC

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
Traduzir
Participant
mar. 7, 2025 11:39 PM UTC

How can I use it please help me

Traduzir
Dan Ebberts
Community Expert
Community Expert
mar. 7, 2025 11:48 PM UTC

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.

Traduzir