pretext

Measure and lay out multiline browser text without DOM reflows.

Updated Apr 20, 2026
One-click install
npx skills add https://github.com/matthew-johnson/hermes-agent --skill pretext-matthew-johnson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pretext
Source: https://github.com/matthew-johnson/hermes-agent/tree/main/skills/creative/pretext
Command: npx skills add https://github.com/matthew-johnson/hermes-agent --skill pretext-matthew-johnson

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill provides tools to measure and lay out multiline text in the browser without triggering costly DOM reflows, enabling fast, creative typography demos.

Core Features & Use Cases

  • Precise text measurement and line breaking for dynamic layouts
  • Support for flow around obstacles, text-as-geometry visuals, editorial multi-column layouts, and kinetic typography
  • Real-world use cases include building interactive demos where text flows around shapes or morphs with animation

Quick Start

Use prepareWithSegments to prepare the text and then layoutNextLineRange / materializeLineRange to render lines.

Frequently Asked Questions about pretext

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

FAQPage Schema
How do I measure and lay out multiline text in the browser without DOM reflows?

You can measure and lay out multiline text without DOM reflows by using the pretext API, which provides per-line and per-glyph metrics directly for canvas rendering. This avoids costly browser reflows during interactive typography animations.

Can I use canvas to make text flow around obstacles in interactive demos?

Yes, canvas text flowing around obstacles is supported by preparing text segments and computing line ranges. The layout engine generates metrics that rendering code consumes to position text around shapes dynamically.

What is kinetic typography and how does DOM-free text layout help build it?

Kinetic typography involves animating text, and DOM-free text layout helps by providing precise per-glyph metrics without triggering reflows. This allows smooth canvas-based rendering for morphing or moving text visuals.

Does pretext support editorial multi-column text layouts in interactive canvases?

Yes, pretext supports editorial multi-column layouts in interactive canvases by exposing layout functions like layoutWithLines and walkLineRanges. These produce the metrics needed to render text across columns efficiently.

How do I get started with text measurement and line breaking for dynamic layouts?

Start by using prepareWithSegments to prepare your text, then call layoutNextLineRange to compute line breaks and materializeLineRange to render. This workflow provides precise measurement for dynamic canvas layouts.

What is the best way to handle text-as-geometry visuals without triggering browser reflows?

The best way to handle text-as-geometry visuals without reflows is using a DOM-free text layout API that outputs per-glyph metrics. Pretext computes these measurements so rendering code can treat text as geometry directly on canvas.