Skip to content

[Bug] Latin/ASCII characters render as corrupted glyphs when mixed with Chinese text #3570

Closed as duplicate

Description

@TerryGSL

Bug Description
Latin characters (English letters, punctuation, numbers) are rendering as severely corrupted, unreadable glyphs when displayed alongside Chinese (CJK) characters in the UI. Chinese characters themselves render correctly, but all ASCII content appears broken — showing distorted, overlapping symbol fragments instead of legible text.
This appears to be a font fallback or glyph rendering issue, likely triggered when the system attempts to render mixed CJK + Latin content using an incompatible or missing font.
Steps to Reproduce

Open the application in an environment where the system locale or primary font is set to a CJK language (e.g., Simplified Chinese).
Navigate to any panel or view that displays mixed Chinese and English/ASCII text (e.g., terminal output, dialog components, task lists).
Observe that Latin characters and numbers are rendered as garbled, corrupted symbols while Chinese characters display normally.

Expected Behavior
All characters — both Chinese (CJK) and Latin/ASCII — should render clearly and legibly using appropriate font fallback chains.
Actual Behavior
Latin/ASCII characters are displayed as distorted, overlapping glyph fragments (see screenshot). Chinese characters are unaffected.
Screenshots
Image

Activity

  1. github-actions commented on Apr 19, 2026

    @github-actions
    Contributor

    Triage notes: I investigated this but could not write a reproduction test that is meaningful in bun:test.

    Why a unit test isn't feasible

    The bug is a visual/browser-level rendering failure that depends on runtime conditions we can't simulate in a Node/Bun test environment:

    • The OS-level system locale and installed font set (CJK primary font)
    • The browser/Electron font fallback chain resolving mixed CJK + Latin content
    • xterm's WebGL glyph texture atlas — "distorted, overlapping glyph fragments" is the signature of atlas corruption when the renderer receives glyphs with inconsistent metrics from fallback fonts. See apps/desktop/src/renderer/lib/terminal/terminal-addons.ts:46 where WebglAddon is loaded.

    None of these are exercisable with document/canvas stubs.

    Likely affected code

    • apps/desktop/src/renderer/lib/terminal/appearance/index.ts:42 — DEFAULT_TERMINAL_FONT_FAMILIES lists Latin-only monospace fonts (JetBrains Mono, Menlo, Monaco, etc.) followed by the generic monospace. When the OS monospace generic resolves to a CJK font (common on systems with a CJK primary font), the terminal cell metrics and the fallback glyph metrics diverge, which in turn corrupts the WebGL atlas.
    • apps/web/src/app/globals.css:7-8 and apps/marketing/src/app/globals.css:5-6 — the global --font-family-sans / --font-family-mono stacks have no explicit CJK-capable fallback either, so the same class of issue can surface in dialogs / lists whenever the OS generic resolves to a CJK font.

    Suggested direction (not applied here)

    A proper fix likely requires either (a) adding explicit CJK-capable monospace fallbacks (e.g. "Noto Sans Mono CJK SC", "Source Han Mono SC") after the Latin fonts, or (b) using @font-face with unicode-range to scope Latin glyphs to a known-good monospace font so fallback only kicks in for CJK codepoints. Validating either would need hands-on testing in an Electron build with a CJK-locale OS and the matching screenshot repro.

    Happy to revisit if someone can capture the value of xterm.options.fontFamily / computed font-family on the broken machine, plus the OS and the resolved monospace generic there.

  2. Cnotech commented on Apr 21, 2026

    @Cnotech
    Image Image

    Got that too after upgrading to 1.5.6, both Claude Code and Codex

  3. atlas555 commented on Apr 22, 2026

    @atlas555
    Image

    after upgrade

  4. atlas555 commented on Apr 23, 2026

    @atlas555

    not only chinese , but also english !
    Need bugfix quickly, can not work !

    Image
  5. allenxln commented on Apr 26, 2026

    @allenxln

    +1

  6. allenxln commented on Apr 26, 2026

    @allenxln

    Chiming in with repro data and two workarounds that narrow this down significantly. cc @Kitenite

    Environment

    • macOS (Darwin 25.4.0), navigator.platform = MacIntel
    • navigator.language = zh-CN, system locale zh-CN
    • All plausible fallback fonts already installed — document.fonts.check() returns true for all of: PingFang SC, SimSun, Microsoft YaHei, Noto Sans Mono CJK SC, Source Han Mono SC, Menlo, JetBrains Mono. So this is not a "missing CJK font" problem on my machine.

    Two workarounds that make the garbling instantly disappear (both very reliable, tested just now):

    1. Open DevTools (any dock position) — garbling clears immediately.
    2. Drag the window edge to resize — same, instant recovery.

    Both trigger an xterm resize → WebGL texture atlas rebuild. This strongly suggests the corrupted state is the initial atlas, not the underlying character stream or the installed fonts. Content stays correct after recovery until the app is restarted.

    One data point that looks suspicious

    With the terminal in the garbled state, I ran:

    getComputedStyle(document.querySelector('.xterm')).fontFamily

    and got:

    ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"
    

    No monospace family at all. But terminal.options.fontFamily at apps/desktop/src/renderer/lib/terminal/terminal-runtime.ts:109 is set from the monospace stack in appearance/index.ts:42. So the element's computed CSS font-family and the xterm renderer's fontFamily option appear to diverge at startup on my machine — I'm not sure if xterm's internal char-measure element is affected too, but if cell metrics end up measured against a proportional stack while glyphs are rasterized from a monospace one, atlas corruption would be the expected outcome, and a resize would "fix" it by re-measuring.

    I haven't been able to pinpoint the CSS source of this divergence from the repo alone — could be a stylesheet load-order race, a Tailwind @layer specificity collision, or something else. Happy to dig further if useful.

    Possibly relevant

    Let me know if there's anything else useful to capture (e.g. a particular timing snapshot, terminal.options dump, devtools trace on first paint). I can put together a draft PR if a direction is confirmed — but wanted to share the data first in case the CSS divergence above points somewhere obvious to someone who knows the render pipeline.

  7. allenxln commented on Apr 26, 2026

    @allenxln

    Quick follow-up: I traced the CSS path in the repo and the divergence is, I think, explainable from source alone.

    • @xterm/xterm@6.0.0/css/xterm.css doesn't set font-family on .xterm itself — only on .xterm-accessibility-tree.
    • The repo's existing .xterm rule in apps/desktop/src/renderer/globals.css:177-184 only sets height/width.
    • So .xterm inherits from body, which picks up Tailwind v4 preflight's default sans-serif stack — exactly what my earlier getComputedStyle output showed.

    Filed as #3758 (Draft) — a one-line CSS addition. Details and reasoning in the PR description. Marking it Draft because I haven't set up a local desktop build yet; on a change this small and this CSS-local that felt like the honest state to leave it in. Happy to take direction from there.

  8. Kitenite commented on Jul 11, 2026

    @Kitenite
    Member

    Closing as a duplicate of #5605, the consolidated tracker for stale terminal-rendering issues from the July 2026 stale-issue sweep (no activity since 2026-06-01). If this still applies on a current build, comment on #5605 and we'll reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions