What problem does it solve?
Pretext solves the problem of creating visually rich, browser-native text layouts that must wrap around shapes without expensive DOM measurement and reflow.
Core Features & Use Cases
- DOM-free text measurement and layout: precompute line breaks, per-line widths, and grapheme positioning from (text, font, width) so you can render confidently.
- Creative primitive for reflow: flow typography around moving obstacles (circles, rectangles, or any computed corridor width) using row-by-row streaming layout.
- Text-as-geometry effects: implement kinetic typography, particle/shatter typography, and shrink-wrapped text “cards” where the layout is driven by measured geometry rather than CSS guessing.
Use Case Example: You want a single-file HTML demo where a long paragraph curves around a dragged orb and stays stable at high frame rates; pretext lets you measure once, then stream layout every frame based on the obstacle’s current position.
Quick Start
Use the pretext skill to generate a single-file HTML demo that measures your chosen real prose with @chenglou/pretext and renders it to a canvas with text flowing around a moving obstacle.