Table of Contents

Class Label

Namespace
Godot
Assembly
GodotSharp.dll

A control for displaying plain text. It gives you control over the horizontal and vertical alignment and can wrap the text inside the node's bounding rectangle. It doesn't support bold, italics, or other rich text formatting. For that, use RichTextLabel instead.

public class Label : Control, IDisposable
Inheritance
Label
Implements
Inherited Members

Constructors

Label()

public Label()

Properties

AutowrapMode

If set to something other than Off, the text gets wrapped inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text. To see how each mode behaves, see TextServer.AutowrapMode.

public TextServer.AutowrapMode AutowrapMode { get; set; }

Property Value

TextServer.AutowrapMode

ClipText

If true, the Label only shows the text that fits inside its bounding rectangle and will clip text horizontally.

public bool ClipText { get; set; }

Property Value

bool

HorizontalAlignment

Controls the text's horizontal alignment. Supports left, center, right, and fill, or justify. Set it to one of the HorizontalAlignment constants.

public HorizontalAlignment HorizontalAlignment { get; set; }

Property Value

HorizontalAlignment

JustificationFlags

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

public TextServer.JustificationFlag JustificationFlags { get; set; }

Property Value

TextServer.JustificationFlag

LabelSettings

A LabelSettings resource that can be shared between multiple Label nodes. Takes priority over theme properties.

public LabelSettings LabelSettings { get; set; }

Property Value

LabelSettings

Language

Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

public string Language { get; set; }

Property Value

string

LinesSkipped

The number of the lines ignored and not displayed from the start of the Text value.

public int LinesSkipped { get; set; }

Property Value

int

MaxLinesVisible

Limits the lines of text the node shows on screen.

public int MaxLinesVisible { get; set; }

Property Value

int

StructuredTextBidiOverride

Set BiDi algorithm override for the structured text.

public TextServer.StructuredTextParser StructuredTextBidiOverride { get; set; }

Property Value

TextServer.StructuredTextParser

StructuredTextBidiOverrideOptions

Set additional options for BiDi override.

public Array StructuredTextBidiOverrideOptions { get; set; }

Property Value

Array

TabStops

Aligns text to the given tab-stops.

public float[] TabStops { get; set; }

Property Value

float[]

Text

The text to display on screen.

public string Text { get; set; }

Property Value

string

TextDirection

Base text writing direction.

public Control.TextDirection TextDirection { get; set; }

Property Value

Control.TextDirection

TextOverrunBehavior

Sets the clipping behavior when the text exceeds the node's bounding rectangle. See TextServer.OverrunBehavior for a description of all modes.

public TextServer.OverrunBehavior TextOverrunBehavior { get; set; }

Property Value

TextServer.OverrunBehavior

Uppercase

If true, all the text displays as UPPERCASE.

public bool Uppercase { get; set; }

Property Value

bool

VerticalAlignment

Controls the text's vertical alignment. Supports top, center, bottom, and fill. Set it to one of the VerticalAlignment constants.

public VerticalAlignment VerticalAlignment { get; set; }

Property Value

VerticalAlignment

VisibleCharacters

The number of characters to display. If set to -1, all characters are displayed. This can be useful when animating the text appearing in a dialog box.

Note: Setting this property updates VisibleRatio accordingly.

public int VisibleCharacters { get; set; }

Property Value

int

VisibleCharactersBehavior

Sets the clipping behavior when VisibleCharacters or VisibleRatio is set. See TextServer.VisibleCharactersBehavior for more info.

public TextServer.VisibleCharactersBehavior VisibleCharactersBehavior { get; set; }

Property Value

TextServer.VisibleCharactersBehavior

VisibleRatio

The fraction of characters to display, relative to the total number of characters (see GetTotalCharacterCount()). If set to 1.0, all characters are displayed. If set to 0.5, only half of the characters will be displayed. This can be useful when animating the text appearing in a dialog box.

Note: Setting this property updates VisibleCharacters accordingly.

public float VisibleRatio { get; set; }

Property Value

float

Methods

GetLineCount()

Returns the number of lines of text the Label has.

public int GetLineCount()

Returns

int

GetLineHeight(int)

Returns the height of the line line.

If line is set to -1, returns the biggest line height.

If there are no lines, returns font size in pixels.

public int GetLineHeight(int line = -1)

Parameters

line int

Returns

int

GetTotalCharacterCount()

Returns the total number of printable characters in the text (excluding spaces and newlines).

public int GetTotalCharacterCount()

Returns

int

GetVisibleLineCount()

Returns the number of lines shown. Useful if the Label's height cannot currently display all lines.

public int GetVisibleLineCount()

Returns

int

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

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