Skip to content

feat: Pretext SVG text rendering for pixel-perfect typography - #44

Merged
gregmeyer merged 1 commit into
mainfrom
feat/pretext-svg-text
Mar 30, 2026
Merged

feat: Pretext SVG text rendering for pixel-perfect typography#44
gregmeyer merged 1 commit into
mainfrom
feat/pretext-svg-text

Conversation

@gregmeyer

Copy link
Copy Markdown
Owner

Summary

  • Integrates @chenglou/pretext as an optional text rendering engine loaded via CDN into the Playwright page context
  • When text_render: "pretext" is passed, headline and subheadline text is measured with Pretext's layout calculations and rendered as SVG <text> elements instead of CSS-styled HTML divs
  • Default behavior (text_render: "css") is completely unchanged — this is an opt-in feature flag
  • Pilot implementation on the hero layout; other layouts can adopt the pretext_slot() helper incrementally

What changed

File Change
pretext_utils.py New — CDN loader + DOMContentLoaded bootstrap script
pretext_renderer.py Newpretext_slot() markup helper + svg_text_block() for static SVG
base.py use_pretext flag + script injection in _wrap_html()
export.py Waits for __pretextReady before Playwright screenshot
modern_hero.py Headline + subheadline conditionally use pretext-slot
color_scheme.py fill: currentColor rule for SVG text theme inheritance
mcp_server.py text_render param on generate_graphic tool
rendering.py + cli.py + cli_create.py Plumbing for the flag

Test plan

  • CSS mode regression: --theme arcade hero renders identically to before
  • Pretext mode: --text-render pretext --theme arcade hero renders with SVG text
  • All 16 smoke tests pass
  • Open HTML output in browser — Pretext bootstrap runs client-side
  • Test with multiple themes (dark, warm, corporate) in pretext mode

🤖 Generated with Claude Code

Integrates @chenglou/pretext as an optional text rendering engine.
When enabled, headline and subheadline text is measured with Pretext's
layout calculations and rendered as SVG <text> elements instead of
CSS-styled HTML divs, giving pixel-perfect control over line breaking
and text positioning.

- New pretext_utils.py with CDN loader and bootstrap script
- New pretext_renderer.py with slot markup and SVG text helpers
- BaseGenerator gains use_pretext flag, injects bootstrap in _wrap_html()
- Export pipeline waits for __pretextReady before screenshot
- Hero layout pilot: headline + subheadline use pretext-slot when enabled
- Theme integration via fill:currentColor inheriting from parent CSS
- MCP tool gains text_render param ("css" | "pretext"), default "css"
- CLI gains --text-render flag on create command

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gregmeyer
gregmeyer merged commit 6cd7819 into main Mar 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant