Skip to main content

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.

PropertyTypeDescription
typestringMust be Text.
textstringText to display. May contain dynamic text.
fontfontText font.
colorstringText color. May contain dynamic text.

Optional properties

The following properties are available in addition to the common label object properties.

PropertyTypeDescription
widthnumberWidth 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.
heightnumberHeight of the text box.
hAlignstringHorizontal text alignment. Allowed values: LEFT, CENTER, RIGHT, JUSTIFIED.
vAlignstringVertical text alignment. Allowed values: TOP, CENTER, BOTTOM.
letterSpacingnumberExtra spacing between letters. May be negative.
lineSpacingnumberExtra spacing between lines. May be negative.
styleFormatstringText 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:

KeyDescription
colorSet the text color, e.g. color="rgb(20%,70%,40%)".
font-familySet the font family, e.g. font-family="Arial".
font-styleSet the font style, e.g. font-family="Bold Italic".
font-heightSet 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-widthSet 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
}
}