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

Auto-scale text size to Paragraph bounding box

Explorer ,
May 06, 2024 May 06, 2024

Copy link to clipboard

Copied

Is there a way to auto scale each row of text so that it aligns on both the left and right side?

 

Ideal would be if every row of text is seperated with a line break so that I can choose the amount of text on each row.

Is it possible to connect the width of each row to the Paragraph Text Bounding box?
Is it possible to change the leading of each row with a expression slider?

 

Skärmavbild 2024-05-06 kl. 10.21.20.png 

TOPICS
Expressions , How to

Views

275

Translate

Translate

Report

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 , May 06, 2024 May 06, 2024

Text expressions only allow one font size or scale operator, so you need three text layers. You can't scale individual lines in a text box with an expression.

 

With the Anchor Point centered, Position tied to the layer above, and scale based on a percentage of the comp width, you can use sourceRectAtTime() to make the appropriate calculations. An expression to a text layer's Anchor Point and modified by scale will always center the anchor point in the text. Use scale multiplied by sourceRectAtT

...

Votes

Translate

Translate
Participant ,
May 06, 2024 May 06, 2024

Copy link to clipboard

Copied

do you want this to be 1 text layer, or 3 seperate text layers ?

Votes

Translate

Translate

Report

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 ,
May 06, 2024 May 06, 2024

Copy link to clipboard

Copied

Text expressions only allow one font size or scale operator, so you need three text layers. You can't scale individual lines in a text box with an expression.

 

With the Anchor Point centered, Position tied to the layer above, and scale based on a percentage of the comp width, you can use sourceRectAtTime() to make the appropriate calculations. An expression to a text layer's Anchor Point and modified by scale will always center the anchor point in the text. Use scale multiplied by sourceRectAtTime.height/2 for horizontal positioning and thisComp,width/2 for centering along with an If/Else argument and you can stack up as many layers as you want.

 

Then, you can nest the Text Box comp in your main comp and adjust the position (of the pre-comp/nested comp). to place the text box where it needs to be.

 

Here are the expressions:

 

// Anchor Point
box = sourceRectAtTime();
s = scale[0/100];
[box.width/2 + box.left, box.height/2 + box.top];

// Position
if (index == 1){
	tLyr = index;
	x = thisComp.width/2;

	Ls = scale[0]/100;
	Lh = sourceRectAtTime().height/2 * Ls;
	pad = 20;
	p = [x, Lh + pad];
}
else{
	x = thisComp.width/2;
	TL = thisComp.layer(index - 1);
	TLs = TL.scale[0]/100;
	TLx = TL.position[1];
	TLh = TL.sourceRectAtTime().height/2 * TLs;

	Ls = scale[0]/100;
	Lh = sourceRectAtTime().height/2 * Ls;


	pad = 20;
	p = [x, TLx + TLh + Lh + pad];
	
}

// Scale
w = thisComp.width * .9;// 90% of comp width
box = sourceRectAtTime();
s = w/box.width * 100;
[s, s]

 

RickGerard_0-1715028125099.gif

That should get you started. 

 

note: I probably could have simplified the If/Else arguement.

Votes

Translate

Translate

Report

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
Explorer ,
May 13, 2024 May 13, 2024

Copy link to clipboard

Copied

LATEST

Wow. Thanks.

Always wish there is easier solutions with AE Expressions.

That looks like a really neat solution!

Had to solve i fast so did a quick-n-dirty solution that worked this time but this looks like a much more flexible solution.

Will try it next time!

Thanks Rick!!

Votes

Translate

Translate

Report

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