Class TextParagraph
Holds a paragraph of text.
- Inheritance
-
TextParagraph
Remarks
Abstraction over TextServer for handling a single paragraph of text.
Properties
alignment
Paragraph horizontal alignment.
var alignment : int = 0
Property Value
Remarks
break_flags
Line breaking rules. For more info see TextServer.
var break_flags : int = 3
Property Value
Remarks
custom_punctuation
Custom punctuation character list, used for word breaking. If set to empty string, server defaults are used.
var custom_punctuation : String = ""
Property Value
Remarks
direction
Text writing direction.
var direction : int = 0
Property Value
Remarks
ellipsis_char
Ellipsis character used for text clipping.
var ellipsis_char : String = "…"
Property Value
Remarks
justification_flags
Line fill alignment rules. See JustificationFlag for more information.
var justification_flags : int = 163
Property Value
Remarks
line_spacing
Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.
var line_spacing : float = 0.0
Property Value
Remarks
max_lines_visible
Limits the lines of text shown.
var max_lines_visible : int = -1
Property Value
Remarks
orientation
Text orientation.
var orientation : int = 0
Property Value
Remarks
preserve_control
If set to true
text will display control characters.
var preserve_control : bool = false
Property Value
Remarks
preserve_invalid
If set to true
text will display invalid characters.
var preserve_invalid : bool = true
Property Value
Remarks
text_overrun_behavior
Sets the clipping behavior when the text exceeds the paragraph's set width. See OverrunBehavior for a description of all modes.
var text_overrun_behavior : int = 0
Property Value
Remarks
width
Paragraph width.
var width : float = -1.0
Property Value
Remarks
Methods
add_object(Variant, Vector2, int, int, float)
Adds inline object to the text buffer, key
must be unique. In the text, object is represented as length
object replacement characters.
bool add_object(Variant key, Vector2 size, int inline_align, int length, float baseline)
Parameters
add_string(String, Font, int, String, Variant)
Adds text span and font to draw it.
bool add_string(String text, Font font, int font_size, String language, Variant meta)
Parameters
clear
Clears text paragraph (removes text and inline objects).
void clear
clear_dropcap
Removes dropcap.
void clear_dropcap
draw(RID, Vector2, Color, Color)
Qualifiers: 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.
void draw(RID canvas, Vector2 pos, Color color, Color dc_color)
Parameters
draw_dropcap(RID, Vector2, Color)
Qualifiers: const
Draw drop cap into a canvas item at a given position, with color
. pos
specifies the top left corner of the bounding box.
void draw_dropcap(RID canvas, Vector2 pos, Color color)
Parameters
draw_dropcap_outline(RID, Vector2, int, Color)
Qualifiers: 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.
void draw_dropcap_outline(RID canvas, Vector2 pos, int outline_size, Color color)
Parameters
draw_line(RID, Vector2, int, Color)
Qualifiers: 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.
void draw_line(RID canvas, Vector2 pos, int line, Color color)
Parameters
draw_line_outline(RID, Vector2, int, int, Color)
Qualifiers: 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.
void draw_line_outline(RID canvas, Vector2 pos, int line, int outline_size, Color color)
Parameters
draw_outline(RID, Vector2, int, Color, Color)
Qualifiers: 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.
void draw_outline(RID canvas, Vector2 pos, int outline_size, Color color, Color dc_color)
Parameters
get_dropcap_lines
Qualifiers: const
Returns number of lines used by dropcap.
int get_dropcap_lines
get_dropcap_rid
Qualifiers: const
Returns drop cap text buffer RID.
RID get_dropcap_rid
get_dropcap_size
Qualifiers: const
Returns drop cap bounding box size.
Vector2 get_dropcap_size
get_line_ascent(int)
Qualifiers: const
Returns the text line ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
float get_line_ascent(int line)
Parameters
line
int
get_line_count
Qualifiers: const
Returns number of lines in the paragraph.
int get_line_count
get_line_descent(int)
Qualifiers: const
Returns the text line descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
float get_line_descent(int line)
Parameters
line
int
get_line_object_rect(int, Variant)
Qualifiers: const
Returns bounding rectangle of the inline object.
Rect2 get_line_object_rect(int line, Variant key)
Parameters
get_line_objects(int)
Qualifiers: const
Returns array of inline objects in the line.
Array get_line_objects(int line)
Parameters
line
int
get_line_range(int)
Qualifiers: const
Returns character range of the line.
Vector2i get_line_range(int line)
Parameters
line
int
get_line_rid(int)
Qualifiers: const
Returns TextServer line buffer RID.
RID get_line_rid(int line)
Parameters
line
int
get_line_size(int)
Qualifiers: const
Returns size of the bounding box of the line of text. Returned size is rounded up.
Vector2 get_line_size(int line)
Parameters
line
int
get_line_underline_position(int)
Qualifiers: const
Returns pixel offset of the underline below the baseline.
float get_line_underline_position(int line)
Parameters
line
int
get_line_underline_thickness(int)
Qualifiers: const
Returns thickness of the underline.
float get_line_underline_thickness(int line)
Parameters
line
int
get_line_width(int)
Qualifiers: const
Returns width (for horizontal layout) or height (for vertical) of the line of text.
float get_line_width(int line)
Parameters
line
int
get_non_wrapped_size
Qualifiers: const
Returns the size of the bounding box of the paragraph, without line breaks.
Vector2 get_non_wrapped_size
get_rid
Qualifiers: const
Returns TextServer full string buffer RID.
RID get_rid
get_size
Qualifiers: const
Returns the size of the bounding box of the paragraph.
Vector2 get_size
hit_test(Vector2)
Qualifiers: const
Returns caret character offset at the specified coordinates. This function always returns a valid position.
int hit_test(Vector2 coords)
Parameters
coords
Vector2
resize_object(Variant, Vector2, int, float)
Sets new size and alignment of embedded object.
bool resize_object(Variant key, Vector2 size, int inline_align, float baseline)
Parameters
set_bidi_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.
void set_bidi_override(Array override)
Parameters
override
Array
set_dropcap(String, Font, int, Rect2, 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.
bool set_dropcap(String text, Font font, int font_size, Rect2 dropcap_margins, String language)
Parameters
tab_align(PackedFloat32Array)
Aligns paragraph to the given tab-stops.
void tab_align(PackedFloat32Array tab_stops)
Parameters
tab_stops
PackedFloat32Array