Skip to content
pixi-silk
GitHub repository
Function

layoutText

import { layoutText } from 'pixi-silk/text';
function layoutText(
   text: string, 
   options: LayoutOptions, 
   measure: TextMeasurer
): TextLayout;

Lays out a block of text. Lines break at \n and, with wordWrap, at spaces. Each character gets its advance, kerning and letter spacing, then the lines are aligned. Widths come from measure, so the same layout works for any renderer.

Parameters#

ParameterType
textstring
optionsLayoutOptions
measureTextMeasurer

Returns#

TextLayout