chenglou/pretext
Fast, accurate & comprehensive text measurement & layout
Build with Backblaze B2
SDKs, agent skills, IDE extensions, and reference pipelines from Backblaze Labs. All open source.
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, thenbun start, and open/demos/indexin your browser. On Windows, usebun run start:windows. Alternatively, see them live at chenglou.me/pretext. Some more at somnai-dreams.github.io/pretext-demos
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
| Repository | Stars | +7d | Health | Last release |
|---|---|---|---|---|
| pingdotgg/t3code | 54.1K | +12.2K | 40 | today |
| pbakaus/impeccable | 106.9K | +6.4K | 35 | today |
| meta/astryx | 20.0K | +4.8K | 65 | 2 days ago |
| Renhuai123/ziwei-doushu | 17.3K | +3.7K | 45 | 25 days ago |
| garrytan/gstack | 141.0K | +2.3K | 60 | 1 day ago |
| chenglou/pretext | 51.0K | — | 54 | 23 days ago |
| Category median | 54.1K | +4.8K | 45 | — |
Discover Repositories
Search across tracked repositories by name or description