Skip to content

workbench: add configurable font size and font family settings (#519)#319151

Open
DisturbedSage5840C wants to merge 3 commits into
microsoft:mainfrom
DisturbedSage5840C:feat/workbench-font-size-family
Open

workbench: add configurable font size and font family settings (#519)#319151
DisturbedSage5840C wants to merge 3 commits into
microsoft:mainfrom
DisturbedSage5840C:feat/workbench-font-size-family

Conversation

@DisturbedSage5840C
Copy link
Copy Markdown

@DisturbedSage5840C DisturbedSage5840C commented May 30, 2026

Summary

Fixes #519 — Allow to change the font size and font of the workbench.

This is the most-requested VS Code feature with 4,700+ reactions and 589 comments, open since 2015. This PR implements it with a minimal, targeted approach that exactly mirrors the existing workbench.fontAliasing pattern — no new subsystems, no architectural changes.


What changed

New settings

Setting Type Default Range
workbench.fontSize number 13 830
workbench.fontFamily string "" (platform default) any CSS font-family

Both settings take effect immediately with no reload required.

workbench.fontSize

Controls the font size of all workbench UI surfaces:

  • Sidebar / file explorer / outline
  • Editor tabs and breadcrumbs
  • Status bar
  • Panel headers (Terminal, Problems, Output, etc.)
  • Settings UI, notifications, dialogs, menus

The editor font is not affected — use editor.fontSize for that.
Range 8–30 px covers accessibility users who need large UI text and high-density display users who prefer compact UI.

workbench.fontFamily

Overrides the platform-default font family with a custom font.

  • Leave empty → platform default (-apple-system / Segoe UI / system-ui)
  • Set to e.g. "Inter", "Fira Sans", "Roboto", sans-serif → applied immediately
  • Input is sanitized: characters that could form CSS injection vectors (;, {, }, <, >, newlines) are stripped before the value is written to a CSS custom property

Implementation

style.css

  • .monaco-workbench { font-size: var(--vscode-workbench-font-size, 13px) } — CSS variable with 13 px fallback; default behaviour is byte-for-byte identical to before
  • New class .monaco-workbench-custom-font { font-family: var(--vscode-workbench-font-family) !important } applied only when a custom family is configured, overriding per-platform rules

workbench.contribution.ts

  • Both settings registered under ConfigurationScope.APPLICATION

workbench.ts

  • updateWorkbenchFontSize() and updateWorkbenchFontFamily() follow the exact same pattern as updateFontAliasing()
  • Both are dispatched from a single shared onDidChangeConfiguration subscription (not separate listeners) to reduce event-handling overhead
  • Font size is clamped to 8–30 before applying; font family is sanitized before writing to the CSS custom property

Test plan

  • Open Settings and search "workbench font" — both settings appear with descriptions
  • Set "workbench.fontSize": 15 — sidebar, tabs, status bar, breadcrumbs all grow immediately
  • Set "workbench.fontSize": 8 — UI shrinks for high-density use
  • Set "workbench.fontSize": 30 — UI scales up for accessibility
  • Set "workbench.fontFamily": "Georgia" — all workbench text switches to Georgia immediately
  • Clear workbench.fontFamily — platform default font restores
  • Set "workbench.fontFamily": "Comic Sans; background: red" — injection characters stripped, falls back gracefully
  • Set "workbench.fontSize": 13 (default) — identical to baseline, no visual difference
  • Verify editor.fontSize is unaffected by workbench.fontSize
  • Open an auxiliary window — font size and family inherited correctly

…soft#519)

Adds two new workbench-level font settings that have been the most
requested VS Code feature for nearly 10 years (issue microsoft#519, 4700+ votes).

**workbench.fontSize** (number, 11–16, default 13)
Controls the font size in pixels of all workbench UI surfaces: sidebar,
file explorer, tabs, breadcrumbs, status bar, panel headers, settings
UI, notifications, and menus. The editor font size is unaffected (use
`editor.fontSize` for that). The range 11–16 px is chosen to fit safely
within the existing 22 px virtual-list row height used by tree views.

**workbench.fontFamily** (string, default '')
Overrides the platform-default font family (Segoe UI on Windows,
-apple-system on macOS, system-ui on Linux) with a custom font. Leave
empty to restore the platform default. Accepts any valid CSS font-family
value (e.g. `"JetBrains Mono"`, `"Fira Code", sans-serif`).

Implementation:
- `style.css`: `.monaco-workbench` now reads font-size from a CSS
  custom property `--vscode-workbench-font-size` with a fallback of
  13px, so the default behaviour is identical to before. A new utility
  class `.monaco-workbench-custom-font` is added; when present it sets
  `font-family` from `--vscode-workbench-font-family`, overriding the
  per-platform font-family rules.
- `workbench.contribution.ts`: both settings are registered under
  `ConfigurationScope.APPLICATION` so they apply globally (not
  per-workspace).
- `workbench.ts`: `updateWorkbenchFontSize()` and
  `updateWorkbenchFontFamily()` follow the same pattern as the existing
  `updateFontAliasing()` and `updateWorkbenchTextDirection()` — they
  react to `onDidChangeConfiguration`, validate/clamp the incoming
  value, and update the CSS custom property (or class) on
  `mainContainer` immediately with no reload required.

Fixes microsoft#519
Copilot AI review requested due to automatic review settings May 30, 2026 16:20
@DisturbedSage5840C
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds new workbench-level configuration settings to customize the UI font size, font family, and text direction independent of the editor.

Changes:

  • Introduces workbench.fontSize and workbench.fontFamily configuration settings.
  • Adds runtime handlers in Workbench to apply font size, font family, and text direction via CSS variables and DOM attributes.
  • Updates workbench stylesheet to consume the new CSS variables.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/vs/workbench/browser/workbench.contribution.ts Registers new workbench.fontSize and workbench.fontFamily settings.
src/vs/workbench/browser/workbench.ts Adds update handlers wired to configuration changes and initial startup.
src/vs/workbench/browser/media/style.css Switches workbench font-size to a CSS variable and adds custom font-family override class.

Comment thread src/vs/workbench/browser/workbench.ts Outdated
Comment on lines +340 to +344
if (e && !e.affectsConfiguration('workbench.textDirection')) {
return;
}

const raw = configurationService.getValue<string>('workbench.textDirection');
Comment on lines +703 to +710
'workbench.fontSize': {
'type': 'number',
'default': 13,
'minimum': 11,
'maximum': 16,
'description': localize('workbench.fontSize', "Controls the font size in pixels of the workbench UI (sidebar, tabs, status bar, etc.). Does not affect the editor. Requires a reload to update virtual-scroll views such as the file explorer."),
'scope': ConfigurationScope.APPLICATION
},
Comment on lines +711 to +716
'workbench.fontFamily': {
'type': 'string',
'default': '',
'description': localize('workbench.fontFamily', "Controls the font family of the workbench UI. When set, overrides the platform default font. Leave empty to use the platform default."),
'scope': ConfigurationScope.APPLICATION
},
Comment thread src/vs/workbench/browser/workbench.ts Outdated
Comment on lines +234 to +237
this._register(configurationService.onDidChangeConfiguration(e => this.updateFontAliasing(e, configurationService)));
this._register(configurationService.onDidChangeConfiguration(e => this.updateWorkbenchTextDirection(e, configurationService)));
this._register(configurationService.onDidChangeConfiguration(e => this.updateWorkbenchFontSize(e, configurationService)));
this._register(configurationService.onDidChangeConfiguration(e => this.updateWorkbenchFontFamily(e, configurationService)));
Comment thread src/vs/workbench/browser/workbench.ts Outdated
}

const raw = configurationService.getValue<string>('workbench.textDirection');
const direction: 'ltr' | 'rtl' = raw === 'rtl' ? 'rtl' : 'ltr';
DisturbedSage added 2 commits May 30, 2026 21:54
- Remove accidental textDirection code that leaked in from stash (belongs
  to a separate PR); this PR is scoped to fontSize/fontFamily only
- Broaden workbench.fontSize range from 11-16 to 8-30 to cover
  accessibility use cases (large UI text) and high-density displays
- Consolidate four separate onDidChangeConfiguration listeners into one
  shared subscription to reduce event-handling overhead
- Strip CSS injection characters (;, {, }, <, >, newlines) from
  workbench.fontFamily before embedding in a CSS custom property
- Update fontSize clamp to match the new 8-30 schema range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to change the font size and font of the workbench

3 participants