chenglou

    chenglou/pretext

    Fast, accurate & comprehensive text measurement & layout

    web
    TypeScript
    NOASSERTION
    51.0K stars
    2.8K forks
    133 GitHub watchers
    Updated Nov 7, 2026
    View on GitHub

    Build with Backblaze B2

    SDKs, agent skills, IDE extensions, and reference pipelines from Backblaze Labs. All open source.

    Explore Backblaze Labs

    Loading star history...

    Where it stands

    Rank, growth pace and release cadence relative to everything GStars tracks.

    1 release in the last 90 days, the latest 23 days ago, with 9 contributors on GitHub.

    Use Cases & Benefits

    • Provides fast, accurate multiline text measurement and layout in JavaScript/TypeScript without triggering browser layout reflows.
    • Avoids expensive DOM reflows by using canvas-based text measurement and precomputed layouts for efficient rendering and virtualization.
    • Use for calculating text block heights in dynamic web UIs to enable precise virtualization and prevent layout shifts on content changes.
    • Use for manual line-by-line text layout in canvas, SVG, or WebGL rendering contexts where custom text flow and wrapping are required.
    • Use for rich inline text flow with atomic elements like chips or mentions, supporting complex UI components with precise text measurement.

    Should you depend on it?

    License terms, project hygiene and risks, from GitHub metadata and GStars' snapshots.

    License

    Other

    GitHub could not identify this license; read the LICENSE file before depending on it.

    Community files

    • README: present

    Watch-outs

    • License not identified by GitHub; read the LICENSE file before depending on it.

    General guidance from repository metadata, not legal advice. How we score

    From the README

    Pure JavaScript/TypeScript library for multiline text measurement & layout. Fast, accurate & supports all the languages you didn't even know about. Allows rendering to DOM, Canvas, SVG and soon, server-side.

    Pretext side-steps the need for DOM measurements (e.g. getBoundingClientRect, offsetHeight), which trigger layout reflow, one of the most expensive operations in the browser. It implements its own text measurement logic, using the browsers' own font engine as ground truth (very AI-friendly iteration method).

    Clone the repo, run bun install, then bun start, and open /demos/index in your browser. On Windows, use bun run start:windows. Alternatively, see them live at chenglou.me/pretext. Some more at somnai-dreams.github.io/pretext-demos

    Excerpt from the chenglou/pretext README on GitHub (NOASSERTION license). © its authors.Read the full README on GitHub

    Daily snapshots

    Stars gained per day, and how forks and open issues moved, from GStars' daily snapshots

    Forks

    2.8K+31

    Open issues

    65-25

    Compared with peers in Web

    Fastest-growing repositories GStars tracks in this cohort for the week of Nov 8, by 7-day star growth

    chenglou/pretext compared with Web repositories by stars, 7-day star growth, health score and last release
    RepositoryStars+7dHealthLast release
    pingdotgg/t3code54.1K+12.2K40today
    pbakaus/impeccable106.9K+6.4K35today
    meta/astryx20.0K+4.8K652 days ago
    Renhuai123/ziwei-doushu17.3K+3.7K4525 days ago
    garrytan/gstack141.0K+2.3K601 day ago
    chenglou/pretext51.0K—5423 days ago
    Category median54.1K+4.8K45—

    Discover Repositories

    Search across tracked repositories by name or description