text2d
A block of text drawn in the 2D pass, pixels_per_unit font pixels per world unit.
On this page
2d · render · 19 properties · 2D
A block of text drawn in the 2D pass, pixels_per_unit font pixels per world unit.
In a scene, text2d is the node key that applies it. A script reaches each property below as a field on node.text2d: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.text2d.get() and node.text2d.set(table).
Properties
| property | type | default | description |
|---|---|---|---|
color |
color | [1,1,1,1] |
Tint, as channel floats or #rrggbb / #rrggbbaa |
font |
asset · font |
— | The face it draws in, and how: a face file such as fonts/Inter.ttf, or a font asset. Empty takes the theme's default font |
font_size |
float | 32 |
Height in font pixels, before pixels_per_unit sizes it in the world At least 1. |
font_style |
enum | normal |
Upright, the family's italic face, or the upright face slanted; a family with no italic is slanted either way One of normal, italic, oblique. |
font_weight |
int | 400 |
Stroke weight, 400 regular and 700 bold Range 100–900. |
line_break |
enum | word_or_glyph |
Where a wrapped line may break: between words with a too-long word cut anywhere, between words only, or anywhere One of word_or_glyph, word, glyph. |
markup |
bool | false |
Read the text as markup: bold, italic, colour, alignment, wave and inline images |
material |
asset · material |
— | The material every layer draws with, reading the glyph atlas as its texture; empty takes an inherited material component, else the built-in one. Its [surface] says whether the glyphs are cut out (alpha = "mask"), which sides of a text3d draw and whether the scene hides it |
max_height |
float | 0 |
Font pixels the lines stop at; zero has no limit At least 0. |
max_lines |
int | 0 |
The most lines a block keeps; zero keeps every line At least 0. |
max_width |
float | 0 |
Font pixels the lines wrap at; zero runs the text on one line At least 0. |
pixels_per_unit |
float | 100 |
Font pixels to one world unit, sizing the block the way a sprite is sized At least 0.01. |
tab_width |
int | 8 |
Spaces between tab stops Range 1–64. |
text |
string | — | The text drawn; text_key wins over it |
text_align |
enum | center |
Where the block sits across the node's origin, and its lines within it: start and end follow the text's direction, left and right do not, justify stretches every full line One of start, center, end, left, right, justify. |
text_key |
string | — | A key in the project's strings, re-read every frame so a language change shows at once |
text_style |
asset · text_style |
— | How it is dressed past its font: line height and spacing, the lines drawn with the glyphs, an outline and a shadow. Empty draws it plain |
truncate |
bool | false |
End a block cut short with an ellipsis; needs max_width, and cuts at max_lines or max_height when either is set, else at one line |
truncate_at |
enum | end |
Which part of a cut line the ellipsis stands in for One of end, start, middle. |
Asset types this component references: font, material, text_style.