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

Script to resize text to fit box

Contributor ,
Feb 15, 2019 Feb 15, 2019

Copy link to clipboard

Copied

I currently have a box area and I need to have text fit into that box and retain it's proportions either height or width.

I can partially accomplish this by setting my type and doing an envelope distort (Alt + Ctrl + C) my results are this:

Screen Shot 2019-02-15 at 10.52.43 AM.png

The problem with this is that the text is stretched out and forced to fit.  In some cases this would be fine but not in my specific case.  Here is an example of it being just two characters.

Screen Shot 2019-02-15 at 10.55.13 AM.png

I would need it to be like this:  Screen Shot 2019-02-15 at 10.57.45 AM.png

I need it to be that if fits either height or width but not forced to do both.  I'm using illustrator cc 2019.

Any ideas how this can be accomplished?

TOPICS
Scripting

Views

1.4K

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
Community Expert ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

Do you need the text to remain live? Or can you work with expanded/outlined text?

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 ,
Feb 18, 2019 Feb 18, 2019

Copy link to clipboard

Copied

How about copy and pate in front before outlined like below?

var tg = app.selection[0]; //keep selection

app.copy();

app.executeMenuCommand("pasteFront");

app.executeMenuCommand("outline");

var bnds = app.selection[0].geometricBounds;

var bx = app.activeDocument.pathItems.rectangle(bnds[1],bnds[0],bnds[2]-bnds[0],bnds[1]-bnds[3]);

bx.filled = false;

bx.stroked = true;

bx.strolkeWeight = 0.3;

app.selection[0].remove();

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
Contributor ,
Feb 19, 2019 Feb 19, 2019

Copy link to clipboard

Copied

I would need the text to remain live. 

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
Valorous Hero ,
Feb 19, 2019 Feb 19, 2019

Copy link to clipboard

Copied

You may be able to use some of the overset-text routine in the "Conditional Distance" demonstration here: 'Conditional Distance' algorithm

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
Contributor ,
Feb 19, 2019 Feb 19, 2019

Copy link to clipboard

Copied

LATEST

Will check it 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