Photoshop CS3脚本-字体名称 [英] photoshop cs3 scripting - font names

查看:208
本文介绍了Photoshop CS3脚本-字体名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用接受字符串的textItem.font来设置textItem的字体,但是我不知道在代码中引用的确切字体名称, 我正在努力实现这样的目标

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

但是要在代码中引用的字体名称与在photoshop UI中显示的字体名称不同 例如Arial是ArialMT,arial粗体是Arial-BoldMT.我在哪里可以获得所有字体名称? 我在javascript参考中找不到它.

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.

推荐答案

Photoshop可用的字体在app.fonts中列出.要将所有字体列出到Extendscript Tools控制台,请执行:

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

您可以使用app.fonts.getByName('String')方法来调用app.fonts数组中名称与String匹配的第一种字体.

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.

这篇关于Photoshop CS3脚本-字体名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆