Tagged articles
5 articles
Page 1 of 1
IT Services Circle
IT Services Circle
Mar 31, 2026 · Frontend Development

How Pretext Calculates Text Layout Without DOM Reflows

Pretext is a TypeScript‑based text layout engine that accurately computes line breaks and element heights using canvas.measureText and Intl.Segmenter, eliminating costly DOM measurements, reflows, and layout thrashing while delivering sub‑0.05 ms performance for dynamic UI scenarios.

CanvasJavaScripttext layout
0 likes · 5 min read
How Pretext Calculates Text Layout Without DOM Reflows
Machine Heart
Machine Heart
Mar 30, 2026 · Frontend Development

How Cheng Lou’s Pretext Library Powers the Viral Bad Apple Text‑Wrap Effect

The article introduces Pretext, a pure JavaScript/TypeScript text‑layout engine that measures and renders text without touching the DOM, claims speed hundreds of times faster than traditional methods, and showcases its use in the viral Bad Apple animation and several interactive demos, while highlighting its AI‑friendly API, tiny footprint, and open‑source impact.

AI-friendlyJavaScriptPretext
0 likes · 6 min read
How Cheng Lou’s Pretext Library Powers the Viral Bad Apple Text‑Wrap Effect
Full-Stack Cultivation Path
Full-Stack Cultivation Path
Mar 30, 2026 · Frontend Development

Solving the 20‑Year Front‑End Text‑Layout Nightmare with Pretext (10k Stars in One Day)

Pretext, a TypeScript‑based text layout engine, eliminates the need for DOM measurements by using canvas.measureText and Intl.Segmenter, delivering sub‑0.05 ms height calculations, preventing layout thrashing, and simplifying scenarios like chat bubbles, masonry grids, AI interfaces, and virtual lists.

Intl.SegmenterPretextVirtualization
0 likes · 5 min read
Solving the 20‑Year Front‑End Text‑Layout Nightmare with Pretext (10k Stars in One Day)
ByteDance Dali Intelligent Technology Team
ByteDance Dali Intelligent Technology Team
Sep 28, 2021 · Mobile Development

Achieving Precise Vertical Text Centering in Flutter: Font Metrics Analysis and Android‑Based Solution

This article investigates why text in Flutter buttons often fails to vertically center, analyzes Android font metrics and NotoSansCJK details, explores native Android solutions like includeFontPadding and Paint.getTextBounds, and proposes a Flutter implementation using minikin layout to achieve precise vertical centering.

AndroidFlutterFont Metrics
0 likes · 15 min read
Achieving Precise Vertical Text Centering in Flutter: Font Metrics Analysis and Android‑Based Solution