Skip to content

GLabel extends GObject

Factory Functions

function GLabel(str, [x=0, y=0])
Creates a new GLabel, displaying the given string str. The object's x and y coordinates can also be specified — if left unspecified, defaults to 0, 0.

Methods

function GLabel::setFont(fontStr)
Sets this GLabel's font to the font specified by fontStr.
fontStr should be using the CSS form of font specification; for example: 24px 'Helvetica Neue'
function GLabel::getFont()
Returns: The font this GLabel is currently using. The font is returned in the same format specified in GLabel::setFont.
function GLabel::setLabel(str)
Sets this GLabel to display the string specified by str.
function GLabel::getLabel()
Returns: The text currently displayed by this GLabel.
function GLabel::getDescent()
Returns: the descent of this font, which is the maximum distance characters extend below the baseline. In JavaScript, this value is estimated from the point size.
function GLabel::getTextAlign()
Returns: the current horizontal text alignment of this font. Can take on any of the values noted here, notably: "left", "right", and "center". The default value is "start", which is "left" in LTR languages and "right" for RTL languages.
function GLabel::setTextAlign(alignment)
Sets this GLabel's horizontal text alignment (see GLabel::getTextAlign for options).
function GLabel::getBaseline()
Returns: the current baseline alignment (roughly, vertical alignment) of this font. Can take on any of the values noted here, notably: "top", "bottom", and "middle". The default value is "alphabetic".
function GLabel::setBaseline(baselineAlignment)
Sets this GLabel's baseline alignment (see GLabel::getBaseline for options).
function GLabel::getAscent()
Returns: The ascent of this font, which is the maximum distance characters extend above the baseline. In JavaScript, this value is estimated from the point size.
function GLabel::getDescent()
Returns: the descent of this font, which is the maximum distance characters extend below the baseline. In JavaScript, this value is estimated from the point size.

Fields

static const GLabel.DEFAULT_FAMILY = "SansSerif"
Defines the default font family used on a newly-created GLabel.
static const GLabel.DEFAULT_SIZE = 12
Defines the default font size used on a newly-created GLabel.