Skip to content

Documentation / @ripl/canvas / renderTextAlongPath

Function: renderTextAlongPath() ​

renderTextAlongPath(ctx, element, method): void

Defined in: canvas/src/utilities.ts:299

Renders text character-by-character along a path using fill or stroke.

Each glyph is drawn at the origin of a frame translated to the path, so it is placed at the point its own textAlign anchors it to — the mid-point only for center. Glyphs are laid out from startOffset (clamped into the path) up to maxWidth of advance, and one whose mid-point falls past the end of the run is dropped, as SVG <textPath> does.

Parameters ​

ParameterTypeDescription
ctxCanvasRenderingContext2DThe native context to draw into.
elementContextTextThe text element, whose pathData describes the path to lay the text along.
method"fill" | "stroke"Whether to fill or stroke each glyph.

Returns ​

void