# 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.

- **Type:** [Guide](https://skills.varg.ai/guides.md) · [Captions & subtitles](https://skills.varg.ai/browse/skills/captions.md)
- **Slug:** `pretext-yaniv-golan`
- **Status:** beta
- **Publisher:** Yaniv Golan (community)
- **License:** MIT
- **Source:** https://github.com/yaniv-golan/pretext-skill/tree/main/pretext/skills/pretext
- **Works in:** Claude Code, Claude.ai, Codex, Cursor, ChatGPT
- **Requires:** @chenglou/pretext from npm, A browser or OffscreenCanvas with Intl.Segmenter (in Node, node-canvas works but accuracy is not guaranteed)
- **Cost:** Free — open-source, runs locally
- **Adoption:** 19 installs, 15 GitHub stars (skills.sh, 2026-10-26)

## 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

- Auto-fit a font size so a title fits a box or N lines
- Know line count and height before rendering text
- Flow text around shapes or across variable-width lines
- Measure text for canvas, SVG or WebGL rendering

## Not for

- CSS-only text layout or generic typography advice (the skill's own exclusion)
- Structured HTML content: pretext measures plain text strings

## Install

- Claude Code: `/plugin marketplace add yaniv-golan/pretext-skill && /plugin install pretext@pretext-marketplace`
- Codex: `$skill-installer https://github.com/yaniv-golan/pretext-skill`
- Cursor: `npx skills add yaniv-golan/pretext-skill`

## More captions & subtitles skills

- [3D Camera Captions](https://skills.varg.ai/skills/hyperframes-camera-3d-captions.md): Captions that live in 3D around a talking head: the camera flies through the words, heroes pass behind the speaker.
- [Remotion Captions](https://skills.varg.ai/skills/remotion-captions.md): Transcribe speech and burn in animated captions with Remotion, or import an existing SRT file.
- [ElevenLabs Speech to Text](https://skills.varg.ai/skills/elevenlabs-speech-to-text.md): Transcribe audio and video with word timestamps, speaker labels and keyterms, ready for subtitles.
- [ElevenLabs Speech to Text (inference.sh)](https://skills.varg.ai/skills/inference-sh-elevenlabs-stt.md): Transcribe audio with ElevenLabs Scribe, speaker diarization and forced alignment, via inference.sh.
- [Speech to Text](https://skills.varg.ai/skills/inference-sh-speech-to-text.md): Transcribe audio with ElevenLabs Scribe v2 or Whisper V3 Large, with timestamps and speaker labels.
- [Chinese Font Selector](https://skills.varg.ai/skills/chinese-font-selector.md): Pick Chinese fonts by license tier first (OFL, vendor-free, avoid), then by scene and mood, with Latin pairings.
