pretext

Measure multiline text height without DOM reflow using canvas-based arithmetic.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/iinoshirozheng/SinoCloudChat --skill pretext
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pretext
Source: https://github.com/iinoshirozheng/SinoCloudChat/tree/main/.agents/skills/pretext
Command: npx skills add https://github.com/iinoshirozheng/SinoCloudChat --skill pretext

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pretext eliminates the overhead of DOM-based text measurement by providing a DOM-free, canvas-based workflow that computes text height and line counts with pure arithmetic, enabling faster rendering in dynamic UIs.

Core Features & Use Cases

  • Efficient height calculation for multiline text without DOM reflow
  • Supports measuring for canvases, SVG, and virtualized lists
  • Real-world scenario: compute row heights for a long virtualized list to prevent layout jank.

Quick Start

Call prepare(text, font) and then layout(prepared, maxWidth, lineHeight) to obtain height.

Frequently Asked Questions about pretext

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I measure multiline text height without triggering DOM reflow?

DOM-free text measurement calculates multiline text height using pure arithmetic and canvas APIs, eliminating the layout jank and performance overhead caused by DOM reflow.

Can I calculate dynamic row heights for virtualized lists using canvas measurement?

Canvas measurement computes precise row heights for virtualized lists by applying width-aware line breaks, preventing scroll jank when rendering long dynamic lists.

What is the best way to measure text layout for canvas and SVG rendering?

Canvas-based text layout measurement is ideal for canvas and SVG rendering, providing font matching and multiline height calculations without touching the DOM.

How do I compute text line breaks and layout using a DOM-free workflow?

Call prepare(text, font) to process text, then layout(prepared, maxWidth, lineHeight) to compute exact line breaks and total multiline text height.

Does DOM-free text measurement support incremental line range calculations?

DOM-free text measurement supports incremental calculations through layoutNextLine and walkLineRanges APIs, allowing you to process text segments and iterate through specific line ranges efficiently.