Repository navigation
fix(terminal): size icons and Hangul from late faces however they arrive - #2074
Conversation
Follow-up of #2062 for the MEDIUM items of #2064. - Two arrivals heard in the same task (both Hangul weights from WebKit's cache, or an icon with Korean) swapped the family's quotes back before the glyph fit looked, so the widths measured with the stand-in stayed. Arrivals now coalesce into one frame per terminal: the widths are cleared there, the family is set once and every row redrawn once. - Each face is followed by its own loaded promise (followLateFaces, coversAny from the #2062 lane's draft): a chunk that fails or stalls holds back none that loaded, a character drawn while another face of its family loads is not dropped, and a failed face is not asked again. - No load is started for a face: the page fetches only the faces its text reaches, so Ovis Hangul Mono stays unfetched behind an installed Korean font, and loadFontStack leaves it out of the Latin preload. - The per-redraw ask is one Set lookup per character. scripts/terminal-late-faces-regression.ts fails on main and passes here.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 10 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
CSS matches font family names without regard to case, so "pretendard variable" typed in Settings draws with the "Pretendard Variable" faces. The late-face follower and the preload's Hangul exclusion compared the names literally: such a face was never followed, and the widths measured with the stand-in stayed once it arrived. Both now compare unquoted, lower-cased names. A test through adjustTerminalGlyphs also covers the explicit width clear on arrival: two arrivals in separate frames set the family back before the rows are drawn again.
|
Merge-pass review verdicts:
|
|
0706143, omo code reviewer: PASS (LOW only).
The Codex re-review of this commit is still running. |
|
0706143, Codex Sol (xhigh): PASS, with no findings in this delta.
Both reviewers have passed 0706143. #2074 now waits on CI, then merges right after #2070. |
|
Merged at 0706143 by the merge pass.
CodeRabbit did not review this PR: its review limit was reached. The merge relied on the two reviewers, CI, and the lane's eamac WKWebView and Ovis for Mac captures. |
…when the icon font arrives (#2158) ## What it fixes The last two items of #2064 that #2074 left open. #2074 fixed every MEDIUM and most LOWs; its body lists these two as left as they are. - **Powerline separators redrew every row when the icon font arrived.** Separators U+E0B0-E0B7 are painted as boxes (`terminalBoxGlyphs.ts`), not taken from a font. Every drawn character still asked for its late faces, though, so a prompt whose only private-use characters are separators followed `Symbols Nerd Font Mono`'s face. When it arrived, the terminal measured again and drew every row again for nothing. - **The Hangul face's range test missed a broken range.** It checked only that the range held no Latin and covered the syllables, so dropping the compatibility jamo or adding `U+E000-F8FF` still passed. ## The change - `src/lib/terminalGlyphs.ts`: faces are asked for after the span is rebuilt. Characters painted as boxes (`isBoxGlyph`) in a span drawn as boxes ask *quietly* (`followLateFaces(...).ask(families, text, true)`): their faces are still followed, but an arrival that only they waited for measures and draws nothing again. xterm measured those characters with the stand-in too, though, so the first time one is drawn from the font instead (under the cursor, or with a joiner), the terminal measures again in the next frame. A single box under the cursor also gets its cell's spacing from the face at once, so even that first frame is not drawn at the stand-in's width. A character the font draws keeps asking as before: the cursor cell, a span with a joiner, Powerline's other shapes U+E0B8-E0D7 (drawn from the icon font), and the box-drawing diagonals U+2571-2573, which `BOX_GLYPHS` matches but `boxDrawing` leaves to the font. - `src/lib/fontFamily.test.ts`: asserts the exact `U+3131-318E, U+AC00-D7A3` for both weights. It also reads each woff2's cmap (a small brotli + format 4 reader in the test) and checks that it maps exactly those code points. Both files map 11,266 code points: 3131-318E and AC00-D7A3. ## Before and after Chrome (headless, the lockfile's build path) on an isolated test herdr session and a port-0 server. The pane prints `\ue0b0 main \ue0b1 abc \ue0b2\ue0b3`, the icon font's response is held until the first drawing, and the script counts how often xterm draws that row again after the face arrives. The script was QA-only and is not committed. | | separator row drawn again after the icon face arrived | icon font fetched | |---|---|---| | before #2062 (7eeb7d4) | 2 | yes | | main 38f0989 | 2 | yes | | this branch | 0 | yes | The icon font is still fetched: the page's own layout of the row text reaches it (it did before #2062 too), and this module starts no load since #2074. Skipping that fetch would mean taking the separators out of the text the browser lays out, which this PR does not do. ## #2064 items With #2074 this closes the issue: - Powerline separators fetching the icon font and redrawing every row: the redraw is fixed. The fetch comes from layout and predates #2062 (see above). - The exact-range assertion and the cmap check: done. ## Design reference No UI change. The rule follows #2062/#2074 (Zed and Warp size a cell from the font that draws it): a character that no font draws needs no late face. ## Checks - `bun test src/lib/terminalGlyphs.test.ts`: the new case "follows no face for Powerline's separators" **fails on main** (1 refresh instead of 0) and passes here. New cases also check: - an icon beside a separator and a box-drawing diagonal still follow their faces (the diagonal case fails if the skip uses `BOX_GLYPHS` instead of `isBoxGlyph`); - a box painted while its face loads, then drawn under the cursor or with a joiner after the face arrived, measures again once, and under the cursor takes its one cell at once. This is the merge pass's MEDIUM at d92c3a6. Its own reproduction with xterm's real `WidthCache` (13 cases) passes here. - `followLateFaces`: a quiet arrival measures nothing until a character it covers is drawn from it, then once; a face asked for by painted and font-drawn text measures again when it arrives. Each was checked against a mutation of the code it covers: dropping the rebuilt guard, the quiet re-measure, the quiet ask, the quiet-to-followed upgrade, or the cursor spacing each fails at least one case. - `src/lib/fontFamily.test.ts` fails under each mutation of the CSS: dropping `U+3131-318E`, or adding `U+E000-F8FF`. The cmap reader's output matches an independent scratch parser for both files. It also fails on Codex's malformed copies of both fonts, where U+3131's glyph-array entry plus `idDelta` is glyph 0; a reader that ignored the delta passed them. - `bun run check fast`: 7396ca78 passed in full (7912 unit tests, 0 fail). On a384522 (the same code minus one removed test, on newer main) and on 92e8cc3a the only local failure on 92e8cc3a was `server/codex.test.ts` "reads short answers in bounded time however many unclosed links" (11.8 against < 8), the ratio flake after #2150 that another lane is fixing; this PR does not touch that file. It also failed this PR's first CI run. - On the merge pass's fix: the Chrome QA above still draws the separator row 0 times after the icon arrives, and `scripts/terminal-late-faces-regression.ts` passes. ## Reviews - omo-native-code-reviewer: **PASS** (two LOW). LOW 1, diagonals skipped through `BOX_GLYPHS`, is fixed. LOW 2 was the cmap reader's glyph-0 reading: Codex found the concrete case, and it is fixed. - Merge pass at d92c3a6: one MEDIUM (a box painted while its face loaded kept xterm's stand-in width once drawn from the font under the cursor). Fixed as described above. - CodeRabbit: one comment on the changelog wording, applied. - Codex Sol on 92e8cc3a (the merge pass's fix): BLOCK on one MEDIUM. The quiet flag was read through a closure, which kept a stopped terminal alive through a face that never loads. Fixed: the arrival handler takes a plain entry. Codex's probes show the leak on 92e8cc3a and not on the fix. A WeakRef/`Bun.gc` unit test for it failed every run against the closure, but also failed 2 to 3 runs in 1000 on the fix (conservative stack scanning), so it was left out; the comment on `whenLoaded` states the rule. - Codex Sol re-review of that fix: the MEDIUM is fixed, no production finding; its only other finding was that flaky test, now removed. - Codex Sol 6.1 Fast xhigh, on fd6094f1: BLOCK on one MEDIUM (font-drawn diagonals lost late-face tracking) and one LOW (cmap `idDelta` on glyph-array entries). Both are fixed in this head. Its re-review of only the fix delta: **PASS**, no new findings. Closes #2064
What it fixes
The MEDIUM items of #2064, the follow-up of #2062's bundled Hangul face. Icons and Korean are now sized from the faces that draw them, however the late font loads interleave:
Ovis Hangul Mono(265 KB / 277 KB) loaded even when an installed D2Coding or Noto Sans Mono CJK KR drew the Hangul. A font typed in Settings also fetched it throughloadFontStack'sMg가before any Korean was printed.fonts.loadfor several characters tied an arrived chunk to a failed or stalled one.asked.The change (
src/lib/terminalGlyphs.ts,src/lib/fontFamily.ts)loadedpromise (followLateFaces, withcoversAnyfrom the fix(terminal): draw Hangul in a bundled coding face that matches the Latin #2062 lane's draft patch). A character drawn while a face of its stack covers it and has not loaded follows that face, whatever its weight.fonts.checkis no longer called once per family and glyph.FontFace.loadedresolves for a load layout started, and that noloadingdoneever fires. A face behind an installed Korean font was never requested, by layout or by a canvas measure.askedis oneSetlookup per drawn character.loadFontStackleaves the bundled Hangul face out of the preload that sizes the grid: it holds no Latin.Before and after
Ovis for Mac's window (the real app,
app/macbuilt ad hoc on the test MacBook Air, macOS 27.0.1, against isolated test servers from fresh clones of main and this branch). A QA-only script served from each build released both Hangul weights' arrival promises in the same task, as a cache does:With natural loads (a cold load and two reloads from the cache, in a WKWebView with the app's configuration), main and this branch draw the same: icons 7.83 px in 7.83 px cells, bars aligned. On this branch the cold load ends at the 1.084x fit of the 13 px face, not the 1.2x that the 11.24 px stand-in gives, so WebKit heard the late face with no
fonts.loadcall.Chrome (
scripts/terminal-late-faces-regression.ts, new in the browser lane). Chromium on Linux stands in with fonts as wide as the faces, so the script gives the page WebKit's narrower stand-ins: the same two files drawn smaller withsize-adjust. It then delivers the icon and Hangul arrivals in one task. It fails on main (icons drawn at 13 px across the next cell, Korean bar +1.47 px) and passes here (icons 7.8 px, bar +0.11 px):Fetches (Chrome on Linux, Noto Sans Mono CJK KR installed ahead of the bundled face, network log):
OvisHangulMono-RegularfetchedWhere nothing ahead of it draws the Hangul (the Mac app, Safari, the regression's typed stack), both weights still load and are measured again.
#2064 items
PaneTerminal.cssandDESIGN.mddescribe the new rule.Setlookup per character).askedkeeps characters whose request was skipped: fixed (nothing is skipped).fonts.checkcalls per glyph;fontFamily.test.ts;Design reference
The design stays #2062's: Zed and Warp size a cell with the font that draws it, which in a browser means measuring again when a late face arrives. This PR only changes how arrivals are heard (each face by its own promise, as
lib/fontFaces.tsalready does for the chrome) and batched (one layout per frame, however many faces arrive). No external code was adapted.Checks
bun test src/lib/terminalGlyphs.test.ts src/lib/fontFamily.test.ts src/lib/fontFaces.test.ts: 49 pass. New cases:coversAny;adjustTerminalGlyphson a stand-in page: two arrivals in separate frames set the family back before the rows are drawn again, and the icon is still measured from its loaded face (fails without the explicit width clear).Each case was checked against a mutation of the code it covers (15 mutations, each caught).
Case-insensitive match in Chrome (a QA-only variant of the regression script): a late face declared "Late Hangul", typed as
late hangul, arriving after the first drawing. At 9947418 the Korean bar stays 15.41 px right of the Latin one (Hangul fitted for the stand-in); at 0706143 it is 0.11 px off.bun run check fast: pass at 0706143 (typecheck, build, 7684 unit tests, 0 fail).scripts/terminal-late-faces-regression.ts: fails on main 42bd1ef, passes on this branch. It is added toscripts/ci-browser.sh.Mac checks ran in fresh clones in
/tmpon the test MacBook Air, with an isolated herdr session and test servers. They were removed afterwards, along with the QA-only gate script.