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

Is it possible to adapt the fontsize to solve a text overflow? with javascript...

Participant ,
Jun 02, 2012 Jun 02, 2012

Copy link to clipboard

Copied

Adapting fontsize.png

I saw scripts that adapt a box to the amout of text, but i'am looking for a script that does it the other way arround.

I have a amout of text that has to fit in a predefined box for example 50 x 30 mm.

The script has to slove the text overflow issue by adapting the fontsize.

Is this possible?

Cheers Daniel

TOPICS
Scripting

Views

855

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
Enthusiast ,
Jun 03, 2012 Jun 03, 2012

Copy link to clipboard

Copied

Something like this, with underscore.js

#include "underscore.js"

var t = app.selection[0], l = t.contents.replace(/\r/g, '').length;

while (l != _.reduce(t.lines, function(memo, line){ return memo + line.characters.length; }, 0))

    t.textRange.characterAttributes.size = t.textRange.characterAttributes.size * 0.98;

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
Participant ,
Jun 03, 2012 Jun 03, 2012

Copy link to clipboard

Copied

Cool gona try it, thankx moluapple.

Daniel

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
Enthusiast ,
Jun 03, 2012 Jun 03, 2012

Copy link to clipboard

Copied

LATEST

Wait, the last line can just be:

t.textRange.characterAttributes.size *= 0.98;

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