Documentation
    Preparing search index...

    Function layoutText

    • Lays text out against atlas (§56 MVP tier).

      const atlas = buildGlyphAtlas();
      const layout = layoutText("Motor\n42 C", atlas, { size: 0.5 });
      layout.lineCount; // 2
      layout.height; // 1 — 2 lines × 0.5
      layout.width; // 1.25 — "Motor", 5 cells × 6 px × (0.5 / 12)
      • Iteration is by code point (for…of), so an astral character is one character and not two lone surrogates.
      • \n ends the line: the pen returns to x = 0 and the baseline drops by size (leading is exactly one line — see TextLayoutOptions.size).
      • \r is skipped entirely, drawing nothing and advancing nothing, so CRLF-terminated text lays out identically to LF-terminated text (decision, WP-3a.4). A lone \r as a line terminator — Mac OS 9 and earlier — is not honoured as a break.
      • Every other character absent from the atlas, control characters and tabs included, draws the fallback box and advances one cell. Nothing is silently dropped: an unrepresentable character is visible, which is what makes a missing script or a stray control byte diagnosable (§56's "font fallback" at this tier).

      Pure: same string, same atlas, same options → identical numbers, always. No clock, no randomness, no measurement of the environment.

      The claim is stronger than "same runtime", and mechanically so: every arithmetic operation here is one of IEEE-754's exactly rounded ones — +, −, ×, ÷ and Math.max — over doubles, with no sqrt, no transcendental, no Math.fround, and no iteration over a hash order (the atlas is consulted with Map.get, never walked). Two conforming engines therefore produce bit-identical quads, which is the tier @fourjs/geometry's triangulatePolygon reached and Path's arcs deliberately did not. An edit that introduces a transcendental — a rotation, an italic shear, a Math.round to whole texels — breaks this stated tier, not merely a number.

      Parameters

      Returns TextLayout