-
Expression Error – Auto-Scaling text
Hi All,
I’ve found this expression which uses the scale property to auto scale the text depending on the amount of characters.
here: https://medium.com/@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]