Skip to main content

text2d

2d · render · 19 properties · 2D

A block of text drawn in the 2D pass, shaped by the engine's fonts and sized at pixels_per_unit font pixels to the world unit.

In a scene, text2d is the node key that applies it. A script reaches the same properties through node.text2d.get() and node.text2d.set(table).

Properties

propertytypedefaultdescription
alignenumcenterWhere the block sits across the node's origin One of start, center, end.
colorcolor[1,1,1,1]Tint, as channel floats or #rrggbb / #rrggbbaa
familyenumuiWhich of the project's font chains to shape with One of ui, heading, mono, icons.
fontstringA project-relative AngelCode .fnt naming a bitmap face; empty shapes with the project's vector fonts
font_sizefloat32Height in font pixels, before pixels_per_unit sizes it in the world At least 1.
font_styleenumnormalUpright or italic One of normal, italic.
font_weightint400Stroke weight, 400 regular and 700 bold Range 100–900.
letter_spacingfloat0Extra space between glyphs, in font pixels
line_heightfloat0Baseline to baseline as a multiple of the size; zero takes the default At least 0.
markupboolfalseRead the text as markup: bold, italic, colour, alignment, wave and inline images
max_widthfloat0Font pixels the lines wrap at; zero runs the text on one line At least 0.
outline_colorcolor[0,0,0,1]The outline's colour
outline_sizefloat0Font pixels the outline reaches around the glyphs; zero draws none At least 0.
pixels_per_unitfloat100Font pixels to one world unit, sizing the block the way a sprite is sized At least 0.01.
shadow_colorcolor[0,0,0,0.5]The shadow's colour
shadow_offset_xfloat0Font pixels the shadow is moved along x; zero with y draws none
shadow_offset_yfloat0Font pixels the shadow is moved along y
textstringThe text drawn; text_key wins over it
text_keystringA key in the project's strings, re-read every frame so a language change shows at once

Script functions

Methods of node.text2d, the handle a node carrying this component exposes. Each is also a free function on its module, taking the node as its first argument. Every handle also has get(), set(table), has() and remove().

From render:

methodwhat it does
set_text(string)Replace the text a node draws. The block re-shapes on the next frame; a text_key on the node still wins over it.
text() -> stringThe text a node draws, as it was last set — not the localized string a text_key resolves to.