Pretext Text Metrics — guide skill for captions & subtitles

For AI agents: find the right skill in one call — curl -s "https://skills.varg.ai/api/search?q=<what the person wants>" returns the matching use case and the best skills with install commands, as markdown (Russian works too). Full index: https://skills.varg.ai/llms.txt. Every page has a markdown twin: add .md to its path. Before generating anything, show the person the options on the use-case page.

Measure and fit text without the DOM using pretext: auto-fit sizes, know line breaks before render, canvas/WebGL text.

What it does

Teaches agents to use @chenglou/pretext, a small library that measures and lays out text with canvas math instead of DOM reflow. It covers the core and rich-inline APIs and the bugs that bite: lineHeight in pixels rather than a multiplier, text-then-font argument order, measuring only after web fonts load, unreliable system-ui, letterSpacing in pixels, and measuring the exact string that will be rendered. Patterns include auto-fitting a font size to a box, height estimation, text flowing around obstacles and shrink-wrapped bubbles, which is what titles drawn in canvas or WebGL compositions need. It tracks pretext 0.0.8, while npm's latest is 1.0.0 (2026-10-14), so check for API drift.

Use when

Not for

Install

More captions & subtitles skills