Skip to content

fix(fonts): list Windows fonts through Chromium instead of PowerShell and surface failures - #37369

Merged
nwparker merged 6 commits into
mainfrom
nwparker/fix-windows-font-enumeration
Nov 2, 2026
Merged

nwparker merged 6 commits into
mainfrom
nwparker/fix-windows-font-enumeration

Conversation

@nwparker

@nwparker nwparker commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On Windows the font picker got its list from a PowerShell System.Drawing.InstalledFontCollection script run by main. When Group Policy blocks Windows PowerShell, which is common on managed machines, the spawn fails. Main then substituted five hard-coded fonts, two of which usually aren't installed, and the picker showed no sign that anything had gone wrong.

Root cause: the Windows font list depended on a child process succeeding, and every failure was replaced with a fallback list that looked real. #15746 made the spawn use an absolute path, which fixed the PATH half of the problem but not the policy block.

Fix

  • Chromium enumerates Windows fonts. On the Windows desktop client, the renderer calls Chromium's Local Font Access API, window.queryLocalFonts() (installed-font-list.ts). There's no subprocess, no registry read and no font parsing in Orca. Main grants local-fonts in the main-window session's permission check handler, for the main window's main frame only, so there's no prompt and no user gesture.
    • Plugin panels and other subframes are refused. Sandboxed srcdoc frames also hit a Permissions Policy SecurityError.
    • Other pages on the default session (for example the hidden PDF export window) are refused.
    • The request handler still refuses local-fonts, so nothing can prompt.
  • PowerShell becomes the fallback. If queryLocalFonts throws or returns nothing, the renderer falls back to the existing IPC. That is PowerShell on Windows, and the unchanged system_profiler / fc-list path on macOS/Linux.
  • Failure is now visible. When the OS list can't be read, listSystemFontFamilies() logs the error and returns [] instead of a fake list. That fallback list was a copy of the renderer's getFallbackTerminalFonts(), which already seeds the suggestions, so it was deleted. When no list arrives, every FontAutocomplete shows a footer under the curated suggestions: "Couldn't list installed fonts. Type any installed font name to use it." Free-text entry was already accepted; the footer just says so. The flag clears again after a later success, and it is never shown on the web client, where browsers can't list fonts at all.
  • Startup and caching unchanged: nothing runs at startup, and lists are cached as before (Chromium caches its enumeration; main caches its own).

Closes #11771

Builds on earlier community attempts: #11785 by @umi008 (prefer pwsh, log failures) and #12595 by @dpfwpfahs1-coder (UTF-8 decoding of localized names). With Chromium as the primary source, neither the PowerShell resolution path nor its console encoding is on the common path any more.

Why queryLocalFonts instead of a native font parser

The first version of this PR read the registered font files' name/fvar/STAT tables in main. It worked: 181 families in 24 ms. But that is a hand-written binary parser that has to stay correct against arbitrary font files. Measured on the same Windows machine:

Source Families CSS-resolvable* Code in Orca
PowerShell / GDI (main today) 182 159 PowerShell script
Custom sfnt parser (dropped) 181 160 ~350 lines of binary parsing
queryLocalFonts() (this PR) 103 102** ~15 lines

* Resolvable means a canvas in Electron 43 renders the name with a different font than the generic fallback. GDI's list includes about 23 weight-named or truncated families, such as "Segoe UI Semilight" and "Bahnschrift SemiLight SemiConde", that Chromium cannot resolve.
** The remaining one is HYZhongHei, a CJK-only font; this check can't detect it because it measures Latin text.

queryLocalFonts returns typographic families ("Segoe UI", "Cascadia Code", "Noto Sans JP"). That matches CSS's family-plus-weight model, Orca's separate terminal font-weight settings, and what macOS already shows. Chromium maintains it, so this PR adds no parser code.

Visual proof

Real Windows 11 (awin-lan), electron-vite build. To simulate a Group Policy block, the PowerShell path in the @orca/process-host dist was pointed at a missing executable, so the spawn fails just as a policy block makes it fail.

Before (origin/main, PowerShell blocked): 5 hard-coded fonts, no sign of failure.
Before (origin/main, Windows, PowerShell blocked): 5 hard-coded fonts

After (PowerShell blocked): full installed list from queryLocalFonts.
After (Windows, PowerShell blocked): installed families from queryLocalFonts

After, every source failing (dark): local-fonts grant disabled and PowerShell blocked. Curated list plus the footer.
After, every source failing (dark): curated list plus footer

Validation

Windows (Windows 11 10.0.26200, awin-lan; isolated HOME/APPDATA/LOCALAPPDATA/user-data; CDP over a tunnel):

Build / condition Families Time
origin/main, PowerShell works 182 229 ms (PowerShell spawn; 187–218 ms standalone)
origin/main, PowerShell blocked 5 (fake fallback) 1 ms
this PR, PowerShell blocked 103 (315 faces) via queryLocalFonts 24 / 543 / 1251 ms on the first call after three cold launches; ~0 ms afterwards
this PR, local-fonts denied and PowerShell blocked 0, curated list plus footer n/a
  • No user gesture is needed once the check handler grants permission. A plain Electron 43.8.4 probe confirmed this: check-only grant returns 315 faces, request-only grant returns 0.
  • Frame scoping, exercised in the real app on Windows and macOS:
    • main frame: full list;
    • same-origin subframe: 0 fonts;
    • sandboxed srcdoc frame: SecurityError: ... "local-fonts" is disallowed by Permissions Policy.
  • macOS (this Mac, background launch with ORCA_BACKGROUND_LAUNCH=1, CDP 9363): the picker still uses system_profiler IPC, 257 families as on main. The picker renders normally in light and dark.
  • Checks: pnpm test src/main/system-fonts.test.ts src/main/window src/renderer/src/components/settings (1885 passed), pnpm tc:node, pnpm tc:web, oxlint, pnpm format, pnpm sync:localization-catalog.
  • Reviews: Opus sub-agent and Codex on the first version, plus an Opus review of the queryLocalFonts version. Fixed from that review: the grant is limited to the main window's webContents, and the web client doesn't show the footer.

Perf

Scanned with the perf-scan skill:

  • Trigger: font-picker focus only, once per Settings mount (latched); nothing at startup.
  • Where the work runs: queryLocalFonts enumeration runs in Chromium's browser process and is async to the renderer; the renderer only dedupes and sorts about 300 strings.
  • Subprocesses: on Windows the PowerShell spawn (about 190–230 ms of process start plus GDI+) is no longer on the common path.
  • Shared state: the footer flag is one module-level store with at most 4 mounted pickers subscribed.
  • Main thread: no main-process work added.

No findings.

Merge risk: Low

  • Size: the diff is +100/−60 lines. It adds no parser and no new native or IPC surface.
  • Blast radius: only the font suggestion list. The saved font setting is free text and unaffected; nothing is persisted or migrated.
  • Compatibility: the IPC shape is unchanged (string[]), and main and renderer ship together.
  • Permission grant: the one new permission grant is limited to the main window's main frame, and the real app confirmed subframes are refused.
  • macOS/Linux: enumeration is unchanged.

Negative user-facing tradeoffs

  • Fewer Windows entries. Suggestions are typographic families (103 here) instead of GDI's legacy weight-named families (182), so "Segoe UI Semibold", "Cascadia Code Light" or "Arial Black" are no longer listed separately; pick the family and use the font-weight settings. Saved values like "Cascadia Code SemiBold" keep working, and any name can still be typed.
  • English names on non-English Windows. queryLocalFonts returns English family names where InstalledFontCollection returned localized ones ("Malgun Gothic" vs "맑은 고딕"). Both resolve, and saved localized names keep working.
  • Main-window pages can list fonts without a prompt. That is the purpose of the grant; it is limited to the main window's main frame.
  • macOS/Linux failure now visible. If system_profiler/fc-list fails, the picker shows the footer where it used to show the same curated list silently.
  • Not done here (follow-up): on this Mac, queryLocalFonts returned the same 257 families in about 3 s versus about 9.6 s for system_profiler. Switching macOS/Linux is out of scope because this PR keeps their behaviour unchanged.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3be295d5-e5f7-4f18-a543-6cc582c5afa2
Commits

Reviewing files that changed from the base of the PR and between 4343dc2 and 76e2c82.

Files selected for processing: 8
  • src/main/system-fonts.test.ts
  • src/main/system-fonts.ts
  • src/main/window/attach-main-window-services.ts
  • src/renderer/src/components/settings/FontAutocomplete.tsx
  • src/renderer/src/components/settings/installed-font-list.ts
  • src/renderer/src/components/settings/use-settings-interaction-controller.ts
  • src/renderer/src/env.d.ts
  • src/renderer/src/i18n/locales/en.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@nwparker
nwparker force-pushed the nwparker/fix-windows-font-enumeration branch from b813d1d to ccdcf41 Compare November 2, 2026 06:38
@nwparker
nwparker force-pushed the nwparker/fix-windows-font-enumeration branch from 8eacf61 to 76e2c82 Compare November 2, 2026 06:53
@nwparker nwparker changed the title fix(fonts): enumerate Windows fonts without PowerShell and surface failures fix(fonts): list Windows fonts through Chromium instead of PowerShell and surface failures Nov 2, 2026
@nwparker
nwparker merged commit 522c7b6 into main Nov 2, 2026
48 checks passed
@nwparker
nwparker deleted the nwparker/fix-windows-font-enumeration branch November 2, 2026 08:11
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]: Windows font picker silently falls back to 5 hardcoded fonts when powershell.exe is Group Policy-blocked (listWindowsFonts spawns by bare name)

1 participant