Skip to content

fix: draw terminal text in the chosen font with the GPU renderer - #351

Merged
FloSch62 merged 1 commit into
mainfrom
fix/webgl-canvas-font
Nov 8, 2026
Merged

FloSch62 merged 1 commit into
mainfrom
fix/webgl-canvas-font

Conversation

@FloSch62

@FloSch62 FloSch62 commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Fixes #350

Problem

Since v0.15.0, terminals using the GPU renderer (WebGL) show text in a small sans-serif face, widely spaced in its cells, and Nerd Font icons as empty boxes. Powerline arrows still look right. Turning off Settings → Terminal → GPU renderer (WebGL) fixes it. 0.15 also turned WebGL on by default for new installs, so more users now see this.

Cause

The WebGL addon builds the canvas font as `${fontStyle} ${fontWeight} ${size}px ${fontFamily}`. For upright text fontStyle is empty, so the string starts with a space: " normal 14px "JetBrains Mono", …".

Electron 45.2.3 (Chromium 156.0.8078.80), which 0.15 moved to, rejects a canvas font with leading whitespace. Electron 45.2.1 in 0.14 accepted it. When the assignment is rejected, the canvas keeps its default 10px sans-serif, and the glyph atlas rasterizes every upright glyph with it. Italic text and the glyphs xterm draws itself (powerline, box drawing) are unaffected. The DOM renderer doesn't use a canvas font.

Same string in both Electrons:

ctx.font = … 45.2.1 45.2.3
" normal 14px monospace" 14px monospace 10px sans-serif
"normal 14px monospace" 14px monospace 14px monospace
"normal 14px monospace " 14px monospace 14px monospace

Only leading whitespace is rejected.

Fix

The existing @xterm/addon-webgl patch now trims both font strings: the one the texture atlas rasterizes glyphs with and _getFont, used by the render layers. Both bundles (.js, .mjs) and the TS sources are patched. xterm's core already trims its own canvas font the same way. pnpm-lock.yaml only changes the patch hash.

Testing

  • Ran the desktop app on Electron 45.2.3 with WebGL on and printed a prompt with Nerd Font icons, powerline arrows and plain text:
    • before: small sans-serif text in wide cells, icons as boxes
    • after: JetBrains Mono, icons from the bundled symbol font, matching the DOM renderer and Electron 45.2.1
  • Patched CJS and ESM bundles parse; client build passes

Since 0.15, terminals using the GPU renderer showed text in a small
sans-serif face, widely spaced in its cells, and Nerd Font icons as
empty boxes. Turning WebGL off fixed it.

The WebGL addon builds the canvas font as "<style> <weight> <size>px
<family>", and the style is empty for upright text, so the string starts
with a space. Electron 45.2.3 (Chromium 156.0.8078.80) rejects a canvas
font with leading whitespace, where 45.2.1 accepted it, and the canvas
kept its default 10px sans-serif. Italic text and the glyphs xterm draws
itself, such as powerline arrows, were unaffected.

The WebGL addon patch now trims both font strings: the one the glyph
atlas rasterizes with and the one the render layers use. xterm's core
already trims its own.

Fixes #350
@FloSch62
FloSch62 merged commit a73bef9 into main Nov 8, 2026
9 of 10 checks passed
@FloSch62
FloSch62 deleted the fix/webgl-canvas-font branch November 8, 2026 11:52
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.

Font symbols not rendering correctly

1 participant