Generate text with font name of an existing text field

New Here ,
Sep 06, 2022 Sep 06, 2022

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. 

_swolleneyes_0-1662483932314.png

am I expecting too much? 🙂 

 

TOPICS
Feature request , How to , Scripting , Type

Views

92

Likes

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

correct answers 1 Correct answer

Advisor , Sep 06, 2022 Sep 06, 2022

 

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 {
...

Likes

Translate

Translate
Advisor ,
Sep 06, 2022 Sep 06, 2022

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;
}

 

Likes

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
New Here ,
Sep 08, 2022 Sep 08, 2022

Copy link to clipboard

Copied

LATEST

wow, femke. you wrote that so fast and it works perfectly.

Thank you!

Likes

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