TextParagraph

继承: RefCounted < Object

Holds a paragraph of text.

描述

Abstraction over TextServer for handling a single paragraph of text.

属性

方法

booladd_object ( key: Variant, size: Vector2, inline_align: InlineAlignment = 5, length: int = 1, baseline: float = 0.0 )
booladd_string ( text: String, font: Font, font_size: int, language: String = "", meta: Variant = null )
voidclear ( )
voidclear_dropcap ( )
voiddraw ( canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), dc_color: Color = Color(1, 1, 1, 1) ) const1
voiddraw_dropcap ( canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1) ) const1
voiddraw_dropcap_outline ( canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1) ) const1
voiddraw_line ( canvas: RID, pos: Vector2, line: int, color: Color = Color(1, 1, 1, 1) ) const1
voiddraw_line_outline ( canvas: RID, pos: Vector2, line: int, outline_size: int = 1, color: Color = Color(1, 1, 1, 1) ) const1
voiddraw_outline ( canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1), dc_color: Color = Color(1, 1, 1, 1) ) const1
intget_dropcap_lines ( ) const1
RIDget_dropcap_rid ( ) const1
Vector2get_dropcap_size ( ) const1
floatget_line_ascent ( line: int ) const1
intget_line_count ( ) const1
floatget_line_descent ( line: int ) const1
Rect2get_line_object_rect ( line: int, key: Variant ) const1
Arrayget_line_objects ( line: int ) const1
Vector2iget_line_range ( line: int ) const1
RIDget_line_rid ( line: int ) const1
Vector2get_line_size ( line: int ) const1
floatget_line_underline_position ( line: int ) const1
floatget_line_underline_thickness ( line: int ) const1
floatget_line_width ( line: int ) const1
Vector2get_non_wrapped_size ( ) const1
RIDget_rid ( ) const1
Vector2get_size ( ) const1
inthit_test ( coords: Vector2 ) const1
boolresize_object ( key: Variant, size: Vector2, inline_align: InlineAlignment = 5, baseline: float = 0.0 )
voidset_bidi_override ( override: Array )
boolset_dropcap ( text: String, font: Font, font_size: int, dropcap_margins: Rect2 = Rect2(0, 0, 0, 0), language: String = "" )
voidtab_align ( tab_stops: PackedFloat32Array )

属性说明

HorizontalAlignment alignment = 0

Paragraph horizontal alignment.


LineBreakFlag break_flags = 3

Line breaking rules. For more info see TextServer.


String custom_punctuation = ""

  • void set_custom_punctuation ( value: String )
  • String get_custom_punctuation ( )

Custom punctuation character list, used for word breaking. If set to empty string, server defaults are used.


Direction direction = 0

Text writing direction.


String ellipsis_char = "…"

  • void set_ellipsis_char ( value: String )
  • String get_ellipsis_char ( )

Ellipsis character used for text clipping.


JustificationFlag justification_flags = 163

Line fill alignment rules. See JustificationFlag for more information.


int max_lines_visible = -1

  • void set_max_lines_visible ( value: int )
  • int get_max_lines_visible ( )

Limits the lines of text shown.


Orientation orientation = 0

Text orientation.


bool preserve_control = false

  • void set_preserve_control ( value: bool )
  • bool get_preserve_control ( )

If set to true text will display control characters.


bool preserve_invalid = true

  • void set_preserve_invalid ( value: bool )
  • bool get_preserve_invalid ( )

If set to true text will display invalid characters.


OverrunBehavior text_overrun_behavior = 0

Sets the clipping behavior when the text exceeds the paragraph's set width. See OverrunBehavior for a description of all modes.


float width = -1.0

  • void set_width ( value: float )
  • float get_width ( )

Paragraph 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 paragraph (removes text and inline objects).


void clear_dropcap ( )

Removes dropcap.


void draw ( canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1), dc_color: Color = Color(1, 1, 1, 1) ) const1

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.


void draw_dropcap ( canvas: RID, pos: Vector2, color: Color = Color(1, 1, 1, 1) ) const1

Draw drop cap into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box.


void draw_dropcap_outline ( canvas: RID, pos: Vector2, outline_size: int = 1, color: Color = Color(1, 1, 1, 1) ) const1

Draw drop cap outline into a canvas item at a given position, with color. pos specifies the top left corner of the bounding box.


void draw_line ( canvas: RID, pos: Vector2, line: int, color: Color = Color(1, 1, 1, 1) ) const1

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.


void draw_line_outline ( canvas: RID, pos: Vector2, line: int, outline_size: int = 1, color: Color = Color(1, 1, 1, 1) ) const1

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.


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) ) const1

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.


int get_dropcap_lines ( ) const1

Returns number of lines used by dropcap.


RID get_dropcap_rid ( ) const1

Returns drop cap text buffer RID.


Vector2 get_dropcap_size ( ) const1

Returns drop cap bounding box size.


float get_line_ascent ( line: int ) const1

Returns the text line ascent (number of pixels above the baseline for horizontal layout or to the left of baseline for vertical).


int get_line_count ( ) const1

Returns number of lines in the paragraph.


float get_line_descent ( line: int ) const1

Returns the text line descent (number of pixels below the baseline for horizontal layout or to the right of baseline for vertical).


Rect2 get_line_object_rect ( line: int, key: Variant ) const1

Returns bounding rectangle of the inline object.


Array get_line_objects ( line: int ) const1

Returns array of inline objects in the line.


Vector2i get_line_range ( line: int ) const1

Returns character range of the line.


RID get_line_rid ( line: int ) const1

Returns TextServer line buffer RID.


Vector2 get_line_size ( line: int ) const1

Returns size of the bounding box of the line of text. Returned size is rounded up.


float get_line_underline_position ( line: int ) const1

Returns pixel offset of the underline below the baseline.


float get_line_underline_thickness ( line: int ) const1

Returns thickness of the underline.


float get_line_width ( line: int ) const1

Returns width (for horizontal layout) or height (for vertical) of the line of text.


Vector2 get_non_wrapped_size ( ) const1

Returns the size of the bounding box of the paragraph, without line breaks.


RID get_rid ( ) const1

Returns TextServer full string buffer RID.


Vector2 get_size ( ) const1

Returns the size of the bounding box of the paragraph.


int hit_test ( coords: Vector2 ) const1

Returns caret character offset at the specified coordinates. 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.


bool set_dropcap ( text: String, font: Font, font_size: int, dropcap_margins: Rect2 = Rect2(0, 0, 0, 0), language: String = "" )

Sets drop cap, overrides previously set drop cap. Drop cap (dropped capital) is a decorative element at the beginning of a paragraph that is larger than the rest of the text.


void tab_align ( tab_stops: PackedFloat32Array )

Aligns paragraph to the given tab-stops.

2

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。