-
Automatically scale text layer to accomodate the length of text
Hi all,
I’m trying to scale a text layer automatically so that when I type text into it (or refer to it from an outside source), the text layer automatically scales so that it doesn’t clip off the sides (if it’s long) or look too small (if it’s short).
I found an expresssion online which contains the below code. It sort of works for a few words, but if the text gets too long it seems to shrink exponentially and looks way too small. If there are only a few characters it also looks too big.
I figure if there was an expression that was slightly more advanced then this wouldn’t happen. What would also be ideal would be to be able to set a maximum height for the text, so that if there was only one word or one letter, then it wouldn’t look massive.
So in other words, I would like an expression that told the text to never be wider than 90% of the comp or higher than 15%, for example.
Alas, my programming ability is poor to say the least. So any help would be greatly appreciated! Thanks.
layerWidth = thisLayer.sourceRectAtTime(time).width;
compWidth = thisComp.width;
maximumWidth = compWidth * .9;
percentageOfMaxWidth = layerWidth / maximumWidth * 100;
leeway = 100 - percentageOfMaxWidth;
[100 + leeway, 100 + leeway]