ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression Error - Auto-Scaling text

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Finn Hitchcock
Expression Error - Auto-Scaling text
on Apr 17, 2020 at 4:56:15 pm

Hi All,

I've found this expression which uses the scale property to auto scale the text depending on the amount of characters.

here: @loranallensmith/auto-scaling-text-size-in-adobe-after-effects-560b07a6cca2'>

However, when I applied this an error appeared in line 11.

Could anyone help me fix this, or point me in the direction of a similar working expression?

Thanks in advance!


// This lets us get the width of the textbox containing your content.
layerWidth = thisLayer.sourceRectAtTime(time).width;
// This lets us get the width of the current composition.
compWidth = thisComp.width;
// This lets you specify a maximum width that text boxes should not exceed. In this example it’s 90%, but you can set it to whatever you need or even map it to a control.
// Pro-tip: If you have other content in the same horizontal space as your text, remember to account for that content when setting your maximumWidth.
maximumWidth = compWidth * .9;
// This calculates the current percentage of the maximum width that the text layer occupies.
percentageOfMaxWidth = layerWidth / maximumWidth * 100;
// We subtract that percentage from 100 to find out how much space we can spare. If the text box can grow a bit, leeway is positive. If it needs to shrink, leeway will be negative.
leeway = 100 — percentageOfMaxWidth;
// Finally, return an array of [width, height] scale. 100 is the baseline and leeway is how much the layer needs to grow or shrink to fit.
[100 + leeway, 100 + leeway]

Return to posts index

Dan Ebberts
Re: Expression Error - Auto-Scaling text
on Apr 17, 2020 at 5:17:01 pm

This line:

leeway = 100 — percentageOfMaxWidth;

has an illegal character in it for the subtract operator. It should be:

leeway = 100 - percentageOfMaxWidth;


Return to posts index

Finn Hitchcock
Re: Expression Error - Auto-Scaling text
on Apr 17, 2020 at 6:43:58 pm

Ahhh thank you!!

Works perfect :D

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 All Rights Reserved