Measure how the GL/MSDF renderer will lay out a single plain-text string,
using the registered font atlas metrics. Mirrors textCommand exactly
(resolveTextStyle → resolveRuns → layoutRuns), so the returned bounds
match what actually gets drawn — use it to size backgrounds/pills, place
labels, or test overlap without guessing widths.
Pass opts.maxWidth to measure word-wrapped height (e.g. for a fixed-width
text box); omitting it measures the unwrapped single-line width. opts.lineHeight
overrides the style's multiplier without changing style itself.
Returns { width, height } in the same units as style.fontSize. The font
must already be registered via registerFont; an unregistered family falls
back to the atlas fallback glyph (and warns), so register fonts at app boot
before measuring.
Measure how the GL/MSDF renderer will lay out a single plain-text string, using the registered font atlas metrics. Mirrors textCommand exactly (
resolveTextStyle→resolveRuns→layoutRuns), so the returned bounds match what actually gets drawn — use it to size backgrounds/pills, place labels, or test overlap without guessing widths.Pass
opts.maxWidthto measure word-wrapped height (e.g. for a fixed-width text box); omitting it measures the unwrapped single-line width.opts.lineHeightoverrides the style's multiplier without changingstyleitself.Returns
{ width, height }in the same units asstyle.fontSize. The font must already be registered viaregisterFont; an unregistered family falls back to the atlas fallback glyph (and warns), so register fonts at app boot before measuring.