Table of Contents

Class TextLine

Namespace
Godot
Assembly
GodotSharp.dll

Abstraction over TextServer for handling a single line of text.

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

Constructors

TextLine()

public TextLine()

Properties

Alignment

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

public HorizontalAlignment Alignment { get; set; }

Property Value

HorizontalAlignment

Direction

Text writing direction.

public TextServer.Direction Direction { get; set; }

Property Value

TextServer.Direction

Flags

Line alignment rules. For more info see TextServer.

public TextServer.JustificationFlag Flags { get; set; }

Property Value

TextServer.JustificationFlag

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

public TextServer.OverrunBehavior TextOverrunBehavior { get; set; }

Property Value

TextServer.OverrunBehavior

Width

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

public void Clear()

Draw(Rid, Vector2, Color?)

Draw text 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)

Parameters

canvas Rid
pos Vector2
color Color?

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

DrawOutline(Rid, Vector2, int, Color?)

Draw text 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)

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

GetLineAscent()

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

public float GetLineAscent()

Returns

float

GetLineDescent()

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

public float GetLineDescent()

Returns

float

GetLineUnderlinePosition()

Returns pixel offset of the underline below the baseline.

public float GetLineUnderlinePosition()

Returns

float

GetLineUnderlineThickness()

Returns thickness of the underline.

public float GetLineUnderlineThickness()

Returns

float

GetLineWidth()

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

public float GetLineWidth()

Returns

float

GetObjectRect(Variant)

Returns bounding rectangle of the inline object.

public Rect2 GetObjectRect(Variant key)

Parameters

key Variant

Returns

Rect2

GetObjects()

Returns array of inline objects.

public Array GetObjects()

Returns

Array

GetRid()

Returns TextServer buffer RID.

public Rid GetRid()

Returns

Rid

GetSize()

Returns size of the bounding box of the text.

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(float)

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

public int HitTest(float coords)

Parameters

coords float

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

TabAlign(float[])

Aligns text to the given tab-stops.

public void TabAlign(float[] tabStops)

Parameters

tabStops float[]