Documentation
    Preparing search index...

    Interface TextLayoutOptions

    Arguments of layoutText.

    interface TextLayoutOptions {
        align?: TextAlign;
        direction?: ShapingDirection;
        features?: Readonly<Record<string, number>>;
        fontId?: string;
        language?: string;
        letterSpacing?: number;
        script?: string;
        shaper?: ShapingEngine;
        size: number;
        wrapWidth?: number;
    }
    Index
    align?: TextAlign

    How each line sits within TextLayout.width — §56's "horizontal alignment" (R-28, 2026-08-13). Defaults to "left".

    layoutText("Motor\n42 C", atlas, { size: 0.5, align: "center" });
    // the short line is inset by (width − lineWidth) / 2

    The block's own origin does not move: alignment is within the text, so x = 0 is still the left edge of the widest line, TextLayout.width is still the true extent, and a caller centring the whole block on a node subtracts width / 2 exactly as before.

    direction?: ShapingDirection
    features?: Readonly<Record<string, number>>
    fontId?: string
    language?: string
    letterSpacing?: number

    Extra world units inserted between adjacent glyphs on a line; defaults to 0. Negative values tighten.

    Between, not after: no spacing precedes the first glyph of a line or follows the last, so TextLayout.width stays the true extent of the text and centring it does not drift by half a spacing (decision, WP-3a.4 — CSS letter-spacing appends after every character instead, which is why centred CSS text with wide tracking looks a touch left of centre).

    script?: string
    shaper?: ShapingEngine
    size: number

    World units per line — the baseline-to-baseline distance of single-spaced lines, and the height of one glyph cell. Must be finite and positive. See the module header for why this is not an em size.

    wrapWidth?: number

    Maximum line width in world units. Omitted (or Infinity) leaves line ends at explicit \n only — bit-identical to the pre-wrapping walk. A finite positive measure wraps at UAX #14-lite opportunities (line-break.ts): breaking spaces, hyphen-minus, and CJK; a single unbreakable run wider than the measure overflows rather than being clipped.