Skip to content

fix: add CJK font fallback for terminal#4

Open
SamCuipogobongo wants to merge 1 commit intodreamlonglll:mainfrom
SamCuipogobongo:fix/cjk-font-fallback
Open

fix: add CJK font fallback for terminal#4
SamCuipogobongo wants to merge 1 commit intodreamlonglll:mainfrom
SamCuipogobongo:fix/cjk-font-fallback

Conversation

@SamCuipogobongo
Copy link
Copy Markdown

Summary

  • Add Sarasa Term SC (更纱黑体) to the fontFamily fallback chain in xterm.js terminal config
  • Without a monospace CJK font, Chinese characters render as garbled glyphs in the WebGL renderer
  • Sarasa Term SC is designed for terminals — CJK chars are exactly 2x ASCII width, aligning with the WebGL cell grid

Test plan

  • Install Sarasa Term SC font (e.g. brew install --cask font-sarasa-gothic)
  • Open Mini-Term terminal and verify Chinese characters render correctly
  • Verify English/ASCII characters are unaffected

🤖 Generated with Claude Code

Add 'Sarasa Term SC' (等宽 CJK 字体) to the fontFamily fallback chain.
Without a proper monospace CJK font, Chinese characters render as garbled
glyphs in the WebGL renderer because the default monospace fonts lack
CJK coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dreamlonglll
Copy link
Copy Markdown
Owner

感谢你的贡献!CJK 字体回退的修复方向是正确的,注释从"Canvas"改为"DOM"也是准确的(项目没有 @xterm/addon-canvas 依赖)。

不过这个 PR 有一个比较大的问题:分支基于旧版本 (v0.1.9),没有 rebase 到当前 main (v0.2.2),导致合并后会回退最近多个版本的功能,包括:

  • 主题系统(浅色/深色主题、系统主题跟随)
  • Git History 分支显示功能
  • 多层级仓库递归扫描与树形展示
  • gitignore 文件灰色显示
  • 快捷键设置页
  • 关闭窗口时多项目布局保存
  • 等等...

请基于最新的 main 分支重新创建 PR,仅包含 src/utils/terminalCache.ts 中的字体和注释修改。

另外一个小建议:Sarasa Term SC 不是系统预装字体,可以考虑在回退链中补充更多常见的 CJK 等宽字体,例如:

fontFamily: "'JetBrains Mono', 'Cascadia Code', Consolas, 'Sarasa Term SC', 'Microsoft YaHei Mono', 'Noto Sans Mono CJK SC', monospace"

这样在用户没有安装更纱黑体的情况下也能有更好的 CJK 字符显示效果。期待你的更新 🙌

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.

2 participants