• Takes a line of text, and splits it into multiple lines if it's too wide.

    Returns an iterable of lines, each its text for that line, and the width it takes to render.

    IMPORTANT: Set the font and other styles on the canvas context before calling this function, as the measurements are based on the current styles.

    Parameters

    Returns Iterable<LineInfo>

    Remark

    It will split the text with the following algorithm:

    • It will first split newlines, and process each line separately.

    • For each line, it will try the following splits, in order. If at any point the line is found to fit, it will stop searching.

      1. Split on the earliest whitespace possible, and remove the whitespace.
      2. Split on hyphens, figure dashes, en dashes, and em dashes. Keep them in both the end of the first line and the start of the second line.
      3. Split on word boundaries (from an alphanumeric to anything else)
      4. Split anywhere.

Generated using TypeDoc