Merge downstream commits by jimweller#1
Merged
Lanjelin merged 7 commits intoLanjelin:mainfrom Mar 19, 2026
Merged
Conversation
Injects `await document.fonts.ready` before `this.xterm.open()` to ensure the browser has registered the custom JetBrains Mono Nerd Font before xterm.js measures character dimensions. Fixes incorrect font spacing on first load.
document.fonts.ready alone is insufficient — the browser may resolve it before rasterizing glyphs with the custom font. Adding a deferred fitAddon.fit() via requestAnimationFrame ensures character dimensions are measured after the first paint with the actual font.
requestAnimationFrame only delays one frame which is insufficient for the browser to apply the custom webfont. Use setTimeout at 100ms and 500ms to re-fit the terminal after the font has been rendered.
fitAddon.fit() only recalculates rows/cols using cached character
dimensions. If xterm.js measured character width against a fallback font
before the custom font was usable for canvas rendering, subsequent fit()
calls perpetuate the wrong metrics.
Two changes:
1. Replace document.fonts.ready with document.fonts.load('14px JetBrains')
to explicitly request the browser to load the specific font face rather
than just checking if pending loads are done.
2. Replace plain fitAddon.fit() timeouts with fontSize toggle trick that
forces xterm.js CharSizeService to invalidate its cache and re-measure
character dimensions with the now-available font.
The CI prettier/eslint check requires multi-line arrow function bodies. Expand the inline callbacks to use proper indentation.
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.
Merge following downstream commits by jimweller