Skip to content

feat(editor): add an opt-in editor font family (default: follow terminal font) - #9658

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-9628-editor-font-family
Jul 21, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fix-9628-editor-font-family

Conversation

@nwparker

@nwparker nwparker commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

What

On Monaco-based editor surfaces (file editor, diffs, notebook cells, code excerpts) the font was hard-wired to the terminal font. Users who set their terminal font to a Nerd Font "Mono" variant saw CJK/Hangul text overlap in the editor: the --mono patch clamps every glyph advance to a single cell, so wide glyphs (ink ~2 cells) advance only 1 cell and pile up on top of each other. The terminal itself stayed correct because it sizes cells from Unicode tables, not font advances. There was no way to give the editor its own font.

Why it happened

MonacoEditor.tsx:155 did const editorFontFamily = settings?.terminalFontFamily || 'monospace' and fed it straight into Monaco (updateOptions at :718, options at :836). The same terminal-font reuse existed in DiffViewer.tsx:425, IpynbViewer.tsx:412/:877, MonacoCodeExcerpt.tsx:54, and DiffSectionBody.tsx:194 (from DiffSectionItem.tsx:434). No editorFontFamily setting existed anywhere — types.ts:2597-2618 and constants.ts:190-203 declared only appFontFamily and terminalFontFamily — so the editor could not be given a different font.

ELI5

The code editor was borrowing the font you picked for your terminal. Some of those fonts are specially squished so every character takes exactly one column — which looks fine in a terminal but makes Chinese, Japanese, and Korean letters crash into each other in the editor. This adds a separate "editor font" setting; leave it blank and nothing changes, or set it to a normal font to fix the overlap.

Evidence

Independent metric check of the Nerd-Fonts "Mono" patch (fontTools 4.61.1, upm=1950) confirms the advance-clamping that causes the overlap:

FiraCodeNerdFont-Regular      U+F08C6  advance 1200  xMax 1790  (ink overflows one cell)
FiraCodeNerdFontMono-Regular  U+F08C6  advance 1200  xMax 1200  (clamped to one cell)

The editor and terminal are on different rendering paths — the terminal never uses font advances:

$ grep -rn "editorFontFamily" src   # before: only the local const in MonacoEditor.tsx
$ grep -n fontFamily src/renderer/src/components/editor/MarkdownPreview.tsx   # no hits — Markdown view is immune

The fix introduces a pure resolver and a new opt-in setting (default empty), plus tests. New MonacoEditor.font-family.test.tsx (91 lines) and expanded editor-font-zoom.test.ts assert that with editorFontFamily unset the resolver returns the byte-identical terminal-font string, and that a set value is honoured:

$ git diff origin/main...HEAD --stat
 23 files changed, 361 insertions(+), 58 deletions(-)
 ... MonacoEditor.font-family.test.tsx | 91 +++++++++++++
 ... lib/editor-font-zoom.ts           | 20 +++++
 ... settings/EditorFontFamilySetting.tsx | 56 +++++++++

The notebook shell's inherit-UI-font branch (IpynbViewer.tsx:877, previously falling back to undefined rather than monospace) is preserved via a dedicated resolveEditorFontFamilyOrInherit.

Trade-offs

Zero user-visible regressions. The new editorFontFamily setting defaults to empty, and resolveEditorFontFamily(settings) returns editorFontFamily?.trim() || terminalFontFamily || 'monospace' — the identical string as before for anyone who does not set it. Per the repro's risk notes, the fix deliberately does not route the editor through buildFontFamily() (which would append the Nerd-Font/PUA fallback chain and change glyph rendering for every existing user), and preserves the notebook inherit-font branch.

Perf

{"hasRegression":false,"verdict":"0 perf regressions: pure-function font resolver swapped into existing Monaco option objects","notes":"The diff adds an opt-in editorFontFamily setting. Hot-path touch points (DiffViewer, DiffSectionBody/Item, IpynbViewer CodeCell, MonacoCodeExcerpt, MonacoEditor) only replace settings?.terminalFontFamily || 'monospace' with resolveEditorFontFamily(settings) — a trivial pure function (editorFontFamily?.trim() || terminalFontFamily || 'monospace') returning a string primitive. It's placed inside Monaco options objects that were already reconstructed every render, so no new object/array/function identity is introduced that would break downstream memo bail-out; the returned value is a stable string. The only per-render allocation is .trim() on a short string, and only when the font is set (negligible, and Monaco option-object construction dominates anyway). No changes to onPtyData, xterm render loop, IPC fanout, polling, or fs watchers. No new intervals/listeners/subprocesses/sync-I-O, so no cleanup concerns. New settings-pane files (EditorFontFamilySetting.tsx, auto-save-delay-draft.ts, general-editor-search.ts) run only on the settings screen, a cold path. constants.ts/types.ts add a default-empty field. No added awaits on the startup/first-paint path."}

Review

Reviewed by an independent agent for 1 round — final verdict: CLEAN.

Closes #9628

Made with Orca 🐋

…nal font)

Monaco-based editor surfaces hard-wired terminalFontFamily, so CJK users on
Nerd Font "Mono" variants (single-cell advances for wide glyphs) got
overlapping Hangul/CJK in the editor while the terminal stayed correct.

Add an opt-in `editorFontFamily` setting that defaults to empty, resolving to
the terminal font byte-identically for existing users. New surfaces resolve via
`resolveEditorFontFamily`; the notebook shell keeps its inherit-UI-font
fallback via `resolveEditorFontFamilyOrInherit`.

Fixes #9628

Co-authored-by: Orca <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e86bfc0a-828d-4c43-885a-ac3b6c931cd1

📥 Commits

Reviewing files that changed from the base of the PR and between 8182141 and 048ce51.

📒 Files selected for processing (23)
  • src/renderer/src/components/editor/DiffSectionBody.tsx
  • src/renderer/src/components/editor/DiffSectionItem.tsx
  • src/renderer/src/components/editor/DiffViewer.tsx
  • src/renderer/src/components/editor/IpynbViewer.tsx
  • src/renderer/src/components/editor/MonacoCodeExcerpt.tsx
  • src/renderer/src/components/editor/MonacoEditor.font-family.test.tsx
  • src/renderer/src/components/editor/MonacoEditor.tsx
  • src/renderer/src/components/settings/EditorFontFamilySetting.tsx
  • src/renderer/src/components/settings/GeneralEditorSettingsSection.tsx
  • src/renderer/src/components/settings/GeneralPane.tsx
  • src/renderer/src/components/settings/Settings.tsx
  • src/renderer/src/components/settings/auto-save-delay-draft.ts
  • src/renderer/src/components/settings/general-editor-search.ts
  • src/renderer/src/components/settings/setting-labels.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/editor-font-zoom.test.ts
  • src/renderer/src/lib/editor-font-zoom.ts
  • src/shared/constants.ts
  • src/shared/types.ts

📝 Walkthrough

Walkthrough

Adds an optional editorFontFamily setting with shared resolution helpers and a default empty value. Adds a searchable, localized settings control with font suggestions. Applies the resolved font family across Monaco editors, diff views, notebook views, and code excerpts. Adds tests for fallback and override behavior. Also introduces auto-save delay draft-state helpers and re-exports them from GeneralPane.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description has useful detail, but it does not follow the required template and omits Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes. Reformat the PR description to match the template and add the missing sections, especially Testing, AI Review Report, Security Audit, Screenshots, and Notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: an opt-in editor font family that follows the terminal font by default.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 91ee29a into main Jul 21, 2026
2 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…nal font) (stablyai#9658)

The code editor was hard-wired to the terminal font, so Nerd Font 'Mono' CJK glyphs overlapped in the editor. Adds an opt-in editorFontFamily setting; default is empty so the resolved value is byte-identical to today for every existing user.

Closes stablyai#9628
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.

[Bug]: Code editor reuses terminalFontFamily — Nerd Font "Mono" variants render overlapping Hangul/CJK glyphs (terminal unaffected)

1 participant