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 ( 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 |
clear_dropcap ( ) |
void |
draw ( RID canvas, Vector2 pos, Color color=Color(1, 1, 1, 1), Color dc_color=Color(1, 1, 1, 1) ) const |
void |
draw_dropcap ( RID canvas, Vector2 pos, Color color=Color(1, 1, 1, 1) ) const |
void |
draw_dropcap_outline ( RID canvas, Vector2 pos, int outline_size=1, Color color=Color(1, 1, 1, 1) ) const |
void |
draw_line ( RID canvas, Vector2 pos, int line, Color color=Color(1, 1, 1, 1) ) const |
void |
draw_line_outline ( RID canvas, Vector2 pos, int line, int outline_size=1, 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), Color dc_color=Color(1, 1, 1, 1) ) const |
get_dropcap_lines ( ) const |
|
get_dropcap_rid ( ) const |
|
get_dropcap_size ( ) const |
|
get_line_ascent ( int line ) const |
|
get_line_count ( ) const |
|
get_line_descent ( int line ) const |
|
get_line_object_rect ( int line, Variant key ) const |
|
get_line_objects ( int line ) const |
|
get_line_range ( int line ) const |
|
get_line_rid ( int line ) const |
|
get_line_size ( int line ) const |
|
get_line_underline_position ( int line ) const |
|
get_line_underline_thickness ( int line ) const |
|
get_line_width ( int line ) const |
|
get_non_wrapped_size ( ) 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 ) |
set_dropcap ( String text, Font font, int font_size, Rect2 dropcap_margins=Rect2(0, 0, 0, 0), String language="" ) |
|
void |
tab_align ( PackedFloat32Array tab_stops ) |
属性说明¶
HorizontalAlignment alignment = 0
void set_alignment ( HorizontalAlignment value )
HorizontalAlignment get_alignment ( )
段落的水平对齐。
BitField<LineBreakFlag> break_flags = 3
void set_break_flags ( BitField<LineBreakFlag> value )
BitField<LineBreakFlag> get_break_flags ( )
断行规则。详情见 TextServer。
String custom_punctuation = ""
自定义标点字符列表,用于分词。如果设置为空字符串,则使用服务器的默认值。
Direction direction = 0
文本书写方向。
BitField<JustificationFlag> justification_flags = 163
void set_justification_flags ( BitField<JustificationFlag> value )
BitField<JustificationFlag> get_justification_flags ( )
行两端对齐规则。详见 JustificationFlag。
int max_lines_visible = -1
限制显示文本的行数。
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 = 0
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 clear_dropcap ( )
移除首字下沉。
void draw ( RID canvas, Vector2 pos, Color color=Color(1, 1, 1, 1), Color dc_color=Color(1, 1, 1, 1) ) const
在画布项中的给定位置绘制文本中所有行和首字下沉,颜色为 color
。pos
指定的是边界框的左上角。
void draw_dropcap ( RID canvas, Vector2 pos, Color color=Color(1, 1, 1, 1) ) const
在画布项中的给定位置绘制首字下沉,颜色为 color
。pos
指定的是边界框的左上角。
void draw_dropcap_outline ( RID canvas, Vector2 pos, int outline_size=1, Color color=Color(1, 1, 1, 1) ) const
在画布项中的给定位置绘制首字下沉的轮廓,颜色为 color
。pos
指定的是边界框的左上角。
void draw_line ( RID canvas, Vector2 pos, int line, Color color=Color(1, 1, 1, 1) ) const
在画布项中的给定位置绘制一行文本,颜色为 color
。pos
指定的是边界框的左上角。
void draw_line_outline ( RID canvas, Vector2 pos, int line, int outline_size=1, 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), Color dc_color=Color(1, 1, 1, 1) ) const
在画布项中的给定位置绘制文本中所有行和首字下沉的轮廓,颜色为 color
。pos
指定的是边界框的左上角。
int get_dropcap_lines ( ) const
返回首字下沉使用的行数。
RID get_dropcap_rid ( ) const
返回首字下沉文本缓冲 RID。
Vector2 get_dropcap_size ( ) const
返回首字下沉边界框大小。
float get_line_ascent ( int line ) const
返回文本行上高(对于水平布局,为基线上方的像素数;或对于垂直布局,基线左侧的像素数)。
int get_line_count ( ) const
返回段落中的行数。
float get_line_descent ( int line ) const
返回文本行下深(对于水平布局,为基线下方的像素数;或对于垂直布局,基线右侧的像素数)。
Rect2 get_line_object_rect ( int line, Variant key ) const
返回内联对象的边界矩形。
Array get_line_objects ( int line ) const
返回某行中内联对象的数组。
Vector2i get_line_range ( int line ) const
返回某行中的字符范围。
RID get_line_rid ( int line ) const
返回 TextServer 行缓冲 RID。
Vector2 get_line_size ( int line ) const
返回文本行边界框的大小。
float get_line_underline_position ( int line ) const
返回基线下方下划线的像素偏移。
float get_line_underline_thickness ( int line ) const
返回下划线的粗细度。
float get_line_width ( int line ) const
返回文本行的宽度(水平排版)或高度(垂直排版)。
Vector2 get_non_wrapped_size ( ) const
返回段落边界框的大小,不带换行符。
RID get_rid ( ) const
返回 TextServer 完整字符串缓冲区的 RID。
Vector2 get_size ( ) const
返回段落边界框的大小。
int hit_test ( Vector2 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 算法将分别被用于每个范围。
bool set_dropcap ( String text, Font font, int font_size, Rect2 dropcap_margins=Rect2(0, 0, 0, 0), String language="" )
设置首字下沉,会覆盖之前设置的首字下沉。首字下沉是段落开头的装饰元素,比文本的其余部分大。
void tab_align ( PackedFloat32Array tab_stops )
将段落与给定的制表位对齐。