Text
The text object displays single or multi-line text.
Mandatory properties
The following properties are available in addition to the common label object properties.
| Property | Type | Description |
|---|---|---|
| type | string | Must be Text. |
| text | string | Text to display. May contain dynamic text. |
| font | font | Text font. |
| color | string | Text color. May contain dynamic text. |
Optional properties
The following properties are available in addition to the common label object properties.
| Property | Type | Description |
|---|---|---|
| width | number | Width of the text box. If present, the text will not grow beyond the width but will be word wrapped. If omitted the text will grow horizontally. |
| height | number | Height of the text box. |
| hAlign | string | Horizontal text alignment. Allowed values: LEFT, CENTER, RIGHT, JUSTIFIED. |
| vAlign | string | Vertical text alignment. Allowed values: TOP, CENTER, BOTTOM. |
| letterSpacing | number | Extra spacing between letters. May be negative. |
| lineSpacing | number | Extra spacing between lines. May be negative. |
| styleFormat | string | Text style language. Allowed values: NONE, SIMPLE, ADVANCED. Default is NONE. |
Simple text style
If the styleFormat property is SIMPLE, then the text will be formatted using asterisk (*) characters. Text between asterisks will be highlighted by changing the font style, e.g. from Regular to Bold.
Example
"text": "Ingredients: Water, sugar, *egg*, salt."
Advanced text style
If the styleFormat property is ADVANCED, then the text can be formatted by adding formatting blocks composed of a list of space separated key-value pairs, enclosed in square brackets. An empty formatting block will restore the previous format. Formatting can be nested.
Example
"text": "Hello, [font-height=\"20mm\" color=\"red\"]huge[] world!"
The following keys are supported:
| Key | Description |
|---|---|
color | Set the text color, e.g. color="rgb(20%,70%,40%)". |
font-family | Set the font family, e.g. font-family="Arial". |
font-style | Set the font style, e.g. font-family="Bold Italic". |
font-height | Set the font height, e.g. font-height="20mm". The supported units are: "mm" for millimeters, "pt" for points and "%" for a relative size. The unit "px" for pixels available to support legacy labels, but should not be used for new labels. |
font-width | Set the font width, e.g. font-width="80%". The only supported unit is percent (%). |
Example
{
"type": "Text",
"x": 10.0,
"y": 10.0,
"text": "Hello, world!",
"color": "rgb(20%, 0%, 80%)",
"font": {
"family": "Liberation Sans",
"height": 10.0,
"style": "Bold",
"width": 1.5
}
}