Text (Legacy)
- Last UpdatedDec 16, 2023
- 4 minute read
The Text node can be used to show text content on screen.
-
The text can be refreshed, which gives the node flexibility.
-
A Text node can use only one font and one color for all the text content.
-
The Text node inherits from RectBase (Legacy).
-
Text is a 2D node that can be combined to build up complex interface presented to the user in overlay. For more information, see Structuring a 2D interface using hierarchy.
Note: The legacy 2D nodes hierarchy has been replaced with a new and better performing hierarchy: 2D nodes. You should no longer use these older 2D nodes, except for very specific tasks.
Platform support
This node is supported on XR-Windows platform only.
|
XR-WIN |
XR-P-WIN |
XR-P-IOS |
XR-P-AND |
XR-P-WASM |
|---|---|---|---|---|
|
Full support |
No support |
No support |
No support |
No support |
|
|
|
|
|
|
Text formatting
The format field is used to define the text formatting.
Using formatters
Horizontal and vertical formatters define where and how to place the text.
Left Top makes the text start from upper left corner of the text area, while HCenter VCenter places the text in the center.
Formatters does not support word wrap.
For multi-line text messages, place \n where there's the need to go to next line. This may result in a bit of complexity to have longer texts correctly displayed.
Using autoline
The Autoline option is an alternative to vertical and horizontal formatters. It places the text starting from the upper left corner, but provides automatic word wrapping and justified alignment for the text (except the last line).
Autoline is preferred when the text to be placed is not just a word but something longer.
Code example
Code example for the Text node.
<rect name="cestello_rect" image="fondo-big.png" order="10" show="false" opacity="1" position="20 480" size="256 300">
<text show="true" text="volume" font="Baveuse,true,33" format="HCenter VCenter" order="2" position="0 40" size="256 100" color="0 0.11 0.53 1"/>
<text name="tx_volume" show="true" text="@volume_vid@%" font="Baveuse,true,40" format="HCenter VCenter" order="2" position="0 78" size="256 100" color="0 0.11 0.53 1"/>
<text name="tx_peso" show="true" text="peso @peso_kg@Kg" font="Baveuse,true,40" format="HCenter VCenter" order="2" position="0 210" size="256 100" color="1 1 1 1"/>
</rect>
Position
The Text node can be positioned inside a context node, such as Context and Global, or be children of other 2D nodes.
Fields
These are the fields for Text (Legacy) node. Only the node-specific fields are indicated, not fields obtained by inheritance.
Field inheritance: NodeBase > RectBase (Legacy) > Text
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
antialias |
sbool |
Optional |
false |
Set to true to use antialias on text. |
|
color |
svec4 |
Optional |
1 1 1 1 |
Sets the text color in RGBA with normalized (0-1) values. Usually alpha remains set to 1. |
|
font |
sstring |
Optional |
Not set |
The targeted font must be installed on the machine. It accept a string made up of three comma-separated elements. The string format is: fontName,BoldState,size. For example, Tahoma,true,12 for Tahoma bold text with 12 pixel height. |
|
format |
sstring |
Optional |
Not set |
Specifies the text alignment format. Accepts space-separated parameters. For example: HCenter Top.
Alternatively, this parameter can be set to Autoline mode that equals Top Left, but provides automatic word wrap and text alignment. |
|
opacity |
sfloat |
Optional |
1 |
Sets the Rect opacity in the range 0-1. |
|
refresh |
sevent |
Optional |
Not set |
Use this parameter to force text refresh. For other types of refresh, setting a string parameter automatically forces a refresh, so this action causes a refresh display after having changed other parameters such as color or font. |
|
text |
sstring |
Optional |
Null |
Sets the text to display. If changed at runtime it automatically forces display refresh. Also accepts text with field/variable value content assignment, such as: time: @node.field@ or the result is: @variable@ |