Repository navigation
fix: draw terminal text in the chosen font with the GPU renderer - #351
Merged
Merged
Conversation
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
This was referenced Nov 8, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 textfontStyleis 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 = …" normal 14px monospace"14px monospace10px sans-serif"normal 14px monospace"14px monospace14px monospace"normal 14px monospace "14px monospace14px monospaceOnly leading whitespace is rejected.
Fix
The existing
@xterm/addon-webglpatch 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.yamlonly changes the patch hash.Testing