API

Type Alias TextDataUpdate

TextDataUpdate:
    | { runs?: GlyphRun[]; storage?: GlyphStorage; update: "reset" }
    | { insertBefore?: number; run: GlyphRun; update: "addRun" }
    | { run: GlyphRun | number; update: "removeRun" }
    | { previous: GlyphRun | number; run: GlyphRun; update: "replaceRun" }

Discriminated union driving updateTextData. Each variant's update field is the discriminator. Arrays/maps passed inside any variant are adopted by the TextData and must not be read or mutated by the caller afterward.

Type Declaration

  • { runs?: GlyphRun[]; storage?: GlyphStorage; update: "reset" }
    • Optionalruns?: GlyphRun[]
    • Optionalstorage?: GlyphStorage
    • update: "reset"

      Rebuild runs and/or swap to a different storage. Both runs and storage are optional; missing fields default to the TextData's current value, so { update: "reset" } with neither performs a pure compaction pass that re-lays-out the slot allocator without dead slots or gaps. Invalidates any previously-passed GlyphRun references when runs is set.

  • { insertBefore?: number; run: GlyphRun; update: "addRun" }
    • OptionalinsertBefore?: number

      Index in data.runs to insert before. Default = append at end.

    • run: GlyphRun
    • update: "addRun"

      Append a new run to the live runs list, or insert it before the run currently at insertBefore. The run's curveSet must already exist in the bound storage.

  • { run: GlyphRun | number; update: "removeRun" }
    • run: GlyphRun | number
    • update: "removeRun"

      Remove a previously-added run. Accepts either the GlyphRun reference or its current index in data.runs.

  • { previous: GlyphRun | number; run: GlyphRun; update: "replaceRun" }
    • previous: GlyphRun | number
    • run: GlyphRun
    • update: "replaceRun"

      Replace one run's contents in place. The new run takes the slot in data.runs that the previous run occupied. Cheapest when the new run has the same glyph count and the same curveSet as the previous one.