Skip to content

measureWrappedText

measureWrappedText(text, options): MeasuredText

Defined in: packages/renderer/src/assets.ts:730

Measure the natural size of a text string — wrap-aware — without constructing a live text node. This is the renderer’s text-metrics primitive: reach for it (not a direct pixi.js import) when a layout needs to size a panel to its text (e.g. a content-sized dialogue bubble).

Both paths honour wordWrapWidth, so lineCount reflects the wrapped line count: canvas via Pixi’s CanvasTextMetrics, bitmap via BitmapFontManager (whose base-unit metrics are scaled to fontSize, matching what a BitmapText renders at). Measurement resolves the engine-level defaultTextStyle under the given options — the same merge the render path applies — so the measured box matches the drawn text.

Requires a DOM/canvas at runtime (the browser) for the canvas path; unit tests mock CanvasTextMetrics (there is no canvas under the node test env).

string

MeasureTextOptions

MeasuredText