Use Javascript font names

New Here ,
Aug 08, 2020 Aug 08, 2020

Copy link to clipboard

Copied

I want to change the font of the selected text. For example I want to change the font to Arial.

 

selection[0].textRange.characterAttributes.textFont = textFonts["ArialMT"];

 

After a long search I realized that although the list of fonts is Arial the font name is
ArialMT.

 

I am new in scripting. What are the rules for font names? Do you have a list of available font names?

TOPICS
How to , Scripting

Views

608

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 2 Correct answers

Advocate , Aug 08, 2020 Aug 08, 2020
This will produce a list of the names of your fonts (saved in a text file to your desktop). (Change "Username" in the path in line 5 to your username.) var list1 = ""; for (var i = 0; i < textFonts.length; i++){ list1 = list1 + "\r" + i + " - " + textFonts[i].name; } var file1 = new File("/C/Users/Username/Desktop/fonts.txt"); file1.open("e"); file1.write(list1); file1.close();

Likes

Translate

Translate
Adobe Community Professional , Aug 08, 2020 Aug 08, 2020
there is not list, you have to build your own list if you need one.  to find out a font name, apply such font to a text manually, select it and run this script function main () { var idoc = app.activeDocument; var itext = idoc.selection[0]; var itextInfo = itext.textRange.characterAttributes; alert("TextFrame Font Name : " + itextInfo.textFont.name); //$.writeln(itextInfo.textFont.name); } main();

Likes

Translate

Translate
Advocate ,
Aug 08, 2020 Aug 08, 2020

Copy link to clipboard

Copied

This will produce a list of the names of your fonts (saved in a text file to your desktop). (Change "Username" in the path in line 5 to your username.)

 

var list1 = "";
for (var i = 0; i < textFonts.length; i++){
  list1 = list1 + "\r" + i + " - " + textFonts[i].name;
}
var file1 = new File("/C/Users/Username/Desktop/fonts.txt");
file1.open("e");
file1.write(list1);
file1.close();

 

 

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
Adobe Community Professional ,
Aug 08, 2020 Aug 08, 2020

Copy link to clipboard

Copied

there is not list, you have to build your own list if you need one. 

 

to find out a font name, apply such font to a text manually, select it and run this script

function main () {
    
    var idoc = app.activeDocument;
    var itext = idoc.selection[0];
    var itextInfo = itext.textRange.characterAttributes;
    alert("TextFrame Font Name : " + itextInfo.textFont.name);
    //$.writeln(itextInfo.textFont.name);
}

main();

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 ,
Dec 19, 2021 Dec 19, 2021

Copy link to clipboard

Copied

How to use javascript for font-size in use document

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
Adobe Community Professional ,
Dec 19, 2021 Dec 19, 2021

Copy link to clipboard

Copied

function main () {
    
    var idoc = app.activeDocument;
    var itext = idoc.selection[0];
    var itextInfo = itext.textRange.characterAttributes;
    alert("TextFrame Font Name : " + itextInfo.textFont.name);
    //$.writeln(itextInfo.textFont.name);
    alert("TextFrame Font Size : " + itextInfo.size);
}

main();

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 ,
Dec 19, 2021 Dec 19, 2021

Copy link to clipboard

Copied

LATEST

Thank you very much, it worked

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