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: Contrarily to most other Controls, Label’s Control.MouseFilter defaults to [constant Control.MOUSE_FILTER_IGNORE] (i.e. it doesn’t react to mouse input events). This implies that a label won’t display any configured Control.HintTooltip, unless you change its mouse filter.

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.

    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

    [Obsolete("GetAlign is deprecated. Use the Align property instead.")]
    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.

    [Obsolete("GetLinesSkipped is deprecated. Use the LinesSkipped property instead.")]
    public int GetLinesSkipped()

Getter for LinesSkipped

    [Obsolete("GetMaxLinesVisible is deprecated. Use the MaxLinesVisible property instead.")]
    public int GetMaxLinesVisible()

Getter for MaxLinesVisible

    [Obsolete("GetPercentVisible is deprecated. Use the PercentVisible property instead.")]
    public float GetPercentVisible()

Getter for PercentVisible

    [Obsolete("GetText is deprecated. Use the Text property instead.")]
    public string GetText()

Getter for Text

    public int GetTotalCharacterCount()

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

    [Obsolete("GetValign is deprecated. Use the Valign property instead.")]
    public VAlign GetValign()

Getter for Valign

    [Obsolete("GetVisibleCharacters is deprecated. Use the VisibleCharacters property instead.")]
    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.

    [Obsolete("HasAutowrap is deprecated. Use the Autowrap property instead.")]
    public bool HasAutowrap()

Getter for Autowrap

    [Obsolete("IsClippingText is deprecated. Use the ClipText property instead.")]
    public bool IsClippingText()

Getter for ClipText

    [Obsolete("IsUppercase is deprecated. Use the Uppercase property instead.")]
    public bool IsUppercase()

Getter for Uppercase

    [Obsolete("SetAlign is deprecated. Use the Align property instead.")]
    public void SetAlign(AlignEnum align)

Setter for Align

    [Obsolete("SetAutowrap is deprecated. Use the Autowrap property instead.")]
    public void SetAutowrap(bool enable)

Setter for Autowrap

    [Obsolete("SetClipText is deprecated. Use the ClipText property instead.")]
    public void SetClipText(bool enable)

Setter for ClipText

    [Obsolete("SetLinesSkipped is deprecated. Use the LinesSkipped property instead.")]
    public void SetLinesSkipped(int linesSkipped)

Setter for LinesSkipped

    [Obsolete("SetMaxLinesVisible is deprecated. Use the MaxLinesVisible property instead.")]
    public void SetMaxLinesVisible(int linesVisible)

Setter for MaxLinesVisible

    [Obsolete("SetPercentVisible is deprecated. Use the PercentVisible property instead.")]
    public void SetPercentVisible(float percentVisible)

Setter for PercentVisible

    [Obsolete("SetText is deprecated. Use the Text property instead.")]
    public void SetText(string text)

Setter for Text

    [Obsolete("SetUppercase is deprecated. Use the Uppercase property instead.")]
    public void SetUppercase(bool enable)

Setter for Uppercase

    [Obsolete("SetValign is deprecated. Use the Valign property instead.")]
    public void SetValign(VAlign valign)

Setter for Valign

    [Obsolete("SetVisibleCharacters is deprecated. Use the VisibleCharacters property instead.")]
    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.
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: