Displays plain text in a line or wrapped inside a rectangle. For formatted text, use RichTextLabel.
    public class Label : Control

Label displays plain text on the screen. 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 formatting. For that, use RichTextLabel instead.

Note that contrarily to most other Controls, Label’s Control.MouseFilter defaults to MOUSE_FILTER_IGNORE (i.e. it doesn’t react to mouse input events).

Inheritance Chain

Constructors

    public Label()

Properties

    public AlignEnum Align { get; set; }

Controls the text’s horizontal align. Supports left, center, right, and fill, or justify. Set it to one of the ALIGN_* constants.

    public bool Autowrap { get; set; }

If true, wraps the text inside the node’s bounding rectangle. If you resize the node, it will change its height automatically to show all the text. Default: false.

    public bool ClipText { get; set; }

If true, the Label only shows the text that fits inside its bounding rectangle. It also lets you scale the node down freely.

    public int LinesSkipped { get; set; }

The node ignores the first lines_skipped lines before it starts to display text.

    public int MaxLinesVisible { get; set; }

Limits the lines of text the node shows on screen.

    public float PercentVisible { get; set; }

Limits the count of visible characters. If you set percent_visible to 50, only up to half of the text’s characters will display on screen. Useful to animate the text in a dialog box.

    public string Text { get; set; }

The text to display on screen.

    public bool Uppercase { get; set; }

If true, all the text displays as UPPERCASE.

    public VAlign Valign { get; set; }

Controls the text’s vertical align. Supports top, center, bottom, and fill. Set it to one of the VALIGN_* constants.

    public int VisibleCharacters { get; set; }

Restricts the number of characters to display. Set to -1 to disable.

Methods

    public AlignEnum GetAlign()

Getter for Align

    public int GetLineCount()

Returns the amount of lines of text the Label has.

    public int GetLineHeight()

Returns the font size in pixels.

    public int GetLinesSkipped()

Getter for LinesSkipped

    public int GetMaxLinesVisible()

Getter for MaxLinesVisible

    public float GetPercentVisible()

Getter for PercentVisible

    public string GetText()

Getter for Text

    public int GetTotalCharacterCount()

Returns the total length of the text.

    public VAlign GetValign()

Getter for Valign

    public int GetVisibleCharacters()

Getter for VisibleCharacters

    public int GetVisibleLineCount()

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

    public bool HasAutowrap()

Getter for Autowrap

    public bool IsClippingText()

Getter for ClipText

    public bool IsUppercase()

Getter for Uppercase

    public void SetAlign(AlignEnum align)

Setter for Align

    public void SetAutowrap(bool enable)

Setter for Autowrap

    public void SetClipText(bool enable)

Setter for ClipText

    public void SetLinesSkipped(int linesSkipped)

Setter for LinesSkipped

    public void SetMaxLinesVisible(int linesVisible)

Setter for MaxLinesVisible

    public void SetPercentVisible(float percentVisible)

Setter for PercentVisible

    public void SetText(string text)

Setter for Text

    public void SetUppercase(bool enable)

Setter for Uppercase

    public void SetValign(VAlign valign)

Setter for Valign

    public void SetVisibleCharacters(int amount)

Setter for VisibleCharacters

Inner Types

AlignEnum

Name Value Description
Left 0 Align rows to the left (default).
Center 1 Align rows centered.
Right 2 Align rows to the right (default).
Fill 3 Expand row whitespaces to fit the width.

VAlign

Name Value Description
Top 0 Align the whole text to the top.
Center 1 Align the whole text to the center.
Bottom 2 Align the whole text to the bottom.
Fill 3 Align the whole text by spreading the rows.
Tags: