@mocanvas/mocanvas · interface

TextMeasureHtmlOptions

interface TextMeasureHtmlOptions

This one ships without a description. The signature above is read from the package, and the guides cover the area it belongs to.


Properties · 9

fontFamily: string
fontSize: number
fontStyle?: string

CSS font-style, e.g. "italic".

fontWeight?: string | number
lineHeight: number

Unitless line height (multiplier of the font size).

maxWidth?: number | null

Wrap width in CSS px, including padding. Omit (or null) for no wrapping.

measureScrollWidth?: boolean

Also report scrollWidth, with the DOM property's meaning: the width the content *cannot* be made to fit in. Text that wraps reports the wrap width; only something unbreakable — one long word, a URL — reports more.

That distinction is the whole point of asking: a shrink-to-fit pass tells "wraps" (fine, keep this size) from "overflows" (too big, shrink) by comparing it against the wrap width.

otherStyles?: Record<string, string>

Extra CSS declarations applied to the probe, e.g. { "font-variant": "small-caps" }.

padding?: number | string

CSS padding, as a number of px or any padding shorthand ("0px", "4px 8px").

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.