TextLine¶
Inherits: RefCounted < Object
Holds a line of text.
Description¶
Abstraction over TextServer for handling single line 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 |
draw ( RID canvas, Vector2 pos, 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) ) const |
get_line_ascent ( ) const |
|
get_line_descent ( ) const |
|
get_line_underline_position ( ) const |
|
get_line_underline_thickness ( ) const |
|
get_line_width ( ) const |
|
get_object_rect ( Variant key ) const |
|
get_objects ( ) const |
|
get_rid ( ) const |
|
get_size ( ) const |
|
resize_object ( Variant key, Vector2 size, InlineAlignment inline_align=5 ) |
|
void |
set_bidi_override ( Array override ) |
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_horizontal_alignment(value) |
Getter |
get_horizontal_alignment() |
Direction direction
Default |
|
Setter |
set_direction(value) |
Getter |
get_direction() |
Text writing direction.
int flags
Default |
|
Setter |
set_flags(value) |
Getter |
get_flags() |
Line Alignment rules. For more info see TextServer.
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 text line's set width. See OverrunBehavior for a description of all modes.
float width
Default |
|
Setter |
set_width(value) |
Getter |
get_width() |
Text line 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 line (removes text and inline objects).
Draw 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) ) const
Draw text into a canvas item at a given position, with color
. pos
specifies the top left corner of the bounding box.
float get_line_ascent ( ) const
Returns the text ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).
float get_line_descent ( ) const
Returns the text descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).
float get_line_underline_position ( ) const
Returns pixel offset of the underline below the baseline.
float get_line_underline_thickness ( ) const
Returns thickness of the underline.
float get_line_width ( ) const
Returns width (for horizontal layout) or height (for vertical) of the text.
Returns bounding rectangle of the inline object.
Array get_objects ( ) const
Returns array of inline objects.
RID get_rid ( ) const
Returns TextServer buffer RID.
Vector2 get_size ( ) const
Returns size of the bounding box of the text.
Returns caret character offset at the specified pixel offset at the baseline. 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.
void tab_align ( PackedFloat32Array tab_stops )
Aligns text to the given tab-stops.