Copy link to clipboard
Copied
Hi, was wondering if it's possible to use AI script to generate a "label" underneath existing text fields that indicates which font was used. For ex. in the image below, the script would add those smaller font name labels under the "sample text" text boxes.
am I expecting too much? 🙂
var distance = 5; // below descender (point text) or text path (area text)
var size = 5; // font size
var doc = app.activeDocument;
var frames = [];
for (var i = 0; i < doc.textFrames.length; i++) {
frames.push(doc.textFrames[i]);
}
for (var i = 0; i < frames.length; i++) {
var x = frames[i].position[0];
if (frames[i].kind == "TextType.POINTTEXT" ||
frames[i].kind == "TextType.AREATEXT") {
var y = frames[i].position[1] - (frames[i].height + distance);
} else {
...
Copy link to clipboard
Copied
var distance = 5; // below descender (point text) or text path (area text)
var size = 5; // font size
var doc = app.activeDocument;
var frames = [];
for (var i = 0; i < doc.textFrames.length; i++) {
frames.push(doc.textFrames[i]);
}
for (var i = 0; i < frames.length; i++) {
var x = frames[i].position[0];
if (frames[i].kind == "TextType.POINTTEXT" ||
frames[i].kind == "TextType.AREATEXT") {
var y = frames[i].position[1] - (frames[i].height + distance);
} else {
continue;
}
var text = doc.textFrames.pointText([x, y]);
text.contents = frames[i].textRange.textFont.name;
text.textRange.size = size;
}
Copy link to clipboard
Copied
wow, femke. you wrote that so fast and it works perfectly.
Thank you!