Skip to content

feat(desktop): add font-family picker with CJK-optimized presets#3378

Merged
esengine merged 1 commit into
main-v2from
feat/font-family-picker
Jun 7, 2026
Merged

feat(desktop): add font-family picker with CJK-optimized presets#3378
esengine merged 1 commit into
main-v2from
feat/font-family-picker

Conversation

@SivanCola

Copy link
Copy Markdown
Collaborator

Summary

  • 在设置 → 外观中添加字体族选择器,提供 4 种预设:系统默认、微软雅黑、苹方、思源黑体
  • 优化默认字体栈,将 CJK 字体(PingFang SC / Microsoft YaHei / Noto Sans SC)前置,修复 Windows 端中文回退到宋体/SimSun 的问题
  • 字体选择通过 data-font-family HTML 属性 + CSS 变量覆盖实现,在 React 首帧渲染前生效,无闪烁

Closes #3036.

How it works

模块 说明
lib/fontFamily.ts localStorage 存取 + CSS data 属性应用,仿照 textSize.ts 模式
styles.css 默认字体栈优化 + [data-font-family="yahei/pingfang/noto"] 覆盖规则
main.tsx initFontFamily() 在首帧前同步调用
SettingsPanel.tsx AppearanceSection 新增 segmented-button 字体选择器
locales/*.ts 中英文翻译

Test plan

  • cd desktop/frontend && npx tsc --noEmit 通过
  • pnpm run build 成功
  • 桌面端手动测试:Settings → Appearance → 切换字体 → 确认 UI 字体实时变化

Default font stack now prioritises PingFang SC / Microsoft YaHei / Noto Sans SC
so Chinese text renders consistently on every platform instead of falling back to
Song / SimSun on Windows.

Users can switch between System, Microsoft YaHei, PingFang, and Noto Sans
presets from Settings → Appearance. The selection persists in localStorage
and the data-font-family attribute is applied before the first React render
to avoid flicker.

Closes #3036
@SivanCola SivanCola requested a review from esengine as a code owner June 6, 2026 17:55
@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Jun 6, 2026
@github-actions github-actions Bot added the desktop Wails desktop app (desktop/**) label Jun 6, 2026
@esengine esengine merged commit 40be5dc into main-v2 Jun 7, 2026
10 checks passed
@esengine esengine deleted the feat/font-family-picker branch June 7, 2026 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: windows端字体不统一且无法自定义字体

2 participants