Label
A control for displaying plain text.
Label.swift:17class Label
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.
Superclasses
class Control
Base class for all GUI controls. Adapts its position and size based on its parent control.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var autowrapMode: TextServer.AutowrapMode
If set to something other than
TextServer/AutowrapMode/autowrapOff
, 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, seeTextServer.AutowrapMode
.var clipText: Bool
If
true
, the Label only shows the text that fits inside its bounding rectangle and will clip text horizontally.var ellipsisChar: String
Ellipsis character used for text clipping.
var horizontalAlignment: HorizontalAlignment
Controls the text’s horizontal alignment. Supports left, center, right, and fill, or justify. Set it to one of the
HorizontalAlignment
constants.var justificationFlags: TextServer.JustificationFlag
Line fill alignment rules. For more info see
TextServer.JustificationFlag
.var labelSettings: LabelSettings?
A
LabelSettings
resource that can be shared between multipleLabel
nodes. Takes priority over theme properties.var language: String
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
var linesSkipped: Int32
The number of the lines ignored and not displayed from the start of the
text
value.var maxLinesVisible: Int32
Limits the lines of text the node shows on screen.
var structuredTextBidiOverride: TextServer.StructuredTextParser
Set BiDi algorithm override for the structured text.
var structuredTextBidiOverrideOptions: GArray
Set additional options for BiDi override.
var tabStops: PackedFloat32Array
Aligns text to the given tab-stops.
var text: String
The text to display on screen.
var textDirection: Control.TextDirection
Base text writing direction.
var textOverrunBehavior: TextServer.OverrunBehavior
Sets the clipping behavior when the text exceeds the node’s bounding rectangle. See
TextServer.OverrunBehavior
for a description of all modes.var uppercase: Bool
If
true
, all the text displays as UPPERCASE.var verticalAlignment: VerticalAlignment
Controls the text’s vertical alignment. Supports top, center, bottom, and fill. Set it to one of the
VerticalAlignment
constants.var visibleCharacters: Int32
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.var visibleCharactersBehavior: TextServer.VisibleCharactersBehavior
Sets the clipping behavior when
visibleCharacters
orvisibleRatio
is set. SeeTextServer.VisibleCharactersBehavior
for more info.var visibleRatio: Double
The fraction of characters to display, relative to the total number of characters (see
getTotalCharacterCount
). If set to1.0
, all characters are displayed. If set to0.5
, only half of the characters will be displayed. This can be useful when animating the text appearing in a dialog box.func getCharacterBounds(pos: Int32
) -> Rect2 Returns the bounding rectangle of the character at position
pos
. If the character is a non-visual character orpos
is outside the valid range, an emptyRect2
is returned. If the character is a part of a composite grapheme, the bounding rectangle of the whole grapheme is returned.func getLineCount(
) -> Int32 Returns the number of lines of text the Label has.
func getLineHeight(line: Int32
) -> Int32 Returns the height of the line
line
.func getTotalCharacterCount(
) -> Int32 Returns the total number of printable characters in the text (excluding spaces and newlines).
func getVisibleLineCount(
) -> Int32 Returns the number of lines shown. Useful if the
Label
’s height cannot currently display all lines.