Skip to content

claude code vibe fix(export): render Monocraft font in minecraft mode PNG export#316

Open
functionstackx wants to merge 1 commit intomasterfrom
claude/issue-282-20260505-0421
Open

claude code vibe fix(export): render Monocraft font in minecraft mode PNG export#316
functionstackx wants to merge 1 commit intomasterfrom
claude/issue-282-20260505-0421

Conversation

@functionstackx
Copy link
Copy Markdown
Contributor

Fixes #282.

Root cause

useChartExport.ts pre-supplied fontEmbedCSS to html-to-image by raw-dumping every @font-face rule from document.styleSheets. Those rules contain stylesheet-relative font URLs (e.g. url("../media/Monocraft-...woff2")) that can't resolve once embedded inside an SVG data URL. The browser silently fell back to Arial — which in minecraft mode replaced Monocraft with sans-serif Arial, exactly the bug reported.

Fix

Drop the manual fontEmbedCSS and the now-unused getFontEmbedCSS() helper, letting html-to-image's built-in getWebFontCSS resolve each font URL against its parent stylesheet's href and inline the woff2 as a data URL.

Verification

  • pnpm typecheck
  • pnpm lint
  • packages/app unit tests: 1731/1731 pass
  • Playwright MCP: PNG export verified across minecraft/dark/light themes

Generated with Claude Code

Drop the manual `fontEmbedCSS` and the `getFontEmbedCSS()` helper so
html-to-image's built-in `getWebFontCSS` runs instead. The previous code
raw-dumped every `@font-face` rule from `document.styleSheets`, but those
rules contain stylesheet-relative font URLs (e.g.
`url("../media/Monocraft-...woff2")`) that can't resolve once embedded
inside an SVG data URL. The browser silently fell back to Arial — which
in minecraft mode replaced the pixel-perfect Monocraft with regular
sans-serif Arial, exactly the bug in #282.

`getWebFontCSS` walks the cloned subtree, resolves each font URL against
its parent stylesheet's href, and inlines the woff2 as a data URL — so
Monocraft renders correctly in the exported PNG.

Fixes #282

Co-authored-by: functionstackx <functionstackx@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
inferencemax-app Ready Ready Preview, Comment May 5, 2026 4:49am

Request Review

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.

export png minecraft mode isnt displayed properly

1 participant