measureText

fun DrawScope.measureText(text: String, font: Font? = null): TextLayout

Measures the layout of text under font (or the current font if null) using the canvas's font render context.

Return

a Java2D TextLayout holding measured bounds, ascent, descent, and advance.

Parameters

text

the text string to measure.

font

the font to use for measurement, or null to use the current font on DrawScope.graphics.

Throws