Skip to main content

Label Class

Description:

  A class for creating Label object.

AutomaticWidth

Type: Readonly Field.

Description:

  The value to use for automatic width calculation

Signature:

const AutomaticWidth: number

__call

Type: Metamethod.

Description:

  Creates a new Label object with the specified font string.

Signature:

metamethod __call: function(self: LabelClass, fontStr: string): Label | nil

Parameters:

ParameterTypeDescription
fontStrstringThe font string to use for the label. Should be in the format "fontName;fontSize;sdf", where sdf should be "true" or "false" and can be omitted as default is false.

Returns:

Return TypeDescription
Label | nilThe new Label object, or nil if the font could not be loaded.

__call

Type: Metamethod.

Description:

  Creates a new Label object with the specified font name and font size.

Signature:

metamethod __call: function(self: LabelClass, fontName: string, fontSize: integer, sdf?: boolean): Label | nil

Parameters:

ParameterTypeDescription
fontNamestringThe name of the font to use for the label.
Can be font file path with or without file extension.
fontSizeintegerThe size of the font to use for the label.
sdfboolean[optional] Whether to use SDF rendering or not. With SDF rendering, the outline feature will be enabled. (Default is false)

Returns:

Return TypeDescription
Label | nilThe new Label object, or nil if the font could not be loaded.