Skip to content

🐛 fix(blog): render OG fonts without network access - #84

Draft
zrr1999 wants to merge 1 commit into
codex/typescript-compatibility-guardfrom
codex/offline-og-fonts
Draft

zrr1999 wants to merge 1 commit into
codex/typescript-compatibility-guardfrom
codex/offline-og-fonts

Conversation

@zrr1999

@zrr1999 zrr1999 commented Oct 4, 2026

Copy link
Copy Markdown
Owner

动机

OG 图片构建为每张图片请求 Google Fonts 的 CSS 和字体资源。字体服务或云端网络不可用时,博客构建会失败;中文标题也需要完整的中文字体支持。

解决方案

  • 从锁定的 npm 字体包读取 IBM Plex Mono 的普通与粗体,保留拉丁文字的原有字体。
  • 添加本地思源黑体作为中文后备字体,按实际文本生成普通与粗体子集;源字体在构建进程内只读取一次。
  • 删除联网字体加载器,让站点与文章 OG 模板使用同一离线入口。
  • 在构建 CI 中运行 Vite+ 测试:禁止 fetch 后仍能将中英文普通/粗体文本渲染为 SVG 和 PNG。

说明

依赖 #83,并通过 #83 依赖 #82。迁移沿用 Spore 的本地字体与子集方案;中文后备字体会改善中文标题的显示。

验证:vp install --frozen-lockfile、vp check --fix、vp test run、三个网站的 vp run build、prek run --all-files 与真实提交钩子均通过。博客仍构建 109 页并生成 Pagefind 索引。字体包及子集工具作为构建依赖写入 lockfile。

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
zrr-website-slides 791f97a Commit Preview URL

Branch Preview URL
Oct 04 2026, 12:38 AM

@gitar-bot

gitar-bot Bot commented Oct 4, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Replaces network font fetching with local font loading and subset rendering.

Fixes OG image rendering to work without network access by loading IBM Plex Mono from locked npm packages and adding Noto Sans SC as a fallback for Chinese characters, with font subsetting generated at build time. Build-time tests now run with fetch disabled to verify SVG and PNG rendering for both Latin and Chinese text.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
zrr-website-blog 791f97a Commit Preview URL

Branch Preview URL
Oct 04 2026, 12:39 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
zrr-website-root 791f97a Commit Preview URL

Branch Preview URL
Oct 04 2026, 12:40 AM

This branch has not been deployed

No deployments
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