Measure paragraph height
Use
prepare() + layout() to get the height of a paragraph at a given container width — without reading from the DOM.The font string passed to
prepare() must match your CSS font declaration shorthand — including size, weight, style, and family. It follows the same format as canvasContext.font, for example '16px Inter' or 'bold 14px "Helvetica Neue"'.Lay out lines manually
Switch to Each entry in
prepareWithSegments() + layoutWithLines() when you need the actual line strings and widths for rendering to canvas, SVG, or WebGL.lines has a text string, a width number, and start/end cursors for further processing.Flow text around a float with layoutNextLine
Use
layoutNextLine() when the available width changes from line to line — for example, when text flows around a floated image.layoutNextLine() is an iterator-style API. Pass the previous line’s end cursor as the next start. It returns null when the paragraph is exhausted.Height prediction
Virtualization, masonry, and scroll anchoring with accurate heights.
Manual layout
Render lines yourself to canvas, SVG, or WebGL.
prepare() API
Full reference for
prepare(), prepareWithSegments(), and options.