Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
TextLine¶
继承: RefCounted < Object
存放一行文本。
描述¶
基于 TextServer 的抽象,用于处理单行文本。
属性¶
|
||
|
||
BitField<JustificationFlag> |
|
|
|
||
|
||
|
||
|
||
|
方法¶
add_object ( Variant key, Vector2 size, InlineAlignment inline_align=5, int length=1, float baseline=0.0 ) |
|
add_string ( String text, Font font, int font_size, 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, float baseline=0.0 ) |
|
void |
set_bidi_override ( Array override ) |
void |
tab_align ( PackedFloat32Array tab_stops ) |
属性说明¶
HorizontalAlignment alignment = 0
void set_horizontal_alignment ( HorizontalAlignment value )
HorizontalAlignment get_horizontal_alignment ( )
设置行内的文本对齐方式,始终按照该行为横向的情况设置。
Direction direction = 0
文本书写方向。
BitField<JustificationFlag> flags = 3
void set_flags ( BitField<JustificationFlag> value )
BitField<JustificationFlag> get_flags ( )
行对齐规则。详细请参阅 TextServer。
Orientation orientation = 0
void set_orientation ( Orientation value )
Orientation get_orientation ( )
文本朝向。
bool preserve_control = false
如果设置为 true
,则将在文本中显示控制字符。
bool preserve_invalid = true
如果设置为 true
,则将在文本中显示无效字符。
OverrunBehavior text_overrun_behavior = 3
void set_text_overrun_behavior ( OverrunBehavior value )
OverrunBehavior get_text_overrun_behavior ( )
设置文本超出文本行的设置宽度时的裁剪行为。有关所有模式的描述,请参阅 OverrunBehavior。
float width = -1.0
文本行宽。
方法说明¶
bool add_object ( Variant key, Vector2 size, InlineAlignment inline_align=5, int length=1, float baseline=0.0 )
向文本缓冲中添加内联对象,key
必须唯一。在文本中,对象使用 length
个对象替换字符表示。
bool add_string ( String text, Font font, int font_size, String language="", Variant meta=null )
添加文本区间以及用于绘制的字体。
void clear ( )
清除文本行(移除文本和内联对象)。
void draw ( RID canvas, Vector2 pos, Color color=Color(1, 1, 1, 1) ) const
在画布项中的给定位置绘制文本,颜色为 color
。pos
指定的是边界框的左上角。
void draw_outline ( RID canvas, Vector2 pos, int outline_size=1, Color color=Color(1, 1, 1, 1) ) const
在画布项中的给定位置绘制文本,颜色为 color
。pos
指定的是边界框的左上角。
float get_line_ascent ( ) const
返回该文本的升部(水平排版时为基线上方的像素数,垂直排版时为基线左侧的像素数)。
float get_line_descent ( ) const
返回该文本的降部(水平排版时为基线下方的像素数,垂直排版时为基线右侧的像素数)。
float get_line_underline_position ( ) const
返回基线下方下划线的像素偏移。
float get_line_underline_thickness ( ) const
返回下划线的粗细度。
float get_line_width ( ) const
返回文本的宽度(对于水平排版)或高度(对于垂直排版)。
Rect2 get_object_rect ( Variant key ) const
返回内联对象的边界矩形。
Array get_objects ( ) const
返回内联对象的数组。
RID get_rid ( ) const
返回 TextServer 缓冲区 RID。
Vector2 get_size ( ) const
返回文本边界框的大小。
int hit_test ( float coords ) const
返回基线处指定像素偏移处的文本光标的偏移量。该函数始终返回一个有效位置。
bool resize_object ( Variant key, Vector2 size, InlineAlignment inline_align=5, float baseline=0.0 )
设置嵌入对象的新大小和对齐方式。
void set_bidi_override ( Array override )
覆盖用于结构化文本的 BiDi。
覆盖范围应覆盖完整的源文本而没有重叠。BiDi 算法将分别被用于每个范围。
void tab_align ( PackedFloat32Array tab_stops )
将文本与给定的制表位对齐。