Table of Contents

Class TextLine

Holds a line of text.

Inheritance
TextLine

Remarks

Abstraction over TextServer for handling a single line of text.

Properties

alignment

Sets text alignment within the line as if the line was horizontal.

var alignment : int = 0

Property Value

int

Remarks

  • void set_horizontal_alignment(int value)
  • int get_horizontal_alignment

direction

Text writing direction.

var direction : int = 0

Property Value

int

Remarks

  • void set_direction(int value)
  • int get_direction

ellipsis_char

Ellipsis character used for text clipping.

var ellipsis_char : String = "…"

Property Value

String

Remarks

  • void set_ellipsis_char(String value)
  • String get_ellipsis_char

flags

Line alignment rules. For more info see TextServer.

var flags : int = 3

Property Value

int

Remarks

  • void set_flags(int value)
  • int get_flags

orientation

Text orientation.

var orientation : int = 0

Property Value

int

Remarks

  • void set_orientation(int value)
  • int get_orientation

preserve_control

If set to true text will display control characters.

var preserve_control : bool = false

Property Value

bool

Remarks

  • void set_preserve_control(bool value)
  • bool get_preserve_control

preserve_invalid

If set to true text will display invalid characters.

var preserve_invalid : bool = true

Property Value

bool

Remarks

  • void set_preserve_invalid(bool value)
  • bool get_preserve_invalid

text_overrun_behavior

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

var text_overrun_behavior : int = 3

Property Value

int

Remarks

  • void set_text_overrun_behavior(int value)
  • int get_text_overrun_behavior

width

Text line width.

var width : float = -1.0

Property Value

float

Remarks

Methods

add_object(Variant, Vector2, int, int, float)

Adds inline object to the text buffer, key must be unique. In the text, object is represented as length object replacement characters.

bool add_object(Variant key, Vector2 size, int inline_align, int length, float baseline)

Parameters

key Variant
size Vector2
inline_align int
length int
baseline float

add_string(String, Font, int, String, Variant)

Adds text span and font to draw it.

bool add_string(String text, Font font, int font_size, String language, Variant meta)

Parameters

text String
font Font
font_size int
language String
meta Variant

clear

Clears text line (removes text and inline objects).

void clear

draw(RID, Vector2, Color)

Qualifiers: const

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

void draw(RID canvas, Vector2 pos, Color color)

Parameters

canvas RID
pos Vector2
color Color

draw_outline(RID, Vector2, int, Color)

Qualifiers: const

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

void draw_outline(RID canvas, Vector2 pos, int outline_size, Color color)

Parameters

canvas RID
pos Vector2
outline_size int
color Color

get_line_ascent

Qualifiers: const

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

float get_line_ascent

get_line_descent

Qualifiers: const

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

float get_line_descent

get_line_underline_position

Qualifiers: const

Returns pixel offset of the underline below the baseline.

float get_line_underline_position

get_line_underline_thickness

Qualifiers: const

Returns thickness of the underline.

float get_line_underline_thickness

get_line_width

Qualifiers: const

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

float get_line_width

get_object_rect(Variant)

Qualifiers: const

Returns bounding rectangle of the inline object.

Rect2 get_object_rect(Variant key)

Parameters

key Variant

get_objects

Qualifiers: const

Returns array of inline objects.

Array get_objects

get_rid

Qualifiers: const

Returns TextServer buffer RID.

RID get_rid

get_size

Qualifiers: const

Returns size of the bounding box of the text.

Vector2 get_size

hit_test(float)

Qualifiers: const

Returns caret character offset at the specified pixel offset at the baseline. This function always returns a valid position.

int hit_test(float coords)

Parameters

coords float

resize_object(Variant, Vector2, int, float)

Sets new size and alignment of embedded object.

bool resize_object(Variant key, Vector2 size, int inline_align, float baseline)

Parameters

key Variant
size Vector2
inline_align int
baseline float

set_bidi_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.

void set_bidi_override(Array override)

Parameters

override Array

tab_align(PackedFloat32Array)

Aligns text to the given tab-stops.

void tab_align(PackedFloat32Array tab_stops)

Parameters

tab_stops PackedFloat32Array