pretext

Measure and lay out multiline text without the DOM using the @chenglou/pretext library.

1|Updated Jul 31, 2026
One-click install
npx skills add https://github.com/icyzh/hermes-web --skill pretext-icyzh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pretext
Source: https://github.com/icyzh/hermes-web/tree/main/skills/creative/pretext
Command: npx skills add https://github.com/icyzh/hermes-web --skill pretext-icyzh

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill solves the performance and layout limitations of standard browser text rendering by providing a zero-dependency, canvas-based engine for precise, high-performance text measurement and kinetic typography.

Core Features & Use Cases

  • DOM-free Layout: Measure text height, line breaks, and grapheme positions without triggering expensive browser reflows.
  • Creative Primitives: Enable advanced visual effects like text flowing around moving obstacles, shattered typography, and interactive word-based game geometry.
  • Use Case: Create a hero section where a paragraph of text dynamically reflows around a user-dragged sprite at 60fps, or build a game where the playfield is constructed from real prose.

Quick Start

Use the pretext skill to generate a creative demo that flows a paragraph of text around a moving circular obstacle.

Frequently Asked Questions about pretext

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

FAQPage Schema
How do I render kinetic typography in the browser without triggering DOM reflows?

DOM-free kinetic typography is rendered by using a canvas-based engine to calculate grapheme positions and line breaks without touching the DOM. This approach avoids expensive browser reflows, enabling high-performance text animation at 60fps.

What is the best way to make canvas text layout flow around moving obstacles?

The best way to flow canvas text around moving obstacles is using a zero-dependency text measurement library to calculate dynamic line breaks. This allows custom rendering logic to reflow multiline text around interactive sprites in real-time.

Can I measure multiline text height and line breaks on a canvas without DOM elements?

Yes, you can measure multiline text height and line breaks without DOM elements by using a canvas-based text layout engine. This provides precise grapheme positioning and text measurement while bypassing standard browser rendering limitations.

Does this canvas-based text layout engine require any external dependencies?

The canvas-based text layout engine is zero-dependency, but it requires the @chenglou/pretext library to function. This library handles the underlying calculations for line breaks and grapheme positions for your custom rendering.

Why does standard browser text rendering struggle with interactive typography games?

Standard browser text rendering struggles with interactive typography games because DOM reflows are computationally expensive during dynamic updates. A DOM-free canvas approach calculates text geometry independently, allowing game playfields to be constructed from real prose without performance drops.

When should I not use DOM elements for multiline text layout?

You should not use DOM elements for multiline text layout when building high-performance effects like shattered typography or text reflowing around dynamic obstacles. DOM-free canvas rendering prevents layout thrashing and maintains smooth frame rates during complex animations.