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(key: Variant, size: Vector2, inline_align: InlineAlignment = 5, length: int = 1, baseline: float = 0.0) |
|
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), oversampling: float = 0.0) const |
void |
draw_outline(canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const |
duplicate() const |
|
get_inferred_direction() 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(key: Variant) const |
|
get_objects() const |
|
get_rid() const |
|
get_size() const |
|
has_object(key: Variant) const |
|
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()
設定行內的文字對齊方式,始終按照該行為橫向的情況設定。
文字書寫方向。
Ellipsis character used for text clipping.
BitField[JustificationFlag] flags = 3 🔗
void set_flags(value: BitField[JustificationFlag])
BitField[JustificationFlag] get_flags()
行對齊規則。詳細請參閱 TextServer。
Orientation orientation = 0 🔗
void set_orientation(value: Orientation)
Orientation get_orientation()
文字朝向。
bool preserve_control = false 🔗
如果設定為 true,則將在文字中顯示控制字元。
bool preserve_invalid = true 🔗
如果設定為 true,則將在文字中顯示無效字元。
OverrunBehavior text_overrun_behavior = 3 🔗
void set_text_overrun_behavior(value: OverrunBehavior)
OverrunBehavior get_text_overrun_behavior()
The clipping behavior when the text exceeds the text line's set width.
文字行寬。
方法說明
bool add_object(key: Variant, size: Vector2, inline_align: InlineAlignment = 5, length: int = 1, baseline: float = 0.0) 🔗
向文字緩衝中新增行內物件,key 必須唯一。在文字中,物件使用 length 個物件替換字元表示。
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), oversampling: float = 0.0) const 🔗
Draw text into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
void draw_outline(canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const 🔗
Draw text into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
Duplicates this TextLine.
Direction get_inferred_direction() const 🔗
Returns the text writing direction inferred by the BiDi algorithm.
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(key: Variant) const 🔗
返回行內對象的邊界矩形。
返回行內物件的陣列。
返回 TextServer 緩衝區 RID。
返回文字邊界框的大小。
bool has_object(key: Variant) const 🔗
Returns true if an object with key is embedded in this line.
int hit_test(coords: float) const 🔗
返回基線處指定圖元偏移處的文字游標的偏移量。該函式始終返回一個有效位置。
bool resize_object(key: Variant, size: Vector2, inline_align: InlineAlignment = 5, baseline: float = 0.0) 🔗
設定內嵌物件的新大小和對齊方式。
void set_bidi_override(override: Array) 🔗
覆蓋用於結構化文字的 BiDi。
覆蓋範圍應覆蓋完整的源文字而沒有重疊。BiDi 演算法將分別被用於每個範圍。
void tab_align(tab_stops: PackedFloat32Array) 🔗
將文字與給定的定位停駐點對齊。