Font:getWidth

Returns the width and line count of a string when rendered using the font, taking into account an optional wrap limit.

width, lines = 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.
linesnumberThe number of lines in the wrapped text.

Notes

To get the correct units returned, make sure the pixel density is set with Font:setPixelDensity.

See also