TextParagraph
Holds a paragraph of text.
Description
Section titled “Description”Abstraction over TextShaping for handling a single paragraph of text.
Properties
Section titled “Properties”Methods
Section titled “Methods”Property descriptions
Section titled “Property descriptions”alignment
Section titled “alignment”HorizontalAlignment alignment = 0
Setter/getter: set_alignment(), get_alignment()
Paragraph horizontal alignment.
break_flags
Section titled “break_flags”TextShaping.LineBreakFlag break_flags = 3
Setter/getter: set_break_flags(), get_break_flags()
Line breaking rules. For more info see TextShaping.
custom_punctuation
Section titled “custom_punctuation”String custom_punctuation = ""
Setter/getter: set_custom_punctuation(), get_custom_punctuation()
Custom punctuation character list, used for word breaking. If set to empty string, server defaults are used.
direction
Section titled “direction”TextShaping.Direction direction = 0
Setter/getter: set_direction(), get_direction()
Text writing direction.
ellipsis_char
Section titled “ellipsis_char”String ellipsis_char = "…"
Setter/getter: set_ellipsis_char(), get_ellipsis_char()
Ellipsis character used for text clipping.
justification_flags
Section titled “justification_flags”TextShaping.JustificationFlag justification_flags = 163
Setter/getter: set_justification_flags(), get_justification_flags()
Line fill alignment rules.
line_spacing
Section titled “line_spacing”float line_spacing = 0.0
Setter/getter: set_line_spacing(), get_line_spacing()
Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.
max_lines_visible
Section titled “max_lines_visible”int max_lines_visible = -1
Setter/getter: set_max_lines_visible(), get_max_lines_visible()
Limits the lines of text shown.
orientation
Section titled “orientation”TextShaping.Orientation orientation = 0
Setter/getter: set_orientation(), get_orientation()
Text orientation.
preserve_control
Section titled “preserve_control”bool preserve_control = false
Setter/getter: set_preserve_control(), get_preserve_control()
If set to true text will display control characters.
preserve_invalid
Section titled “preserve_invalid”bool preserve_invalid = true
Setter/getter: set_preserve_invalid(), get_preserve_invalid()
If set to true text will display invalid characters.
text_overrun_behavior
Section titled “text_overrun_behavior”TextShaping.OverrunBehavior text_overrun_behavior = 0
Setter/getter: set_text_overrun_behavior(), get_text_overrun_behavior()
The clipping behavior when the text exceeds the paragraph’s set width.
float width = -1.0
Setter/getter: set_width(), get_width()
Paragraph width.
Method descriptions
Section titled “Method descriptions”add_object
Section titled “add_object”bool add_object(key: Variant, size: Vector2, inline_align: InlineAlignment = 5, length: int = 1, baseline: float = 0.0)
Adds inline object to the text buffer, key must be unique. In the text, object is represented as length object replacement characters.
add_string
Section titled “add_string”bool add_string(text: String, font: Font, font_size: int, language: String = "", meta: Variant = null)
Adds text span and font to draw it.
void clear()
Clears text paragraph (removes text and inline objects).
clear_dropcap
Section titled “clear_dropcap”void clear_dropcap()
Removes dropcap.
void draw(canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), dc_color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const
Draw all lines of the text and drop cap into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
draw_dropcap
Section titled “draw_dropcap”void draw_dropcap(canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const
Draw drop cap into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
draw_dropcap_outline
Section titled “draw_dropcap_outline”void draw_dropcap_outline(canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const
Draw drop cap outline into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
draw_line
Section titled “draw_line”void draw_line(canvas: RID, pos: Vector2, line: int, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const
Draw single line of text into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
draw_line_outline
Section titled “draw_line_outline”void draw_line_outline(canvas: RID, pos: Vector2, line: int, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const
Draw outline of the single line of text into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
draw_outline
Section titled “draw_outline”void draw_outline(canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), dc_color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const
Draw outlines of all lines of the text and drop cap into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
duplicate
Section titled “duplicate”TextParagraph duplicate() const
Duplicates this TextParagraph.
get_dropcap_lines
Section titled “get_dropcap_lines”int get_dropcap_lines() const
Returns number of lines used by dropcap.
get_dropcap_rid
Section titled “get_dropcap_rid”RID get_dropcap_rid() const
Returns drop cap text buffer RID.
get_dropcap_size
Section titled “get_dropcap_size”Vector2 get_dropcap_size() const
Returns drop cap bounding box size.
get_inferred_direction
Section titled “get_inferred_direction”TextShaping.Direction get_inferred_direction() const
Returns the text writing direction inferred by the BiDi algorithm.
get_line_ascent
Section titled “get_line_ascent”float get_line_ascent(line: int) const
Returns the text line ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
get_line_count
Section titled “get_line_count”int get_line_count() const
Returns number of lines in the paragraph.
get_line_descent
Section titled “get_line_descent”float get_line_descent(line: int) const
Returns the text line descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
get_line_object_rect
Section titled “get_line_object_rect”Rect2 get_line_object_rect(line: int, key: Variant) const
Returns bounding rectangle of the inline object.
get_line_objects
Section titled “get_line_objects”Array get_line_objects(line: int) const
Returns array of inline objects in the line.
get_line_range
Section titled “get_line_range”Vector2i get_line_range(line: int) const
Returns character range of the line.
get_line_rid
Section titled “get_line_rid”RID get_line_rid(line: int) const
Returns TextShaping line buffer RID.
get_line_size
Section titled “get_line_size”Vector2 get_line_size(line: int) const
Returns size of the bounding box of the line of text. Returned size is rounded up.
get_line_underline_position
Section titled “get_line_underline_position”float get_line_underline_position(line: int) const
Returns pixel offset of the underline below the baseline.
get_line_underline_thickness
Section titled “get_line_underline_thickness”float get_line_underline_thickness(line: int) const
Returns thickness of the underline.
get_line_width
Section titled “get_line_width”float get_line_width(line: int) const
Returns width (for horizontal layout) or height (for vertical) of the line of text.
get_non_wrapped_size
Section titled “get_non_wrapped_size”Vector2 get_non_wrapped_size() const
Returns the size of the bounding box of the paragraph, without line breaks.
get_range
Section titled “get_range”Vector2i get_range() const
Returns the character range of the paragraph.
get_rid
Section titled “get_rid”RID get_rid() const
Returns TextShaping full string buffer RID.
get_size
Section titled “get_size”Vector2 get_size() const
Returns the size of the bounding box of the paragraph.
has_object
Section titled “has_object”bool has_object(key: Variant) const
Returns true if an object with key is embedded in this shaped text buffer.
hit_test
Section titled “hit_test”int hit_test(coords: Vector2) const
Returns caret character offset at the specified coordinates. This function always returns a valid position.
resize_object
Section titled “resize_object”bool resize_object(key: Variant, size: Vector2, inline_align: InlineAlignment = 5, baseline: float = 0.0)
Sets new size and alignment of embedded object.
set_bidi_override
Section titled “set_bidi_override”void set_bidi_override(override: Array)
Overrides BiDi for the structured text.
Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately.
set_dropcap
Section titled “set_dropcap”bool set_dropcap(text: String, font: Font, font_size: int, dropcap_margins: Rect2 = Rect2(0, 0, 0, 0), language: String = "")
Sets drop cap, overrides previously set drop cap. Drop cap (dropped capital) is a decorative element at the beginning of a paragraph that is larger than the rest of the text.
tab_align
Section titled “tab_align”void tab_align(tab_stops: []f32)
Aligns paragraph to the given tab-stops.