chenglou/pretext
Fast, accurate & comprehensive text measurement & layout observed · 2026-10-12
Health v2 · maintenance only
60/100
- Activity 99
- Release rhythm 35
- Longevity 16
Flags: no_releases no_license
How is this computed?
round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10) — computed 2026-10-21. Adoption (stars, forks) is never an input.
- gap_med: n/a
- age_days: 227
- days_rel: n/a
- days_push: 9
- n_releases_24m: 0
Adoption not part of the score
50754 stars · 2754 forks observed · 2026-10-12
What it is AI-extracted, prompt v1, taxonomy v1, 2026-09-21, confidence 0.97
Pretext is a pure JavaScript/TypeScript library that measures and lays out multiline text without touching the DOM. It works with Canvas, SVG and can be used server‑side for fast, accurate text height calculations.
Use cases
- Calculate the height of a paragraph of text without any DOM reads.
- Lay out multiline text manually for custom chat bubbles or masonry cards.
- Virtualize long lists by predicting item heights accurately.
- Create server‑side text layout for PDF or image generation.
- Implement custom line‑wrapping and justification algorithms in the browser.
- Build responsive UI components that need precise text dimensions.
When to choose
- You need fast, deterministic text height calculations without causing layout reflow.
- Your application performs virtual scrolling or occlusion and requires accurate size prediction.
- You want to render text to Canvas, SVG, or off‑screen contexts.
- You are building custom UI layouts (e.g., chat bubbles, masonry grids) that depend on precise line breaks.
When to avoid
- You already rely on native DOM measurement and performance is not a concern.
- You need a full typographic layout engine with advanced hyphenation, ligatures, or PDF typesetting.
- Your project is limited to environments without Canvas or SVG support.
Facets
library · maturity active
parser ui-components frontend web-development browser text-measurement multiline-layout canvas svg dom-free virtualization typescript layout nodejs
2 sources
- readme: https://github.com/chenglou/pretext · fetched 2026-10-12 · 219efa814451
- homepage: http://chenglou.me/pretext/ · fetched 2026-09-07 · 585c33c2440f
Member repositories
| Repository | Role | Health v2 |
|---|---|---|
| chenglou/pretext | main | 60 |
For agents
markdown · JSON · MCP: product_card(name="chenglou/pretext")
Data as of 2026-10-19T08:05:51.212177+00:00 · Report a problem