Skip to content

Add experimental grayscale terminal font smoothing on macOS - #335625

Merged
Anthony Kim (anthonykim1) merged 4 commits into
mainfrom
anthonykim1/terminal-crisp-font-rendering
Sep 27, 2026
Merged

Anthony Kim (anthonykim1) merged 4 commits into
mainfrom
anthonykim1/terminal-crisp-font-rendering

Conversation

@anthonykim1

@anthonykim1 Anthony Kim (anthonykim1) commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Part of: #337208

  • Add the experimental, advanced terminal.integrated.fontRendering setting on macOS, with inherit (default, unchanged) and grayscale.
  • Apply grayscale as terminal-scoped -webkit-font-smoothing: antialiased on high-DPI displays only, leaving the editor, workbench, terminal font, and theme colors unchanged.
  • Apply the policy to normal, detached, and sticky-scroll terminals.
  • Keep terminal transparency controlled only by terminal.integrated.enableImages; hide the setting and model it as optional outside macOS.

Context

  • Comparing VS Code's HiDPI terminal with Ghostty showed that the visible macOS difference comes from antialiasing policy, not rendering resolution.
  • An earlier Windows/Linux alpha-canvas variant was removed. On Windows it produced grayscale antialiasing but was not sharper (evaluation).
  • crisp was renamed grayscale to describe the antialiasing mode it applies.

Known limitation

With GPU acceleration, grayscale is not yet applied consistently. Measured in Code OSS on macOS at DPR 2, with WebGL confirmed and identical Menlo 13 content; each case was run twice:

Case Result
Terminals restored by Developer: Reload Window Fully applied
Terminal opened while another is open, including right after changing the setting Fully applied
First terminal in a window Partial: bold, colored, and non-ASCII text change, while plain default-colored ASCII keeps the previous look
New terminal after closing all terminals, or after relaunching Plain default-colored ASCII keeps the previous look (other text not measured)
Terminal that was already open when the setting changed No change

The setting description points to Developer: Reload Window for this reason. Here is the reload comparison:

Terminal font rendering after window reload: inherit vs grayscale

Next steps

  1. Suggest an xterm.js follow-up so the policy applies consistently. Its WebGL atlas warms up ASCII glyphs while the raster canvas is detached from the styled terminal element. clearTextureAtlas replaces glyph bitmaps but not the cached Canvas2D font state. Atlases are also shared by a configuration that excludes font smoothing. A fix could establish the raster policy before warm-up, invalidate font state when it changes, and keep atlases with different policies separate. xtermjs/xterm.js#2464 closed general antialiasing configuration as out of scope, so the scope is worth discussing with maintainers first.
  2. Adopt that fix, remove the limitation from the setting description, and add GPU pixel coverage for cold start, reload, live switching, and shared atlases.
  3. Evaluate Windows and Linux separately.

Validation

Run against the same change applied to e550b8b959b1, whose dependencies match the local install:

  • npm run test-browser-no-install -- --run src/vs/workbench/contrib/terminal/test/browser/xterm/xtermTerminal.test.ts --browser chromium: 25 passing.
  • npm run typecheck-client, ESLint for the changed TypeScript files, npm run stylelint -- src/vs/workbench/contrib/terminal/browser/xterm/terminalFontRendering.css, and git diff --check.
  • Code OSS pixel comparisons for the cases above, on Electron 43.7.3.

Manual review cases

  1. On a macOS high-DPI display, set grayscale, then open another terminal while one is open, or run Developer: Reload Window. Text should look sharper; font, size, spacing, and colors should not change.
  2. Remove the setting and confirm terminal rendering matches inherit.
  3. Enable terminal.integrated.enableImages and confirm images and transparency work in both modes.
  4. Confirm the setting is not shown on Windows or Linux.

Inspirations from:

Copilot AI balanced review requested due to automatic review settings September 11, 2026 05:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The platform-gated configuration contract is inaccurate, and detached forwarding is not actually covered by the new test.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity · 1 Low severity

New issues introduced by this change (2)
Severity Finding
Medium severity src/​vs/​workbench/​contrib/​terminal/​common/​terminal.ts — Model the excluded setting as optional
Low severity src/​vs/​workbench/​contrib/​terminal/​test/​browser/​xterm/​xtermTerminal.test.ts — Exercise detached configuration forwarding
What changed in this PR

Adds an opt-in crisp font-rendering mode for macOS terminals while preserving existing defaults.

Changes:

  • Registers terminal.integrated.fontRendering.
  • Applies smoothing consistently to standard, detached, and sticky-scroll terminals.
  • Refreshes glyph caches and adds targeted tests.
File Description
terminalStickyScrollOverlay.ts Applies rendering policy to sticky scroll.
xtermTerminal.test.ts Tests rendering configuration behavior.
terminalConfiguration.ts Registers the setting.
terminal.ts (workbench) Adds the configuration property.
xtermTerminal.ts Applies rendering during attachment and updates.
terminalFontRendering.ts Implements class updates and atlas refresh.
terminalFontRendering.css Defines HiDPI smoothing behavior.
terminal.ts (platform) Adds the setting identifier.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 10172ed2-6839-4f48-a62c-ffd95f85c86e
@anthonykim1 Anthony Kim (anthonykim1) changed the title Add a crisp font-rendering option for macOS terminals Add experimental cross-platform terminal font rendering Sep 16, 2026
@anthonykim1

Anthony Kim (anthonykim1) commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Update (39b262f): The PR now follows the recommendation below. It is scoped to macOS and uses grayscale instead of crisp; Windows and Linux are left as separate follow-ups. The Windows evaluation below remains the evidence for that decision.


The implementation is cross-platform, but the sharpness benefit is not established across platforms.

I compared the pre-PR build with PR head on Windows: Cascadia Mono 16px, 150% display scaling, WebGL enabled, images disabled, and matching content/theme.

The setting works mechanically: crisp changes glyph rasterization from LCD/subpixel antialiasing to grayscale. However, the existing rendering looks at least as sharp - and arguably sharper - on this setup. Removing colored edge fringes is not evidence of improved readability or sharpness.

Additional pixel-alignment and Canvas text-rendering experiments did not improve the sampled output. This is not evidence that Windows cannot improve; it means this PR has not demonstrated that improvement.

Recommendation: preserve the observed macOS benefit, keep inherit as the default, and describe any Windows/Linux option as an antialiasing preference, not a quality upgrade. A name such as grayscale would be more accurate than crisp. Linux still needs independent visual evaluation.

If the intended feature is specifically "sharper terminal text," I would not extend that claim to Windows based on the current evidence.

(generated by copilot)

Only offer terminal.integrated.fontRendering on macOS and rename the
opt-in value from crisp to grayscale, since it changes antialiasing
rather than making text universally sharper.

Stop coupling the setting to terminal transparency, so images remain
the only thing that enables it, and document that the WebGL renderer
currently only picks the policy up after a window reload with open
terminals.
@anthonykim1 Anthony Kim (anthonykim1) changed the title Add experimental cross-platform terminal font rendering Add experimental grayscale terminal font smoothing on macOS Sep 27, 2026
@anthonykim1

Anthony Kim (anthonykim1) commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Comparison of terminals restored by Developer: Reload Window, with terminal.integrated.fontRendering set to inherit and grayscale. Captured in Code OSS on macOS at DPR 2, with WebGL, Menlo 13, and identical terminal content; 11,949 pixels differ. The lower rows are 3× nearest-neighbor crops of the same captures.

Terminal font rendering after window reload: inherit vs grayscale

The same full effect appears in a terminal opened while another one is open. With the WebGL renderer, terminals that were already open when the setting changed don't change, and the first terminal in a window only partly picks it up. See the description for the measured cases.

@anthonykim1 Anthony Kim (anthonykim1) added the macos Issues with VS Code on MAC/OS X label Sep 27, 2026
@anthonykim1
Anthony Kim (anthonykim1) marked this pull request as ready for review September 27, 2026 18:06
@anthonykim1
Anthony Kim (anthonykim1) merged commit 1b7223a into main Sep 27, 2026
35 checks passed
@anthonykim1
Anthony Kim (anthonykim1) deleted the anthonykim1/terminal-crisp-font-rendering branch September 27, 2026 18:26
@vs-code-engineering vs-code-engineering Bot added this to the 1.140.0 milestone Sep 27, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Nov 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

macos Issues with VS Code on MAC/OS X

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants