• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Fit texts in textbox by resizing font size using after effects expression

New Here ,
Sep 09, 2024 Sep 09, 2024

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

TOPICS
How-to , Scripting

Views

166

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Participant ,
Sep 09, 2024 Sep 09, 2024

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
    }
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2024 Sep 09, 2024

Copy link to clipboard

Copied

Thanks, sir for your prompt answer. For use in after effects expression, I can not configure out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2024 Sep 09, 2024

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 09, 2024 Sep 09, 2024

Copy link to clipboard

Copied

LATEST

sorry for posting in wrong forum

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines