TextLine
继承: RefCounted
< Object
Holds a line of text.
描述
Abstraction over TextServer
for handling a single line of text.
属性
方法
bool | add_object ( key: Variant , size: Vector2 , inline_align: InlineAlignment = 5, length: int = 1, baseline: float = 0.0 ) |
bool | add_string ( text: String , font: Font , font_size: int , language: String = "", meta: Variant = null ) |
void | clear ( ) |
void | draw ( canvas: RID , pos: Vector2 , color: Color = Color(1, 1, 1, 1) ) const1 |
void | draw_outline ( canvas: RID , pos: Vector2 , outline_size: int = 1, color: Color = Color(1, 1, 1, 1) ) const1 |
float | get_line_ascent ( ) const1 |
float | get_line_descent ( ) const1 |
float | get_line_underline_position ( ) const1 |
float | get_line_underline_thickness ( ) const1 |
float | get_line_width ( ) const1 |
Rect2 | get_object_rect ( key: Variant ) const1 |
Array | get_objects ( ) const1 |
RID | get_rid ( ) const1 |
Vector2 | get_size ( ) const1 |
int | hit_test ( coords: float ) const1 |
bool | resize_object ( key: Variant , size: Vector2 , inline_align: InlineAlignment = 5, baseline: float = 0.0 ) |
void | set_bidi_override ( override: Array ) |
void | tab_align ( tab_stops: PackedFloat32Array ) |
属性说明
HorizontalAlignment alignment = 0
void
set_horizontal_alignment ( value: HorizontalAlignment )- HorizontalAlignment get_horizontal_alignment ( )
Sets text alignment within the line as if the line was horizontal.
Direction direction = 0
Text writing direction.
String
ellipsis_char = "…"
Ellipsis character used for text clipping.
JustificationFlag flags = 3
void
set_flags ( value: JustificationFlag )- JustificationFlag get_flags ( )
Line alignment rules. For more info see TextServer
.
Orientation orientation = 0
void
set_orientation ( value: Orientation )- Orientation get_orientation ( )
Text orientation.
bool
preserve_control = false
If set to true
text will display control characters.
bool
preserve_invalid = true
If set to true
text will display invalid characters.
OverrunBehavior text_overrun_behavior = 3
void
set_text_overrun_behavior ( value: OverrunBehavior )- OverrunBehavior 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 = -1.0
Text line width.
方法说明
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.
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 line (removes text and inline objects).
void
draw ( canvas: RID
, pos: Vector2
, color: Color
= Color(1, 1, 1, 1) ) const1
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 ( canvas: RID
, pos: Vector2
, outline_size: int
= 1, color: Color
= Color(1, 1, 1, 1) ) const1
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 ( ) const1
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 ( ) const1
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 ( ) const1
Returns pixel offset of the underline below the baseline.
float
get_line_underline_thickness ( ) const1
Returns thickness of the underline.
float
get_line_width ( ) const1
Returns width (for horizontal layout) or height (for vertical) of the text.
Rect2
get_object_rect ( key: Variant
) const1
Returns bounding rectangle of the inline object.
Returns array of inline objects.
Returns TextServer buffer RID.
Returns size of the bounding box of the text.
int
hit_test ( coords: float
) const1
Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position.
bool
resize_object ( key: Variant
, size: Vector2
, inline_align: InlineAlignment = 5, baseline: float
= 0.0 )
Sets new size and alignment of embedded object.
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.
void
tab_align ( tab_stops: PackedFloat32Array
)
Aligns text to the given tab-stops.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。