本文へ移動
cccskills
無料GitHub で公開

pretext

Create text effects impossible with CSS alone — kinetic typography, flowing text around animated obstacles, calligrams, shrinkwrap chat bubbles, typographic ASCII art, glyph path animation, variable font waves, glyph morphing, illuminated manuscripts. Single-file HTML output, zero build step. Powered by @chenglou/pretext + opentype.js. Triggers on text effects, kinetic typography, text animation, calligram, glyph art, typography art.

インストール方法を見る

含まれるファイル(21)

  • SKILL.md13.8 KB
  • assets/templates/calligram.html9.0 KB
  • assets/templates/editorial-engine.html10.7 KB
  • assets/templates/glyph-morph.html23.7 KB
  • assets/templates/glyph-paths.html14.4 KB
  • assets/templates/height-prediction.html5.6 KB
  • assets/templates/letterbox-gallery.html10.6 KB
  • assets/templates/outline-calligrams.html19.0 KB
  • assets/templates/play-core-ascii.html8.5 KB
  • assets/templates/shrinkwrap-bubbles.html6.0 KB
  • assets/templates/text-on-path.html18.5 KB
  • assets/templates/typographic-ascii.html7.0 KB
  • assets/templates/variable-font.html17.1 KB
  • README.md1.6 KB
  • references/api-reference.md3.7 KB
  • references/calligram-shapes.md18.4 KB
  • references/obstacle-routing.md12.2 KB
  • references/opentype-integration.md7.6 KB
  • references/play-core-rendering.md9.5 KB
  • references/typographic-ascii.md4.0 KB
  • scripts/validate_pretext.py8.6 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Pretext Text Effects

Generate browser pages powered by Pretext (@chenglou/pretext)—a pure-arithmetic text measurement library that bypasses DOM layout reflow entirely. Pretext measures text with proportional font precision using canvas measureText, enabling effects impossible with CSS alone.

Companion library: opentype.js (opentype.js@1.3.4) — direct font binary parsing for per-glyph SVG path rendering, Bezier control point access, kerning tables, and variable font axes. Pretext handles line breaking; opentype.js handles what happens inside each glyph. Together they unlock effects neither can achieve alone.

Output is always a single self-contained HTML file. No build step, no framework, runs in any modern browser.

Quick Start

Describe a text effect. Claude picks the right Pretext pattern and generates a complete HTML file.

Examples:

  • /pretext fluid smoke ASCII art with gold characters on black
  • /pretext chat bubbles that shrinkwrap tighter than CSS
  • /pretext calligram — the word "ocean" shaped like a wave
  • /pretext editorial layout with text flowing around draggable circles
  • /pretext masonry grid of shower thoughts with instant height prediction
  • /pretext glyph path art — SVG letterforms with stroke animation
  • /pretext animated dragon cursor that pushes text aside as it moves
  • /pretext illuminated manuscript with live vine growth reflow
  • /pretext variable font wave — per-character weight animation
  • /pretext glyph morph — letterform interpolation from A to Z
  • /pretext letterbox gallery of "BEACON" in Playfair Display italic on dark background
  • /pretext glyph-mask calligram — letter R filled with lorem ipsum in Georgia

Do NOT Use This Skill When

  • Simple CSS text-shadow, text-stroke, or gradient text effects
  • CSS Shapes level 1 (shape-outside on floated elements) for static layouts
  • Basic @keyframes text animation (fade, slide, typewriter)
  • Monospace ASCII art (no proportional measurement needed)
  • SVG <text> without per-glyph control
  • Rich text editing (contenteditable, ProseMirror, TipTap)
  • PDF generation or markdown rendering

These are all achievable without Pretext or opentype.js.

Effect Categories

Pretext-Only Effects

CategoryPretext APIs UsedWhen to Use
Height Predictionprepare + layoutAccordion, masonry, virtualized lists — anywhere you need text height without DOM reads
ShrinkwrapwalkLineRanges + binary searchChat bubbles, tooltips, labels — finding the exact tightest width for multiline text
Obstacle RoutinglayoutNextLine (variable width)Text flowing around images, logos, draggable orbs — editorial layouts
Animated ObstacleslayoutNextLine + carveTextLineSlotsMoving creatures/orbs that displace text at 60fps — slot-carving fills BOTH sides of obstacle
Typographic ASCIIprepareWithSegments (char measurement)Fluid simulations, 3D wireframes, particle systems rendered as proportional characters
CalligramsprepareWithSegments + SDFWords rendered as shapes using their own letters — hearts, stars, spirals
Glyph-Mask CalligramsCanvas measureText + getImageData pixel maskAny font glyph as calligram shape — fill a large letter with small text using pixel-mask technique (no SDF needed, no opentype.js)
Letterbox GalleryGlyph-mask + per-letter <canvas> gridEach character in a string gets its own canvas with text fill, cursor displacement, and independent interaction
Multi-column EditorialAll rich APIs combinedMagazine-style layouts with headline fitting, pull quotes, drop caps, column flow

Pretext + opentype.js Effects

CategoryAPIs UsedWhen to Use
Glyph Path Artopentype glyph.getPath()SVG letterforms with fill/stroke/control point modes, stroke-draw animation
Text on Pathopentype getPath() + arc-length samplingPer-glyph placement along Bezier curves with tangent rotation
Variable Font Animationopentype font.tables.fvar.axes + CSS font-variation-settingsPer-character weight/width waves, breathe, ripple, cascade effects
Glyph Morphingopentype paths + flubber interpolate()Letterform interpolation between glyphs with contour-aware morphing
Outline CalligramsPretext layoutNextLine + opentype glyph maskText fills the interior of a large glyph's actual contour (not SDF approximation)
Illuminated ManuscriptAll Pretext + opentype combinedLiving medieval pages: wet ink, vine reflow, capital inflation, aging, erasure poetry

Concept-to-Effect

Every design decision derives from the concept. Do not default—derive.

Choose the API tier from the effect complexity:

  • Static height only → prepare() + layout() (fastest, opaque)
  • Need line text/positions → prepareWithSegments() + layoutWithLines()
  • Need per-line width variation → layoutNextLine() (iterator, variable width per line)
  • Need aggregate geometry without strings → walkLineRanges() (no string materialization)
  • Need individual character widths → prepareWithSegments() on single chars

Choose the rendering target from the output type:

  • DOM elements (.line { position: absolute }) → editorial, accordion, masonry
  • Canvas 2D (ctx.fillText) → calligrams, some ASCII art
  • HTML spans with inline styles → typographic ASCII (weight/style/opacity per character)

Architecture

Pretext CDN → prepare/prepareWithSegments → layout/layoutNextLine → line positions
                                                                          ↓
opentype.js CDN → font.parse(buffer) → glyph.getPath() ──────────> SVG <path> elements
                                                                          ↓
                                                              requestAnimationFrame (if animated)
                                                              resize handler (always)

Two-library split: Pretext decides WHERE text goes (line breaking, obstacle routing). opentype.js decides HOW each glyph looks (SVG paths, Bezier curves, contour data). Use Pretext alone for DOM-positioned text. Add opentype.js when you need per-glyph SVG rendering, path animation, or glyph contour access.

CDN Imports

<!-- Pretext (ESM, required) -->
<script type="module">
import { prepare, layout, prepareWithSegments, layoutWithLines, walkLineRanges, layoutNextLine, clearCache } from 'https://esm.sh/@chenglou/pretext@0.0.2'
</script>

<!-- opentype.js (UMD, optional — only for glyph path effects) -->
<script src="https://cdn.jsdelivr.net/npm/opentype.js@1.3.4/dist/opentype.min.js"></script>

<!-- Font binary for opentype.js (Inter .woff — confirmed working) -->
<!-- const FONT_URL = 'https://cdn.jsdelivr.net/npm/@fontsource/inter@5.0.8/files/inter-latin-400-normal.woff' -->

<!-- flubber (optional — only for glyph morphing) -->
<!-- <script src="https://cdn.jsdelivr.net/npm/flubber@0.4.2/build/flubber.min.js"></script> -->

Import only the functions you need. Pin the version. opentype.js cannot parse .woff2 — use .woff or .ttf only.

Composition Parameters

All Effects

ParameterDefaultNotes
Font'18px Georgia, Palatino, serif'Never use system-ui — unreliable with Pretext
Line height28 (px)Must match CSS line-height for height prediction
Background#08080e or #f5f1eaDark or light — never pure black #000

Typographic ASCII

ParameterRangeDefault
Font size10–18px14
Font familyserif preferredGeorgia, Palatino, "Times New Roman", serif
Charsetprintable ASCII .,:;!+-=*#@%&a-zA-Z0-9
Weights1–3[300, 500, 800]
Stylesnormal, italicboth
Opacity levels6–1010 CSS classes .a1–.a10

Calligrams

ParameterRangeDefault
Canvas size200–800px400
Char density6–24px14
Shapesheart, circle, star, wave, spiralheart
Animationspring entrancespringK: 0.08, damping: 0.75

Editorial / Obstacle Routing

ParameterRangeDefault
Columns1–42
Column gap20–60px40
Gutter30–80px48
Orb count1–65
Orb radius30–120px65–110
hPad (horizontal padding around obstacle)8–20px14
vPad (vertical padding)2–8px4
MIN_SLOT_WIDTH30–80px50

opentype.js — Glyph Path Effects

ParameterRangeDefault
Font URL.woff or .ttf only@fontsource/inter@5.0.8
Font size10–200px14 (body), 42 (display)
Stroke-dashoffset draw speed30–150ms per glyph80ms
Wet ink amplitude0.5–3px1.8
Wet ink decay (tau)800–3000ms1500
Glyph morph easinglinear, ease-in-out, springease-in-out

Glyph-Mask Calligrams / Letterbox Gallery

ParameterRangeDefault
Canvas size (per letter)200–1000px500
Fill font size8–24px11
Fill modelself, lorem, alphabet, customlorem
Fill caseupper, lower, mixedupper
Fill columns1–41
Grid columns (gallery)2–63
Cursor displacement radius50–250px100
Cursor displacement force10–5035
Displacement damping0.85–0.980.94

opentype.js + flubber — Glyph Morphing

ParameterRangeDefault
Morph duration300–2000ms800
Flubber maxSegmentLength5–2010
Contour strategyequal, 1-to-many, many-to-1auto-detect

References

Working on...Load
Full API surface, types, caveatsreferences/api-reference.md
Typographic palette, brightness, ASCII gridreferences/typographic-ascii.md
Column flow, obstacles, headline fitting, slot-carving, animated physicsreferences/obstacle-routing.md
SDF shapes, proportional spacing, animationreferences/calligram-shapes.md
Pixel-mask technique, glyph-mask calligrams, cursor displacement, letterbox galleryreferences/calligram-shapes.md (Pixel-Mask section)
opentype.js + Pretext integration patternsreferences/opentype-integration.md
Working accordion templateassets/templates/height-prediction.html
Working bubbles templateassets/templates/shrinkwrap-bubbles.html
Working editorial templateassets/templates/editorial-engine.html
Working ASCII art templateassets/templates/typographic-ascii.html
Working calligram templateassets/templates/calligram.html
Working letterbox gallery templateassets/templates/letterbox-gallery.html
GlyphKit demos (6 working demos, local)~/Desktop/Programming/glyphkit/demos/ (machine-specific)

Anti-Patterns

Pretext

  • Never use system-ui as font — canvas and DOM can resolve different fonts on macOS
  • Never use React/Vue/framework — vanilla JS + HTML only
  • Never omit <meta name="viewport"> — proportional measurement depends on correct device pixels
  • Never use setInterval for animation — always requestAnimationFrame
  • Never skip the resize handler — text layout depends on container width
  • Never call prepare() inside the animation loop — it's the expensive one-time pass. Cache it.
  • Never omit document.fonts.ready.then(...) — measure after fonts load, not before
  • Never use pure black (#000000) — use rich off-blacks (#06060a, #08080e, #0a0a0c)
  • Never build line strings when you only need geometry — use walkLineRanges instead of layoutWithLines
  • Never position text with CSS flow — use position: absolute and place lines from Pretext coordinates
  • Never pick one side of an obstacle when the obstacle is in the middle — use carveTextLineSlots to fill both sides
  • Never create/destroy DOM elements per frame — use element pooling (syncPool)

opentype.js

  • Never use .woff2 files — opentype.js cannot parse them. Use .woff or .ttf only
  • Never use opentype.load() — use fetch().then(r => r.arrayBuffer()).then(opentype.parse) for better error handling
  • Never render glyphs at absolute positions then try to move them — render at (0,0) and position via <g transform="translate(x,y)">
  • Never forget font.unitsPerEm — the scale factor is fontSize / font.unitsPerEm
  • Never call glyph.getPath() inside a tight loop without caching — cache the pathData string, regenerate only when position changes
  • Never skip kerning — always check font.getKerningValue(glyph, nextGlyph) * scale between adjacent glyphs
  • Never use Google Fonts TTF CDN URLs (they return 404 for programmatic access) — use @fontsource via jsdelivr

Post-Generation QA

python3 ~/.claude/skills/pretext/scripts/validate_pretext.py output.html

Checklist:

  1. ESM import from esm.sh/@chenglou/pretext present
  2. <script type="module"> tag
  3. Named font declaration (no system-ui)
  4. <meta name="viewport"> present
  5. Window resize handler
  6. document.fonts.ready awaited before measurement
  7. requestAnimationFrame loop (for animated effects)
  8. Touch event handlers (for interactive effects)
  9. No setInterval for animation
  10. No framework imports

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Search academic papers, build literature reviews, and synthesize research findings — combines Exa MCP (research_paper category, arxiv filtering) with arxiv-mcp-server for paper discovery, download, and deep analysis. Triggers on academic paper, literature review, research synthesis, arxiv, find papers, scholarly search.

日本語の概要は準備中です。原文の説明を表示しています。

tdimino/claude-code-minoan412026年9月28日 更新

Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

日本語の概要は準備中です。原文の説明を表示しています。

tdimino/claude-code-minoan412026年9月28日 更新

This skill should be used when creating, auditing, or maintaining AGENTS.md files and Codex CLI configuration for any project—including initializing AGENTS.md for cross-agent compatibility (Codex, Cursor, Copilot, Devin, Jules, Amp, Gemini CLI), generating config.toml or .rules files, scaffolding .agents/skills/, converting CLAUDE.md to AGENTS.md, or auditing existing agent configs for bloat and staleness. Complementary to codex-orchestrator (which executes subagents; this skill creates the config files they consume).

日本語の概要は準備中です。原文の説明を表示しています。

tdimino/claude-code-minoan412026年9月28日 更新

Academic research skill for Biblical Hebrew, Semitic linguistics, cuneiform studies, and comparative Ancient Near Eastern research. Provides Sefaria API for Hebrew Bible, CDLI/ORACC for cuneiform databases, and web discovery via Omnisearch, Exa, Firecrawl, and Obscura for finding scholarly sources across JSTOR, Perseus, Persée, Google Scholar, and academia.edu. Triggers on Hebrew quotes, cuneiform, Sefaria, ANE research, Minoan, search for scholarship, find papers, literature review, scholarly search, academic search, Genesis/Tehom, Ugaritic, Talmudic sources, extract from PDF, OCR academic.

日本語の概要は準備中です。原文の説明を表示しています。

tdimino/claude-code-minoan412026年9月28日 更新

Build comprehensive ARCHITECTURE.md files following matklad's canonical guidelines — bird's-eye views, ASCII/Mermaid diagrams, codemaps, invariants, and layer boundaries. Triggers on document the architecture, create ARCHITECTURE.md, map this codebase, architectural overview.

日本語の概要は準備中です。原文の説明を表示しています。

tdimino/claude-code-minoan412026年9月28日 更新

Generate physically-based atmospheric scattering shaders — sky domes, planetary atmospheres, LUT-optimized pipelines, depth-aware post-processing. Four modes — sky-dome, atmosphere-post, planet, lut. Triggers on atmospheric scattering, sky shader, sunset rendering, planet atmosphere, Rayleigh scattering, Mie scattering, volumetric sky, sky dome, atmosphere post-processing, aerial perspective, transmittance LUT, sky rendering, realistic sky, planetary rendering.

日本語の概要は準備中です。原文の説明を表示しています。

tdimino/claude-code-minoan412026年9月28日 更新

tdimino のスキルをすべて見る

このスキルの問題を報告する