Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

How to have the text resize automatically to fit a shape

New Here ,
Feb 19, 2025 Feb 19, 2025

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.

TOPICS
Expressions , How to
888
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 19, 2025 Feb 19, 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
Translate
Community Expert ,
Feb 19, 2025 Feb 19, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2025 Mar 07, 2025

How can I use it please help me

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 07, 2025 Mar 07, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 07, 2025 Mar 07, 2025
LATEST

If you also wanted to automate centering the text on the circle, you could use a position expresion like this for the text layer:

 

L = thisComp.layer("Shape Layer 1");
r1 = L.sourceRectAtTime(time,false);
c1 = L.toComp([r1.left + r1.width/2,r1.top + r1.height/2]);
r2 = sourceRectAtTime(time,false);
c2 = toComp([r2.left + r2.width/2,r2.top + r2.height/2]);
delta = c2 - c1;
value - delta

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines