Pretext Layout
by Roy Yuen
High-performance browser-based text layout and measurement for virtualization, canvas, and layout-heavy applications.
- Measure text dimensions without triggering DOM layout thrashing
- Calculate multiline text height for smooth dynamic height virtuallization ops
- Render complex text layouts on HTML canvas with high-performance metrics
Free
Included in download
- Downloadable skill package
- Works with Public, pretext
- 1 permission declared
See it in action
You say
Measure the 200px width layout for "Hello World" using 24px line-height, then provide the per-line ranges and performance stats after ensuring fonts are loaded.
Your agent does
Prepared handle cached for "Hello World". Height: 48px at 200px width. Line 1: "Hello " (0-6) Line 2: "World" (6-11) Performance: <0.1ms layout time. Verified against document.fonts.ready status.
Pretext Layout
by Roy Yuen
High-performance browser-based text layout and measurement for virtualization, canvas, and layout-heavy applications.
Free
Included in download
- Downloadable skill package
- Works with Public, pretext
- 1 permission declared
- Instant install
See it in action
You say
Measure the 200px width layout for "Hello World" using 24px line-height, then provide the per-line ranges and performance stats after ensuring fonts are loaded.
Your agent does
Prepared handle cached for "Hello World". Height: 48px at 200px width. Line 1: "Hello " (0-6) Line 2: "World" (6-11) Performance: <0.1ms layout time. Verified against document.fonts.ready status.
About This Skill
Efficient Text Measurement & Layout
The Pretext Layout skill enables AI agents to integrate and debug high-performance multiline text measurement using the @chenglou/pretext library. It solves the common frontend performance bottleneck of "layout thrashing" by replacing slow DOM-based height probes with a fast, browser-native API approach.
What it does
This skill provides developers with a structured methodology for measuring text width and height without repeated DOM reflows. It supports high-level block height calculation for virtualization and low-level line-by-line geometry for custom Canvas or SVG rendering workflows. It handles complex edge cases including web fonts, emoji, and bidirectional text.
Supported Workflows
- Virtualization: Pre-measure list item heights for smooth scroll anchoring.
- Custom Rendering: Extract per-line ranges for manual drawing in Canvas or SVG.
- Responsive Design: Rapidly recalculate layouts during window resize events on the hot path.
- Debugging: Verify layout accuracy against real-world CSS styles and font loading states.
Why use this skill?
While a general AI can write basic JavaScript, this skill understands the specific lifecycle of the Pretext library—such as partitioning the expensive "prepare" phase from the lightweight "layout" phase. It ensures your agent correctly manages browser-only runtime constraints, font loading promises, and locale-specific white-space behaviors to prevent layout shifts and flickering.
Use Cases
- Measure text dimensions without triggering DOM layout thrashing
- Calculate multiline text height for smooth dynamic height virtuallization ops
- Render complex text layouts on HTML canvas with high-performance metrics
- Audit text overflow and wrapping logic for layout-heavy applications
Known Limitations
• Requires a browser environment or OffscreenCanvas; no native Node.js support. • Does not support complex CSS properties like 'float', 'flex', or 'letter-spacing'.
How to Install
mkdir -p ~/.claude/skills && curl -sL https://www.agensi.io/api/install/pretext-layout -o /tmp/pretext-layout.zip && unzip -o /tmp/pretext-layout.zip -d ~/.claude/skills && rm /tmp/pretext-layout.zipFree skills install directly. Paid skills require purchase - use the download button above after buying.
Reviews
No reviews yet - be the first to share your experience.
Only users who have downloaded or purchased this skill can leave a review.
No reviews yet - be the first to share your experience.
Only users who have downloaded or purchased this skill can leave a review.
Security Scanned
Passed automated security review
Permissions
File Scopes
Public, sanitized export of the `pretext-layout` skill for browser-first `@chenglou/pretext` integration npm install @chenglou/pretext
Frequently Asked Questions
Learn More About AI Agent Skills
More Premium Skills
cinematic-sites
Turn any basic business URL into a high-end cinematic landing page with AI-generated 4K assets and GSAP animations.
designing-hybrid-context-layers
Architects the right retrieval strategy for every query — teaching your agent when to use RAG, a knowledge graph, or a temporal index instead of defaulting to vector search for everything.
World-Class Site & App Design
Every AI-built UI looks generic and templated. This skill teaches your agent to actually match the design to the project, the industry, and the audience.
ai-automation-qa-pack
Professional QA & UAT documentation generator for AI automation agencies and complex agent deployments.