View definition


Defined in


Extents returns the width and height that the TextLayout will actually take up when drawn. This measures full line allocations, even if no glyph reaches to the top of its ascent or bottom of its descent; it does not return a "best fit" rectnagle for the points that are actually drawn.

For a single-line TextLayout (where the width is negative), if there are no font changes throughout the TextLayout, then the height returned by TextLayout is equivalent to the sum of the ascent and descent of its default font's metrics. Or in other words, after

f := ui.LoadClosestFont(...)
l := ui.NewTextLayout("text", f, -1)
metrics := f.Metrics()
_, height := l.Extents()

metrics.Ascent+metrics.Descent and height are equivalent.

Extents is referenced in 0 repositories