Font:getWidth

Returns the width of a string when rendered using the font, with an optional wrap. To get the correct units returned, make sure the pixel density is set with Font:setPixelDensity.

width = Font:getWidth(text, wrap)

Arguments

NameTypeDefaultDescription
textstringThe text to get the width of.
wrapnumber0The width at which to wrap lines, or 0 for no wrap.

Returns

NameTypeDescription
widthnumberThe maximum width of any line in the text.

See also