@mocanvas/mocanvas · function

measureLabel

declare function measureLabel(source: RichTextSource, opts: LabelMeasureOptions): TextMeasurement

Measure a shape label with the shared measurer using the default label typography.

Takes either spelling of a label: a plain string, or the rich-text document the store may hold in props.richText. Rich text goes through the HTML path so its marks (a bold run is wider than the plain one) are part of the measurement; plain text goes through the cheaper text path. Both use the same measurer, probe element and cache.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.