chenglou/pretext
Fast, accurate & comprehensive text measurement & layout observed · 2026-08-28
Health v2 · maintenance only
55/100
- Activity 89
- Release rhythm 35
- Longevity 12
Flags: no_releases young
How is this computed?
round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10) — computed 2026-09-03. Adoption (stars, forks) is never an input.
- gap_med: n/a
- age_days: 179
- days_rel: n/a
- days_push: 71
- n_releases_24m: 0
Adoption not part of the score
50059 stars · 2734 forks observed · 2026-08-28
What it is AI-extracted, prompt v1, taxonomy v1, 2026-08-29, confidence not recorded
Pretext is a pure TypeScript library for fast, accurate multiline text measurement and layout that avoids DOM reflows by using the browser's font engine for measurement and pure arithmetic for layout. It supports rendering to DOM, Canvas, and SVG, handles international text, and offers both height prediction and manual line-level layout APIs.
Use cases
- measure paragraph height without touching the DOM
- build virtualized lists with accurate text heights
- implement masonry layouts with text cards
- prevent layout shift when text loads
- do Knuth-Plass paragraph justification in the browser
- lay out text lines manually on canvas or SVG
- verify button labels don't overflow during development
When to choose
- you need text height or line breaks without triggering layout reflow
- you're building virtualization, masonry, or custom layout systems
- you need accurate measurement for multilingual text including CJK and RTL
- you render text to Canvas or SVG and need line-level control
When to avoid
- you only need simple CSS text wrapping with no measurement needs
- you need server-side text measurement today (not yet supported)
- your project doesn't use JavaScript in the browser
Facets
library · maturity active
templating ui-components developer-tools frontend web-development performance browser text-measurement text-layout line-breaking knuth-plass canvas-measurement virtualization no-dom-reflow multilingual nodejs web-server typescript
2 sources
- readme: https://github.com/chenglou/pretext · fetched 2026-08-28 · f78ab8f7b135
- homepage: http://chenglou.me/pretext/ · fetched 2026-08-28 · 585c33c2440f
Member repositories
| Repository | Role | Health v2 |
|---|---|---|
| chenglou/pretext | main | 55 |
For agents
markdown · JSON · MCP: product_card(name="chenglou/pretext")
Data as of 2026-08-30T08:39:29.467469+00:00 · Report a problem