@mocanvas/mocanvas · function

wrapTextTextureRuns

declare function wrapTextTextureRuns(spec: TextTextureSpec): TextTextureLine[]

Break a spec's label into the lines the raster draws, keeping each run's formatting.

Same greedy word wrapping as wrapTextTextureLines — hard newlines (here: block boundaries and hardBreak nodes) always break, a word that does not fit is split by characters — but a line is a list of styled runs rather than a string, so a bold word inside a sentence is measured and drawn bold. A spec with no richText yields one unstyled run per line, so the two functions agree line for line.

Mentioned here

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.