Mobile app version of vmapp.org
Login or Join
Nimeshi706

: After Effects Scripting : fontSize adjusted to boxTextSize Script Optimization I need Help Improving and optimizing a Script. I'm fairly new to java and scripting in general and I've been Trying

@Nimeshi706

Posted in: #AdobeAfterEffects #Optimization #Script #Text

I need Help Improving and optimizing a Script.

I'm fairly new to java and scripting in general and I've been Trying to do a script that would increase the font Size of a text until it fully fills it's box Limits , and this is what I've come up with so far.

function textResize(v,n){
var myComp = v;
var myTextLayer = myComp.layer(n);
var myText = myTextLayer.sourceText.value;
var orgText = myText.text;
var textBoxSurface = myText.boxTextSize[0]*myText.boxTextSize[1];
var textPixel = myTextLayer.sourceRectAtTime(0,false);
var textPixelSurface = textPixel.height*textPixel.width;

myText.text = "W";
myText.fontSize = 20;
myTextLayer.sourceText.setValue(myText);
textPixel = myTextLayer.sourceRectAtTime(0,false);
textPixelSurface = textPixel.height*textPixel.width;
while (( Math.round((textBoxSurface/textPixelSurface)) >= Math.round(orgText.length) ) ){
myText.fontSize = myText.fontSize +1;
myTextLayer.sourceText.setValue(myText);
textPixel = myTextLayer.sourceRectAtTime(0,false);
textPixelSurface = textPixel.height*textPixel.width;
}

myText.text = orgText;
myTextLayer.sourceText.setValue(myText);

}


it's still inaccurate and even the font size reaches it's limit (1296)!

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Nimeshi706

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme