Skip to content

Merge downstream commits by jimweller#1

Merged
Lanjelin merged 7 commits intoLanjelin:mainfrom
jimweller:main
Mar 19, 2026
Merged

Merge downstream commits by jimweller#1
Lanjelin merged 7 commits intoLanjelin:mainfrom
jimweller:main

Conversation

jimweller and others added 7 commits February 11, 2026 23:06
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.
@Lanjelin Lanjelin merged commit 7a99aa5 into Lanjelin:main Mar 19, 2026
1 check passed
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.

3 participants