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

Need illustrator javascript to Check and fix the dynamically over flow text

Community Beginner ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

I want to dynamically fit over flow text in a specific txt frame in Illustrator by changing the font size. Is there a way to do this with JavaScript and set a minimum font size that does this action and in case there is still text is over flow show a pop

TOPICS
Scripting

Views

437

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 ,
Aug 08, 2017 Aug 08, 2017

Copy link to clipboard

Copied

Do you have some code written that you want help with, or are you looking to have the code written?

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 Beginner ,
Aug 10, 2017 Aug 10, 2017

Copy link to clipboard

Copied

LATEST

Thanks for the reply,

Below script was based on dataset this will move all the multiline text to single line text by reducing font size without changing the text frame size. But I need code to find the data set with overset text and reduce the font size to fit overset text.

#target illustrator

function DealWithOversetText_SingleLine(){

function recordFontSize(){

for (var i = 0; i < doc.textFrames.length; i++) {

var t = doc.textFrames;

if(t.kind == TextType.AREATEXT && t.editable && !t.locked && !t.hidden){

  1. t.note = t.textRange.characterAttributes.size;

}

};

}

function removeNotesOnText(){

for (var i = 0; i < doc.textFrames.length; i++) {

var t = doc.textFrames;

  1. t.note = "";

}

}

function isOverset(textBox){

if(textBox.lines.length > 0){

if(textBox.lines[0].characters.length < textBox.characters.length){

return true;

} else {

return false;

}

} else if(textBox.characters.length > 0){

return true;

}

}

function shrinkFont(textBox){

var totalCharCount = textBox.characters.length;

var lineCount = textBox.lines.length;

if(textBox.lines.length > 0){

var firstLineCharCount = textBox.lines[0].characters.length;

if(isOverset(textBox)){

var inc = 0.01;

while(isOverset(textBox)){

  1. textBox.textRange.characterAttributes.size -= inc;

}

}

} else if(textBox.characters.length > 0){

var inc = 0.01;

while(isOverset(textBox)){

  1. textBox.textRange.characterAttributes.size -= inc;

}

}

}

function resetSize(textAreaBox){

var t = textAreaBox;

if(t.contents != ""){

if(t.note != ""){

  1. t.textRange.characterAttributes.size = (t.note * 1);

}

}

}

function resetAllTextBoxes(){

for (var i = 0; i < doc.textFrames.length; i++) {

var t = doc.textFrames;

if(t.kind == TextType.AREATEXT && t.editable && !t.locked && !t.hidden){

resetSize(t);

}

};

}

function shrinkAllTextBoxes(){

for (var i = 0; i < doc.textFrames.length; i++) {

var t = doc.textFrames;

if(t.kind == TextType.AREATEXT && t.editable && !t.locked && !t.hidden){

shrinkFont(t);

}

};

}

if(app.documents.length > 0){

var doc = app.activeDocument;

if(doc.activeDataSet == doc.dataSets[0]){

recordFontSize();

}

resetAllTextBoxes();

shrinkAllTextBoxes();

if(doc.activeDataSet == doc.dataSets[doc.dataSets.length - 1]){

removeNotesOnText();

}

}

}

DealWithOversetText_SingleLine();

Regards

ashok

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