TextMesh
Inherits: PrimitiveMesh < Mesh < Resource < RefCounted < Object
Description
Section titled “Description”Generate a PrimitiveMesh from the text.
Generate a PrimitiveMesh from the text.
TextMesh can be generated only when using dynamic fonts with vector glyph contours. Bitmap fonts (including bitmap data in the TrueType/OpenType containers, like color emoji fonts) are not supported.
The UV layout is arranged in 4 horizontal strips, top to bottom: 40% of the height for the front face, 40% for the back face, 10% for the outer edges and 10% for the inner edges.
Properties
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| TextSystem.AutowrapMode | autowrap_mode |
0 |
| float | curve_step |
0.5 |
| float | depth |
0.05 |
| Font | font |
|
| int | font_size |
16 |
| HorizontalAlignment | horizontal_alignment |
1 |
| BitField[TextSystem.JustificationFlag] | justification_flags |
163 |
| String | language |
"" |
| float | line_spacing |
0.0 |
| Vector2 | offset |
Vector2(0, 0) |
| float | pixel_size |
0.01 |
| TextSystem.StructuredTextParser | structured_text_bidi_override |
0 |
| Array | structured_text_bidi_override_options |
[] |
| String | text |
"" |
| TextSystem.Direction | text_direction |
0 |
| bool | uppercase |
false |
| VerticalAlignment | vertical_alignment |
1 |
| float | width |
500.0 |
Property descriptions
Section titled “Property descriptions”autowrap_mode
TextSystem.AutowrapMode autowrap_mode = 0
If set to something other than TextSystem.AUTOWRAP_OFF, the text gets wrapped inside the node’s bounding rectangle. If you resize the node, it will change its height automatically to show all the text.
curve_step
float curve_step = 0.5
Step (in pixels) used to approximate Bézier curves. Lower values result in smoother curves, but is slower to generate and render. Consider adjusting this according to the font size and the typical viewing distance.
Note: Changing this property will regenerate the mesh, which is a slow operation, especially with large font sizes and long texts.
depth
float depth = 0.05
Depths of the mesh, if set to 0.0 only front surface, is generated, and UV layout is changed to use full texture for the front face only.
font
Font font
Font configuration used to display text.
font_size
int font_size = 16
Font size of the TextMesh’s text. This property works in tandem with pixel_size. Higher values will result in a more detailed font, regardless of curve_step and pixel_size. Consider keeping this value below 63 (inclusive) for good performance, and adjust pixel_size as needed to enlarge text.
Note: Changing this property will regenerate the mesh, which is a slow operation, especially with large font sizes and long texts. To change the text’s size in real-time efficiently, change the node’s Entity3D.scale instead.
horizontal_alignment
HorizontalAlignment horizontal_alignment = 1
Controls the text’s horizontal alignment. Supports left, center, right, and fill (also known as justify).
justification_flags
BitField[TextSystem.JustificationFlag] justification_flags = 163
Line fill alignment rules.
language
String language = ""
Language code used for line-breaking and text shaping algorithms. If left empty, the current locale is used instead.
line_spacing
float line_spacing = 0.0
Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.
offset
Vector2 offset = Vector2(0, 0)
The text drawing offset (in pixels).
Note: Changing this property will regenerate the mesh, which is a slow operation. To change the text’s position in real-time efficiently, change the node’s Entity3D.position instead.
pixel_size
float pixel_size = 0.01
The size of one pixel’s width on the text to scale it in 3D. This property works in tandem with font_size.
Note: Changing this property will regenerate the mesh, which is a slow operation, especially with large font sizes and long texts. To change the text’s size in real-time efficiently, change the node’s Entity3D.scale instead.
structured_text_bidi_override
TextSystem.StructuredTextParser structured_text_bidi_override = 0
Set BiDi algorithm override for the structured text.
structured_text_bidi_override_options
Array structured_text_bidi_override_options = []
Set additional options for BiDi override.
text
String text = ""
The text to generate mesh from.
Note: Due to being a Resource, it doesn’t follow the rules of Entity.auto_translate_mode. If disabling translation is desired, it should be done manually with Object.set_message_translation().
text_direction
TextSystem.Direction text_direction = 0
Base text writing direction.
uppercase
bool uppercase = false
If true, all the text displays as UPPERCASE.
vertical_alignment
VerticalAlignment vertical_alignment = 1
Controls the text’s vertical alignment. Supports top, center, and bottom.
width
float width = 500.0
Text width (in pixels), used for fill alignment.
