TextParagraph¶
Inherits: RefCounted < Object
Holds a paragraph of text.
Description¶
Abstraction over TextServer for handling paragraph of text.
Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods¶
add_object ( Variant key, Vector2 size, InlineAlignment inline_align=5, int length=1 ) |
|
add_string ( String text, Font fonts, int size, Dictionary opentype_features={}, String language="", Variant meta=null ) |
|
void |
clear ( ) |
void |
clear_dropcap ( ) |
void |
draw ( RID canvas, Vector2 pos, Color color=Color(1, 1, 1, 1), Color dc_color=Color(1, 1, 1, 1) ) const |
void |
draw_dropcap ( RID canvas, Vector2 pos, Color color=Color(1, 1, 1, 1) ) const |
void |
draw_dropcap_outline ( RID canvas, Vector2 pos, int outline_size=1, Color color=Color(1, 1, 1, 1) ) const |
void |
draw_line ( RID canvas, Vector2 pos, int line, Color color=Color(1, 1, 1, 1) ) const |
void |
draw_line_outline ( RID canvas, Vector2 pos, int line, int outline_size=1, Color color=Color(1, 1, 1, 1) ) const |
void |
draw_outline ( RID canvas, Vector2 pos, int outline_size=1, Color color=Color(1, 1, 1, 1), Color dc_color=Color(1, 1, 1, 1) ) const |
get_dropcap_lines ( ) const |
|
get_dropcap_rid ( ) const |
|
get_dropcap_size ( ) const |
|
get_line_ascent ( int line ) const |
|
get_line_count ( ) const |
|
get_line_descent ( int line ) const |
|
get_line_object_rect ( int line, Variant key ) const |
|
get_line_objects ( int line ) const |
|
get_line_range ( int line ) const |
|
get_line_rid ( int line ) const |
|
get_line_size ( int line ) const |
|
get_line_underline_position ( int line ) const |
|
get_line_underline_thickness ( int line ) const |
|
get_line_width ( int line ) const |
|
get_non_wrapped_size ( ) const |
|
get_rid ( ) const |
|
get_size ( ) const |
|
get_spacing_bottom ( ) const |
|
get_spacing_top ( ) const |
|
resize_object ( Variant key, Vector2 size, InlineAlignment inline_align=5 ) |
|
void |
set_bidi_override ( Array override ) |
set_dropcap ( String text, Font fonts, int size, Rect2 dropcap_margins=Rect2(0, 0, 0, 0), Dictionary opentype_features={}, String language="" ) |
|
void |
tab_align ( PackedFloat32Array tab_stops ) |
Enumerations¶
enum OverrunBehavior:
OVERRUN_NO_TRIMMING = 0 --- No text trimming is performed.
OVERRUN_TRIM_CHAR = 1 --- Trims the text per character.
OVERRUN_TRIM_WORD = 2 --- Trims the text per word.
OVERRUN_TRIM_ELLIPSIS = 3 --- Trims the text per character and adds an ellipsis to indicate that parts are hidden.
OVERRUN_TRIM_WORD_ELLIPSIS = 4 --- Trims the text per word and adds an ellipsis to indicate that parts are hidden.
Property Descriptions¶
HorizontalAlignment alignment
Default |
|
Setter |
set_alignment(value) |
Getter |
get_alignment() |
Paragraph horizontal alignment.
String custom_punctuation
Default |
|
Setter |
set_custom_punctuation(value) |
Getter |
get_custom_punctuation() |
Custom punctuation character list, used for word breaking. If set to empty string, server defaults are used.
Direction direction
Default |
|
Setter |
set_direction(value) |
Getter |
get_direction() |
Text writing direction.
int flags
Default |
|
Setter |
set_flags(value) |
Getter |
get_flags() |
Line breaking and alignment rules. For more info see TextServer.
int max_lines_visible
Default |
|
Setter |
set_max_lines_visible(value) |
Getter |
get_max_lines_visible() |
Limits the lines of text shown.
Orientation orientation
Default |
|
Setter |
set_orientation(value) |
Getter |
get_orientation() |
Text orientation.
bool preserve_control
Default |
|
Setter |
set_preserve_control(value) |
Getter |
get_preserve_control() |
If set to true
text will display control characters.
bool preserve_invalid
Default |
|
Setter |
set_preserve_invalid(value) |
Getter |
get_preserve_invalid() |
If set to true
text will display invalid characters.
OverrunBehavior text_overrun_behavior
Default |
|
Setter |
set_text_overrun_behavior(value) |
Getter |
get_text_overrun_behavior() |
Sets the clipping behavior when the text exceeds the paragraph's set width. See OverrunBehavior for a description of all modes.
float width
Default |
|
Setter |
set_width(value) |
Getter |
get_width() |
Paragraph width.
Method Descriptions¶
bool add_object ( Variant key, Vector2 size, InlineAlignment inline_align=5, int length=1 )
Adds inline object to the text buffer, key
must be unique. In the text, object is represented as length
object replacement characters.
bool add_string ( String text, Font fonts, int size, Dictionary opentype_features={}, String language="", Variant meta=null )
Adds text span and font to draw it.
void clear ( )
Clears text paragraph (removes text and inline objects).
void clear_dropcap ( )
Removes dropcap.
void draw ( RID canvas, Vector2 pos, Color color=Color(1, 1, 1, 1), Color dc_color=Color(1, 1, 1, 1) ) 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.
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_outline ( RID canvas, Vector2 pos, int outline_size=1, Color color=Color(1, 1, 1, 1) ) 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.
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_outline ( RID canvas, Vector2 pos, int line, int outline_size=1, Color color=Color(1, 1, 1, 1) ) 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_outline ( RID canvas, Vector2 pos, int outline_size=1, Color color=Color(1, 1, 1, 1), Color dc_color=Color(1, 1, 1, 1) ) 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.
int get_dropcap_lines ( ) const
Returns number of lines used by dropcap.
RID get_dropcap_rid ( ) const
Returns drop cap text buffer RID.
Vector2 get_dropcap_size ( ) const
Returns drop cap bounding box size.
Returns the text line ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
int get_line_count ( ) const
Returns number of lines in the paragraph.
Returns the text line descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
Returns bounding rectangle of the inline object.
Returns array of inline objects in the line.
Returns character range of the line.
Returns TextServer line buffer RID.
Returns size of the bounding box of the line of text.
Returns pixel offset of the underline below the baseline.
Returns thickness of the underline.
Returns width (for horizontal layout) or height (for vertical) of the line of text.
Vector2 get_non_wrapped_size ( ) const
Returns the size of the bounding box of the paragraph, without line breaks.
RID get_rid ( ) const
Returns TextServer full string buffer RID.
Vector2 get_size ( ) const
Returns the size of the bounding box of the paragraph.
int get_spacing_bottom ( ) const
Returns extra spacing at the bottom of the line. See Font.spacing_bottom.
int get_spacing_top ( ) const
Returns extra spacing at the top of the line. See Font.spacing_top.
Returns caret character offset at the specified coordinates. This function always returns a valid position.
bool resize_object ( Variant key, Vector2 size, InlineAlignment inline_align=5 )
Sets new size and alignment of embedded object.
void set_bidi_override ( Array override )
Overrides BiDi for the structured text.
Override ranges should cover full source text without overlaps. BiDi algorithm will be used on each range separately.
bool set_dropcap ( String text, Font fonts, int size, Rect2 dropcap_margins=Rect2(0, 0, 0, 0), Dictionary opentype_features={}, String language="" )
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.
void tab_align ( PackedFloat32Array tab_stops )
Aligns paragraph to the given tab-stops.