Adobe 23101335 Scripting Guide - Page 67

Warping text, 3.11 Selections

Page 67 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.10.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.11 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. For example, you may apply effects to a selection or copy the current selection to the clipboard. But remember that you may have to set the active layer before acting on the selection. Here's how: Photoshop 7.0 Scripting Guide 67

  • 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

Photoshop 7.0 Scripting Guide
67
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.10.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.11 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.
For example, you may apply effects to a selection or copy the current selection to the
clipboard. But remember that you may have to set the active layer before acting on the
selection. Here’s how: