Pretext Layout

    2

    High-performance browser-based text layout and measurement for virtualization, canvas, and layout-heavy applications.

    Free

    40 uses5.0 (1 review)

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    pretext-layout

    Example session with this skill installed

    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.

    • Read your context and instructions
    • Compiled the pretext-layout

    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.

    Connects securely to your tools. The creator never sees your data.

    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.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Frontend & Web Apps.

    • 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 use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    5.0
    1 review
    5
    1
    4
    0
    3
    0
    2
    0
    1
    0

    This skill has been used 40 times.

    Trust & safety

    Security scan

    Security scan passed 7 months ago

    • Free with an Agensi account

    Permissions

    Terminal / Shell
    Listed7 months ago

    What's inside

    Frequently Asked Questions

    This skill helps AI agents implement high-performance text measurement using the @chenglou/pretext library, solving "layout thrashing" issues in virtualization and canvas-based applications by avoiding slow DOM-based probes.

    The skill is designed for use within browser environments and is compatible with any AI agent that supports JavaScript/TypeScript development workflows and modern web APIs.

    You receive a specialized AI agent capability that understands the Pretext library's lifecycle, including optimizing the 'prepare' phase and handling font-loading states for accurate layout calculations.

    Yes, it is specifically designed to handle complex text scenarios including web fonts, emoji rendering, and bidirectional (RTL/LTR) text to ensure accurate geometry across different locales.

    This skill is optimized for high-performance frontend workflows, specifically helping agents pre-calculate item heights for smooth virtualization and extracting line-level coordinates for custom Canvas or SVG rendering.

    New in Frontend & Web Apps

    Free