Skip to content

claude code vibe fix(export): render Monocraft font in minecraft mode PNG export / 修复 minecraft 模式下 PNG 导出的 Monocraft 字体渲染#316

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

claude code vibe fix(export): render Monocraft font in minecraft mode PNG export / 修复 minecraft 模式下 PNG 导出的 Monocraft 字体渲染#316
functionstackx wants to merge 1 commit into
masterfrom
claude/issue-282-20260505-0421

Conversation

@functionstackx

@functionstackx functionstackx commented May 5, 2026

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

中文说明

修复 minecraft 模式下 PNG 导出时 Monocraft 字体无法渲染的问题。根因是 useChartExport.ts 手动提取的 @font-face 规则包含相对路径的字体 URL,嵌入 SVG data URL 后无法解析,浏览器静默回退到 Arial。修复方案:移除手动字体嵌入,改用 html-to-image 内置的 getWebFontCSS,自动解析并内联字体文件。

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

vercel Bot commented May 5, 2026

Copy link
Copy Markdown

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

@functionstackx functionstackx changed the title claude code vibe fix(export): render Monocraft font in minecraft mode PNG export claude code vibe fix(export): render Monocraft font in minecraft mode PNG export / 修复 minecraft 模式下 PNG 导出的 Monocraft 字体渲染 Jul 4, 2026
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