Copy link to clipboard
Copied
I searched the web but did not finding the solution. I make a text box & want to dynamically hold texts within it. It uses a fixed font size of 50 but if there are more texts then font size will be reduced to fit all texts within the textbox. Any solution will be highly appreciated
Copy link to clipboard
Copied
there may be a better way, but this had worked for a smaller task of mine. feel free to change the text increment values to whatever text you plan on using. if youre using larger text, then .5 may be too small of an increment.
/*do this to whatever textframe you want to check. but as long as the text frame is returning true for overset, the loop will keep running and each loop will reduce each character by .5 size and .5 leading.*/
while(CheckIfOverset(Selection)){
var CharLen = Selection.textRange.characters.length
for (var p = 0; p < CharLen; p++) {
Selection.textRange.characters[p].size-=0.5
Selection.textRange.characters[p].leading-=0.5
}
}
/* overset function takes area frame, converts to point text and determines if text is overset */
function CheckIfOverset(t) {
var d;
d = t.duplicate()
d.name = 'temp'
d.convertAreaObjectToPointObject()
d = t.parent.textFrames['temp']
if (d.contents.replace(/[\x03\r]/g, '') !== t.contents.replace(/[\x03\r]/g, '')) {
d.remove();
return true
} else {
d.remove();
return false
}
}
Copy link to clipboard
Copied
Thanks, sir for your prompt answer. For use in after effects expression, I can not configure out.
Copy link to clipboard
Copied
Hi @dibyendu_5274 maybe you need to post this question on the After Effects forum. This is the Illustrator forum.
- Mark
Copy link to clipboard
Copied
sorry for posting in wrong forum