Skip to content

feat(desktop): let monospace text use its own preferred font - #265

Merged
Zongwei9888 merged 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/monospace-font-setting
Oct 21, 2026
Merged

Zongwei9888 merged 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/monospace-font-setting

Conversation

@raymondginger2018-sudo

Copy link
Copy Markdown
Contributor

New appearance setting: a preferred monospace family list, prepended to the built-in mono stack.

The trailing comma carries the mechanism: the built-in stack has no leading comma of its own, so without one the preference and the first built-in family collapse into a single bogus name and the browser drops the declaration (measured in Edge 153, the engine Tauri uses on Windows). Documented in appearance.ts.

Notes

Verification

  • tokens.test.ts: 29/29 passed (2 new tests).
  • tsc --noEmit: clean.
  • appearance.test.ts: locally every test in this file dies in the shared beforeEach on Node 25 (localStorage.clear is not a function, Node 25's built-in localStorage). Differential-verified: clean f183965f59 fails 0/15 there; this branch 0/19 — same root cause, unrelated to this change. CI's Linux nodes are unaffected.

Appearance → Settings offered one preferred-font list, and the picker's
Monospace group fed the same key. `--font-mono` had no preference
variable, so a face chosen there either wrote the interface stack or
looked applied and changed nothing: code blocks, diffs and the small
monospace labels kept the built-in stack either way.

`fontFamilyMono` is now a row of `APPEARANCE_SETTINGS` with its own key,
field and `--font-mono-preferred` variable, which `--font-mono` consumes
as a prefix. The variable is declared empty rather than omitted, because
`var()` without a fallback would make the whole `font-family` declaration
invalid at computed-value time; an empty value also keeps the shipped
rendering byte-identical until a font is chosen.

The placeholder and the note moved onto the descriptor rows, so the table
stays the one place that knows a preference's key, validation and copy —
the renderer no longer keeps a second map of the two font keys, and each
field writes the key it was reached through.

The terminal pane is out of reach and the copy now says so: xterm paints
its own canvas and takes its font from `TerminalPanel`, whose geometry is
deliberately frozen because the fit addon sends its cols/rows to the PTY.

Measured in Edge 153, the engine Tauri uses on Windows, against the built
stylesheet: with no preference the stack is unchanged, and with one the
built-in stack still follows it. The trailing comma `familyListCss`
appends is what keeps `JetBrains Mono "SFMono-Regular"` from parsing as a
single family name — without it the declaration is dropped and monospace
text falls back to the interface font.

Refs HKUDS#155.
@Zongwei9888
Zongwei9888 merged commit e6d1f0c into HKUDS:main Oct 21, 2026
12 checks passed
@Zongwei9888

Copy link
Copy Markdown
Collaborator

Merged into main on 2026-10-21 as e6d1f0c ("Merge PR #265: let Desktop code text use its own preferred font"). Thank you, this is a nicely contained change.

We checked it in a running Web client: with a font entered under Appearance, code text switches to it while the interface font stays the same, and the choice survives a reload. The default is unchanged and the Chinese strings are in place. Typecheck, lint and the 336 vitest tests pass.

One minor thing, not blocking: a value the user ends with a comma ("X,") becomes X,, and falls back to the interface font, as the existing interface-font field already does. It's in the README news for 2026-10-21.

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.

2 participants