i am trying to set the font of a textItem, using textItem.font which accepts a string, but i do not know the exact font names to refer in code, i am trying to achieve something like this
var newLayer = docRef_1.artLayers.add();
newLayer.kind=LayerKind.TEXT;
var textItemRef = newLayer.textItem;
textItemRef.contents = someCharacter;
textItemRef.size = 120;
textItemRef.font="Verdana-Bold";
but the font names to refer in code are not the same as they appear in photoshop UI for e.g Arial is ArialMT, arial bold is Arial-BoldMT. Where can i get all the font names? i could not find it in the javascript reference.
The fonts available to Photoshop are listed in app.fonts
. To list all fonts to the Extendscript Tools console, execute:
for (i=0; i< app.fonts.length; i++) {
$.writeln(app.fonts[i].name);
}
You can use the app.fonts.getByName('String')
method to call the first font in the app.fonts
array that matches String
in its name.