Table of Contents

Class TextParagraph

Namespace
Godot
Assembly
GodotSharp.dll

Abstraction over TextServer for handling a single paragraph of text.

public class TextParagraph : RefCounted, IDisposable
Inheritance
TextParagraph
Implements
Inherited Members

Constructors

TextParagraph()

public TextParagraph()

Properties

Alignment

Paragraph horizontal alignment.

public HorizontalAlignment Alignment { get; set; }

Property Value

HorizontalAlignment

BreakFlags

Line breaking rules. For more info see TextServer.

public TextServer.LineBreakFlag BreakFlags { get; set; }

Property Value

TextServer.LineBreakFlag

CustomPunctuation

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

public string CustomPunctuation { get; set; }

Property Value

string

Direction

Text writing direction.

public TextServer.Direction Direction { get; set; }

Property Value

TextServer.Direction

EllipsisChar

Ellipsis character used for text clipping.

public string EllipsisChar { get; set; }

Property Value

string

JustificationFlags

Line fill alignment rules. For more info see TextServer.JustificationFlag.

public TextServer.JustificationFlag JustificationFlags { get; set; }

Property Value

TextServer.JustificationFlag

MaxLinesVisible

Limits the lines of text shown.

public int MaxLinesVisible { get; set; }

Property Value

int

Orientation

Text orientation.

public TextServer.Orientation Orientation { get; set; }

Property Value

TextServer.Orientation

PreserveControl

If set to true text will display control characters.

public bool PreserveControl { get; set; }

Property Value

bool

PreserveInvalid

If set to true text will display invalid characters.

public bool PreserveInvalid { get; set; }

Property Value

bool

TextOverrunBehavior

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

public TextServer.OverrunBehavior TextOverrunBehavior { get; set; }

Property Value

TextServer.OverrunBehavior

Width

Paragraph width.

public float Width { get; set; }

Property Value

float

Methods

AddObject(Variant, Vector2, InlineAlignment, int, float)

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

public bool AddObject(Variant key, Vector2 size, InlineAlignment inlineAlign = InlineAlignment.Center, int length = 1, float baseline = 0)

Parameters

key Variant
size Vector2
inlineAlign InlineAlignment
length int
baseline float

Returns

bool

AddString(string, Font, int, string, Variant)

Adds text span and font to draw it.

public bool AddString(string text, Font font, int fontSize, string language = "", Variant meta = default)

Parameters

text string
font Font
fontSize int
language string
meta Variant

Returns

bool

Clear()

Clears text paragraph (removes text and inline objects).

public void Clear()

ClearDropcap()

Removes dropcap.

public void ClearDropcap()

Draw(Rid, Vector2, Color?, Color?)

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.

public void Draw(Rid canvas, Vector2 pos, Color? color = null, Color? dcColor = null)

Parameters

canvas Rid
pos Vector2
color Color?

If the parameter is null, then the default value is new Color(1, 1, 1, 1).

dcColor Color?

If the parameter is null, then the default value is new Color(1, 1, 1, 1).

DrawDropcap(Rid, Vector2, Color?)

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

public void DrawDropcap(Rid canvas, Vector2 pos, Color? color = null)

Parameters

canvas Rid
pos Vector2
color Color?

If the parameter is null, then the default value is new Color(1, 1, 1, 1).

DrawDropcapOutline(Rid, Vector2, int, Color?)

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

public void DrawDropcapOutline(Rid canvas, Vector2 pos, int outlineSize = 1, Color? color = null)

Parameters

canvas Rid
pos Vector2
outlineSize int
color Color?

If the parameter is null, then the default value is new Color(1, 1, 1, 1).

DrawLine(Rid, Vector2, int, Color?)

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.

public void DrawLine(Rid canvas, Vector2 pos, int line, Color? color = null)

Parameters

canvas Rid
pos Vector2
line int
color Color?

If the parameter is null, then the default value is new Color(1, 1, 1, 1).

DrawLineOutline(Rid, Vector2, int, int, Color?)

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.

public void DrawLineOutline(Rid canvas, Vector2 pos, int line, int outlineSize = 1, Color? color = null)

Parameters

canvas Rid
pos Vector2
line int
outlineSize int
color Color?

If the parameter is null, then the default value is new Color(1, 1, 1, 1).

DrawOutline(Rid, Vector2, int, Color?, Color?)

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.

public void DrawOutline(Rid canvas, Vector2 pos, int outlineSize = 1, Color? color = null, Color? dcColor = null)

Parameters

canvas Rid
pos Vector2
outlineSize int
color Color?

If the parameter is null, then the default value is new Color(1, 1, 1, 1).

dcColor Color?

If the parameter is null, then the default value is new Color(1, 1, 1, 1).

GetDropcapLines()

Returns number of lines used by dropcap.

public int GetDropcapLines()

Returns

int

GetDropcapRid()

Returns drop cap text buffer RID.

public Rid GetDropcapRid()

Returns

Rid

GetDropcapSize()

Returns drop cap bounding box size.

public Vector2 GetDropcapSize()

Returns

Vector2

GetLineAscent(int)

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

public float GetLineAscent(int line)

Parameters

line int

Returns

float

GetLineCount()

Returns number of lines in the paragraph.

public int GetLineCount()

Returns

int

GetLineDescent(int)

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

public float GetLineDescent(int line)

Parameters

line int

Returns

float

GetLineObjectRect(int, Variant)

Returns bounding rectangle of the inline object.

public Rect2 GetLineObjectRect(int line, Variant key)

Parameters

line int
key Variant

Returns

Rect2

GetLineObjects(int)

Returns array of inline objects in the line.

public Array GetLineObjects(int line)

Parameters

line int

Returns

Array

GetLineRange(int)

Returns character range of the line.

public Vector2I GetLineRange(int line)

Parameters

line int

Returns

Vector2I

GetLineRid(int)

Returns TextServer line buffer RID.

public Rid GetLineRid(int line)

Parameters

line int

Returns

Rid

GetLineSize(int)

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

public Vector2 GetLineSize(int line)

Parameters

line int

Returns

Vector2

GetLineUnderlinePosition(int)

Returns pixel offset of the underline below the baseline.

public float GetLineUnderlinePosition(int line)

Parameters

line int

Returns

float

GetLineUnderlineThickness(int)

Returns thickness of the underline.

public float GetLineUnderlineThickness(int line)

Parameters

line int

Returns

float

GetLineWidth(int)

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

public float GetLineWidth(int line)

Parameters

line int

Returns

float

GetNonWrappedSize()

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

public Vector2 GetNonWrappedSize()

Returns

Vector2

GetRid()

Returns TextServer full string buffer RID.

public Rid GetRid()

Returns

Rid

GetSize()

Returns the size of the bounding box of the paragraph.

public Vector2 GetSize()

Returns

Vector2

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

HitTest(Vector2)

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

public int HitTest(Vector2 coords)

Parameters

coords Vector2

Returns

int

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

ResizeObject(Variant, Vector2, InlineAlignment, float)

Sets new size and alignment of embedded object.

public bool ResizeObject(Variant key, Vector2 size, InlineAlignment inlineAlign = InlineAlignment.Center, float baseline = 0)

Parameters

key Variant
size Vector2
inlineAlign InlineAlignment
baseline float

Returns

bool

SetBidiOverride(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.

public void SetBidiOverride(Array @override)

Parameters

override Array

SetDropcap(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.

public bool SetDropcap(string text, Font font, int fontSize, Rect2? dropcapMargins = null, string language = "")

Parameters

text string
font Font
fontSize int
dropcapMargins Rect2?

If the parameter is null, then the default value is new Rect2(new Vector2(0, 0), new Vector2(0, 0)).

language string

Returns

bool

TabAlign(float[])

Aligns paragraph to the given tab-stops.

public void TabAlign(float[] tabStops)

Parameters

tabStops float[]