Adobe 23101764 Scripting Guide - Page 85

Selections

Page 85 highlights

Scripting Photoshop 3 Selections 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. Photoshop CS Scripting Guide 81

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105

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.