Photoshop CS Scripting Guide
81
Scripting Photoshop
Selections
3
5. Create a script to get the font name of the text. An example JavaScript is below:
var textLayer = activeDocument.artLayers[0];
if (textLayer.kind == LayerKind.TEXT)
{
alert(textLayer.textItem.font);
}
6. The name that is displayed in the alert dialog is the PostScript name of the font. Use this
name to set the font of your text For example, the above script returned the name
“ArialMT.” The examples below show how to set this font:
AS:
set font of textItemRef to "ArialMT"
VB:
textLayer.TextItem.Font = "ArialMT"
JS:
textLayer.textItem.font = "ArialMT";
3.11.4 Warping text
Warping is another common effect that can be applied to text. To warp a text item-object, set
the object's
warp style (WarpStyle/warpStyle)
property. The style to set it to is an
enumeration.
AS:
set warp style of textItemRef to flag
VB:
textLayerRef.TextItem.WarpStyle = psFlag
JS:
textLayerRef.textItem.warpStyle = WarpStyle.FLAG;
3.12 Selections
There are instances where you will want to write scripts that only act on the current selection.
If you are writing a script that depends on a selection, be sure to set the selection yourself, as
you cannot test for a non-existent selection. When creating new selections, you can add to,
replace, or subtract from a selection.