Fix spaced-out terminal text on Windows: put a Latin monospace before the CJK fallbacks

On Windows none of the Mac/Linux monospace fonts in the stack are
installed, so the first font that resolves is Malgun Gothic (the Windows
Korean UI font). xterm.js sizes its character cell from that font's
advance width, and Malgun Gothic advances Latin glyphs in a full-width
CJK cell — doubling every cell and rendering the whole terminal (and the
sidepanel mono UI) as spaced-out text.

Insert Consolas (present on every Windows install) and the Cascadia
faces ahead of the CJK fonts in both the xterm fontFamily and the
--font-mono CSS var. The CJK fonts stay last for actual CJK coverage.
No bundled font, no user install needed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GKj8Nr8T4GvryTcWBJRMyC
This commit is contained in:
Yotam 2026-07-17 11:25:45 +09:00
parent a3259400a3
commit 3cffb782c2
2 changed files with 10 additions and 2 deletions

View File

@ -391,7 +391,13 @@
function ensureXterm() {
if (term) return;
term = new Terminal({
fontFamily: '"JetBrains Mono", "SF Mono", Menlo, "Noto Sans Mono CJK KR", "Malgun Gothic", monospace',
// Windows Latin monospace (Consolas, always present; Cascadia ships with Terminal/VS)
// MUST precede the CJK fallbacks: xterm sizes the character cell from the first
// resolved font's advance width, and Malgun Gothic (the Windows Korean UI font, the
// first that resolves here when the Mac/Linux fonts are absent) advances Latin glyphs
// in a full-width CJK cell — doubling every cell into spaced-out text. The CJK fonts
// stay last for actual CJK glyph coverage.
fontFamily: '"JetBrains Mono", "SF Mono", "Cascadia Mono", "Cascadia Code", Consolas, Menlo, "DejaVu Sans Mono", "Noto Sans Mono CJK KR", "Malgun Gothic", monospace',
fontSize: 13,
theme: { background: '#0a0a0a', foreground: '#e5e5e5' },
cursorBlink: true,

View File

@ -38,7 +38,9 @@
/* Typography */
--font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
--font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', 'Noto Sans Mono CJK KR', 'Malgun Gothic', monospace;
/* Consolas (always on Windows) before the CJK fallbacks else Latin text resolves to
Malgun Gothic and renders full-width/spaced-out. Same fix as the xterm fontFamily. */
--font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Mono', 'Cascadia Code', Consolas, 'DejaVu Sans Mono', 'Noto Sans Mono CJK KR', 'Malgun Gothic', monospace;
/* Radius */
--radius-sm: 4px;