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
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?
Copy link to clipboard
Copied
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){
}
};
}
function removeNotesOnText(){
for (var i = 0; i < doc.textFrames.length; i++) {
var t = doc.textFrames;
}
}
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)){
}
}
} else if(textBox.characters.length > 0){
var inc = 0.01;
while(isOverset(textBox)){
}
}
}
function resetSize(textAreaBox){
var t = textAreaBox;
if(t.contents != ""){
if(t.note != ""){
}
}
}
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