Copy link to clipboard
Copied
i want to identify the overset text in all text frames and reduce the font size for all overset text frames.
But the script only run on selected text frame.
#target illustrator
test();
function test(){
var doc = app.activeDocument;
var sel = doc.selection[0];
var contents = sel.contents;
for(var i = 0; i < sel.lines.length; i++){
contents = contents.replace(sel.lines.contents, "");
}
//alert(contents);
reduceSizeOfOversetText(app.selection[0]);
};
function reduceSizeOfOversetText(t) {
var d;
while (
d = t.duplicate(),
d.name = 'temp',
d.convertAreaObjectToPointObject(),
d = t.parent.textFrames['temp'],
d.contents.replace(/[\x03\r]/g, '') !== t.contents.replace(/[\x03\r]/g, '')
)
{
d.remove();
// alert(t.textRange.characterAttributes.size)
if ((t.textRange.characterAttributes.size)<5.5)
{
alert("Text has been overflown with point size of 5 points, please check the overflow text and fix as per SOP")
return;
// return false;
//break;
// exit()
}
t.textRange.characterAttributes.size -= 1;
}
d.remove();
}
kindly help on this.
Thanks in advance
Regards
Ashok
Your test function check only first selection. You have to make for~ loop like below.
function test(){
var doc = app.activeDocument;
for (var j=0;j<doc.textFrames.length;j++){
reduceSizeOfOversetText(doc.textFrames
); }
}
You can reference make loopin JavaScript.
Copy link to clipboard
Copied
Your test function check only first selection. You have to make for~ loop like below.
function test(){
var doc = app.activeDocument;
for (var j=0;j<doc.textFrames.length;j++){
reduceSizeOfOversetText(doc.textFrames
); }
}
You can reference make loopin JavaScript.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now