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...
TextParagraph
繼承: RefCounted < Object
持有一個文字段落。
說明
對 TextServer 的抽象,用於處理單個文字段落。
屬性
|
||
BitField[LineBreakFlag] |
|
|
|
||
|
||
|
||
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 |
|
void |
draw(canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), dc_color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const |
void |
draw_dropcap(canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const |
void |
draw_dropcap_outline(canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const |
void |
draw_line(canvas: RID, pos: Vector2, line: int, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const |
void |
draw_line_outline(canvas: RID, pos: Vector2, line: int, outline_size: int = 1, 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), dc_color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const |
duplicate() const |
|
get_dropcap_lines() const |
|
get_dropcap_rid() const |
|
get_dropcap_size() const |
|
get_inferred_direction() const |
|
get_line_ascent(line: int) const |
|
get_line_count() const |
|
get_line_descent(line: int) const |
|
get_line_object_rect(line: int, key: Variant) const |
|
get_line_objects(line: int) const |
|
get_line_range(line: int) const |
|
get_line_rid(line: int) const |
|
get_line_size(line: int) const |
|
get_line_underline_position(line: int) const |
|
get_line_underline_thickness(line: int) const |
|
get_line_width(line: int) const |
|
get_non_wrapped_size() const |
|
get_range() 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) |
set_dropcap(text: String, font: Font, font_size: int, dropcap_margins: Rect2 = Rect2(0, 0, 0, 0), language: String = "") |
|
void |
tab_align(tab_stops: PackedFloat32Array) |
屬性說明
HorizontalAlignment alignment = 0 🔗
void set_alignment(value: HorizontalAlignment)
HorizontalAlignment get_alignment()
段落的水平對齊。
BitField[LineBreakFlag] break_flags = 3 🔗
void set_break_flags(value: BitField[LineBreakFlag])
BitField[LineBreakFlag] get_break_flags()
斷行規則。詳情見 TextServer。
String custom_punctuation = "" 🔗
自訂標點字元列表,用於分詞。如果設定為空字串,則使用伺服器的預設值。
文字書寫方向。
Ellipsis character used for text clipping.
BitField[JustificationFlag] justification_flags = 163 🔗
void set_justification_flags(value: BitField[JustificationFlag])
BitField[JustificationFlag] get_justification_flags()
Line fill alignment rules.
Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.
限制顯示文字的行數。
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 = 0 🔗
void set_text_overrun_behavior(value: OverrunBehavior)
OverrunBehavior get_text_overrun_behavior()
The clipping behavior when the text exceeds the paragraph'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 clear_dropcap() 🔗
移除首字下沉。
void draw(canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), dc_color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) 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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
void draw_dropcap(canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const 🔗
Draw drop cap 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_dropcap_outline(canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) 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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
void draw_line(canvas: RID, pos: Vector2, line: int, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) const 🔗
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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
void draw_line_outline(canvas: RID, pos: Vector2, line: int, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) 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. 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), dc_color: Color = Color(1, 1, 1, 1), oversampling: float = 0.0) 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. If oversampling is greater than zero, it is used as font oversampling factor, otherwise viewport oversampling settings are used.
TextParagraph duplicate() const 🔗
Duplicates this TextParagraph.
int get_dropcap_lines() const 🔗
返回首字下沉使用的行數。
返回首字下沉文字緩衝 RID。
Vector2 get_dropcap_size() const 🔗
返回首字下沉邊界框大小。
Direction get_inferred_direction() const 🔗
Returns the text writing direction inferred by the BiDi algorithm.
float get_line_ascent(line: int) const 🔗
返回文字行上高(對於水平佈局,為基線上方的圖元數;或對於垂直佈局,基線左側的圖元數)。
返回段落中的行數。
float get_line_descent(line: int) const 🔗
返回文字行下深(對於水平佈局,為基線下方的圖元數;或對於垂直佈局,基線右側的圖元數)。
Rect2 get_line_object_rect(line: int, key: Variant) const 🔗
返回行內對象的邊界矩形。
Array get_line_objects(line: int) const 🔗
返回某行中行內物件的陣列。
Vector2i get_line_range(line: int) const 🔗
返回某行中的字元範圍。
RID get_line_rid(line: int) const 🔗
返回 TextServer 行緩衝 RID。
Vector2 get_line_size(line: int) const 🔗
Returns size of the bounding box of the line of text. Returned size is rounded up.
float get_line_underline_position(line: int) const 🔗
返回基線下方底線的圖元偏移。
float get_line_underline_thickness(line: int) const 🔗
返回底線的粗細度。
float get_line_width(line: int) const 🔗
返回文字行的寬度(水平排版)或高度(垂直排版)。
Vector2 get_non_wrapped_size() const 🔗
返回段落邊界框的大小,不帶分行符號。
Returns the character range of the paragraph.
返回 TextServer 完整字串緩衝區的 RID。
返回段落邊界框的大小。
bool has_object(key: Variant) const 🔗
Returns true if an object with key is embedded in this shaped text buffer.
int hit_test(coords: Vector2) const 🔗
返回指定座標處的文字游標的偏移量。該函式始終返回一個有效位置。
bool resize_object(key: Variant, size: Vector2, inline_align: InlineAlignment = 5, baseline: float = 0.0) 🔗
設定內嵌物件的新大小和對齊方式。
void set_bidi_override(override: Array) 🔗
覆蓋用於結構化文字的 BiDi。
覆蓋範圍應覆蓋完整的源文字而沒有重疊。BiDi 演算法將分別被用於每個範圍。
bool set_dropcap(text: String, font: Font, font_size: int, dropcap_margins: Rect2 = Rect2(0, 0, 0, 0), language: String = "") 🔗
設定首字下沉,會覆蓋之前設定的首字下沉。首字下沉是段落開頭的裝飾元素,比文字的其餘部分大。
void tab_align(tab_stops: PackedFloat32Array) 🔗
將段落與給定的定位停駐點對齊。