Table of Contents

Class TextParagraph

Holds a paragraph of text.

Inheritance
TextParagraph

Remarks

Abstraction over TextServer for handling a single paragraph of text.

Properties

alignment

Paragraph horizontal alignment.

var alignment : int = 0

Property Value

int

Remarks

  • void set_alignment(int value)
  • int get_alignment

break_flags

Line breaking rules. For more info see TextServer.

var break_flags : int = 3

Property Value

int

Remarks

  • void set_break_flags(int value)
  • int get_break_flags

custom_punctuation

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

var custom_punctuation : String = ""

Property Value

String

Remarks

  • void set_custom_punctuation(String value)
  • String get_custom_punctuation

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

justification_flags

Line fill alignment rules. See JustificationFlag for more information.

var justification_flags : int = 163

Property Value

int

Remarks

  • void set_justification_flags(int value)
  • int get_justification_flags

line_spacing

Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.

var line_spacing : float = 0.0

Property Value

float

Remarks

  • void set_line_spacing(float value)
  • float get_line_spacing

max_lines_visible

Limits the lines of text shown.

var max_lines_visible : int = -1

Property Value

int

Remarks

  • void set_max_lines_visible(int value)
  • int get_max_lines_visible

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 paragraph's set width. See OverrunBehavior for a description of all modes.

var text_overrun_behavior : int = 0

Property Value

int

Remarks

  • void set_text_overrun_behavior(int value)
  • int get_text_overrun_behavior

width

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

void clear

clear_dropcap

Removes dropcap.

void clear_dropcap

draw(RID, Vector2, Color, Color)

Qualifiers: 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.

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

Parameters

canvas RID
pos Vector2
color Color
dc_color Color

draw_dropcap(RID, Vector2, Color)

Qualifiers: const

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(RID canvas, Vector2 pos, Color color)

Parameters

canvas RID
pos Vector2
color Color

draw_dropcap_outline(RID, Vector2, int, Color)

Qualifiers: 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.

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

Parameters

canvas RID
pos Vector2
outline_size int
color Color

draw_line(RID, Vector2, int, Color)

Qualifiers: 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.

void draw_line(RID canvas, Vector2 pos, int line, Color color)

Parameters

canvas RID
pos Vector2
line int
color Color

draw_line_outline(RID, Vector2, int, int, Color)

Qualifiers: 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.

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

Parameters

canvas RID
pos Vector2
line int
outline_size int
color Color

draw_outline(RID, Vector2, int, Color, Color)

Qualifiers: 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.

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

Parameters

canvas RID
pos Vector2
outline_size int
color Color
dc_color Color

get_dropcap_lines

Qualifiers: const

Returns number of lines used by dropcap.

int get_dropcap_lines

get_dropcap_rid

Qualifiers: const

Returns drop cap text buffer RID.

RID get_dropcap_rid

get_dropcap_size

Qualifiers: const

Returns drop cap bounding box size.

Vector2 get_dropcap_size

get_line_ascent(int)

Qualifiers: const

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

float get_line_ascent(int line)

Parameters

line int

get_line_count

Qualifiers: const

Returns number of lines in the paragraph.

int get_line_count

get_line_descent(int)

Qualifiers: const

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

float get_line_descent(int line)

Parameters

line int

get_line_object_rect(int, Variant)

Qualifiers: const

Returns bounding rectangle of the inline object.

Rect2 get_line_object_rect(int line, Variant key)

Parameters

line int
key Variant

get_line_objects(int)

Qualifiers: const

Returns array of inline objects in the line.

Array get_line_objects(int line)

Parameters

line int

get_line_range(int)

Qualifiers: const

Returns character range of the line.

Vector2i get_line_range(int line)

Parameters

line int

get_line_rid(int)

Qualifiers: const

Returns TextServer line buffer RID.

RID get_line_rid(int line)

Parameters

line int

get_line_size(int)

Qualifiers: const

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

Vector2 get_line_size(int line)

Parameters

line int

get_line_underline_position(int)

Qualifiers: const

Returns pixel offset of the underline below the baseline.

float get_line_underline_position(int line)

Parameters

line int

get_line_underline_thickness(int)

Qualifiers: const

Returns thickness of the underline.

float get_line_underline_thickness(int line)

Parameters

line int

get_line_width(int)

Qualifiers: const

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

float get_line_width(int line)

Parameters

line int

get_non_wrapped_size

Qualifiers: const

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

Vector2 get_non_wrapped_size

get_rid

Qualifiers: const

Returns TextServer full string buffer RID.

RID get_rid

get_size

Qualifiers: const

Returns the size of the bounding box of the paragraph.

Vector2 get_size

hit_test(Vector2)

Qualifiers: const

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

int hit_test(Vector2 coords)

Parameters

coords Vector2

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

set_dropcap(String, Font, int, Rect2, 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.

bool set_dropcap(String text, Font font, int font_size, Rect2 dropcap_margins, String language)

Parameters

text String
font Font
font_size int
dropcap_margins Rect2
language String

tab_align(PackedFloat32Array)

Aligns paragraph to the given tab-stops.

void tab_align(PackedFloat32Array tab_stops)

Parameters

tab_stops PackedFloat32Array