TextItem
The Class that groups all Type related properties of a Text Layer in Photoshop.
Copied to your clipboardconst app = require('photoshop').app;const textItem = app.activeDocument.activeLayers[0].textItem;
Some properties and methods are available directly in the TextItem instance itself:
Copied to your clipboardtextItem.contents; // "Lorem Ipsum"textItem.contents = "Hello World";textItem.isPointText; // trueawait textItem.convertToParagraphText();
Most properties and methods are grouped for convenience in the characterStyle and paragraphStyle properties of TextItem.
Copied to your clipboardtextItem.characterStyle.size; // 12textItem.characterStyle.size = 24;textItem.paragraphStyle.hyphenation; // true
Finally, the warpStyle object contains all the properties related to the Warp effect applied to the text layer.
Copied to your clipboardtextItem.warpStyle.style; // "arcLower"
Please note that for some properties that are expressed in pixels, the valid range of values might depend on the document's resolution. When this is the case, you'll find that in the documentation "for a 72ppi document" is specified.
An example is the font size:
Copied to your clipboard// Range: 0.01..1296—for a 72ppi documenttextItem.characterStyle.size = 1000;
If you want to find the range for documents with a different resolution, please use the following conversion formula:
Copied to your clipboardnewVal = (documentResolution / 72) * referenceVal;// I.e., for a 300ppi document the maximum font size will be:// (300 / 72) * 1296 = 5400px
Upon setting a value, validation will be performed internally. An invalid value will result in a Range Error.
Properties
characterStyle
• characterStyle: CharacterStyle
The object that stores properties related to the Character panel in the Photoshop UI.
paragraphStyle
• paragraphStyle: ParagraphStyle
The object that stores properties related to the Paragraph panel in the Photoshop UI.
warpStyle
• warpStyle: WarpStyle
The object that stores properties related to the Warp Text dialog.
Properties
Name | Type | Access | Default | Min Version | Description |
---|---|---|---|---|---|
contents | string | R W | - | 24.1 | The actual text of the Layer. |
isParagraphText | boolean | R | - | 24.1 | True if the Text Layer is a "Paragraph Text": text that uses boundaries to control the flow of characters, either horizontally or vertically. |
isPointText | boolean | R | - | 24.1 | True if the Text Layer is a "Point Text": a horizontal or vertical line of text that begins where the user clicks in the image. |
orientation | R W | HORIZONTAL | 24.1 | The text orientation. | |
parent | R | - | 24.1 | The parent Layer | |
textClickPoint | object | R W | - | 24.1 | The text insertion point in the document, as an `{x, y}` object where the coordinates are expressed in pixels. |
typename | string | R | - | 24.1 | The typename |
Methods
convertToParagraphText
24.1Promise<TextItem>
Convert a Text Layer from Point Text to Paragraph Text
convertToPointText
24.1Promise<TextItem>
Convert a Text Layer from Paragraph Text to Point Text
convertToShape
24.1Promise<void>
Convert the Text Layer into a Shape Layer
createWorkPath
24.1Promise<void>
Create a Work Path from the Text Layer