Skip to content

fix(settings): emit Windows font family names as UTF-8 - #12602

Merged
brennanb2025 merged 3 commits into
stablyai:mainfrom
bbingz:fix/12590-windows-font-picker-utf8
Aug 9, 2026
Merged

brennanb2025 merged 3 commits into
stablyai:mainfrom
bbingz:fix/12590-windows-font-picker-utf8

Conversation

@bbingz

@bbingz bbingz commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Windows PowerShell 5.1 can emit font family names with the console code page while Node always decodes stdout as UTF-8.
  • Force [Console]::OutputEncoding to UTF-8 before enumerating InstalledFontCollection.
  • Regression tests cover script UTF-8 pin and Korean name round-trip on the parse path.

Fixes #12590

Test plan

  • vitest src/main/system-fonts.test.ts (6/6)
  • Windows host PowerShell UTF-8 enumeration smoke

@coderabbitai

coderabbitai Bot commented Aug 5, 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 Plus

Run ID: 8c64a8d9-383b-45ee-9fc3-13fe0ef117b4

📥 Commits

Reviewing files that changed from the base of the PR and between d51710e and 5634434.

📒 Files selected for processing (2)
  • src/main/system-fonts.test.ts
  • src/main/system-fonts.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/system-fonts.test.ts

📝 Walkthrough

Walkthrough

Windows font discovery now configures PowerShell output encoding as UTF-8 before enumerating installed fonts. A test verifies that the encoding statement is the first statement in the generated command.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the summary and testing plan but omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add all missing template sections and complete the required testing checklist, noting when screenshots are not applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the Windows UTF-8 font-name fix.
Linked Issues check ✅ Passed The changes set PowerShell UTF-8 output and add regression coverage for localized Korean font names, meeting issue #12590 objectives.
Out of Scope Changes check ✅ Passed The changed source and test files directly support the linked issue and contain no unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4db41408-87a9-4d52-9359-b61c29a37863

📥 Commits

Reviewing files that changed from the base of the PR and between 7956335 and 66be0b227ef9e3e44fdb2093a52a7bd2b17a9a10.

📒 Files selected for processing (2)
  • src/main/system-fonts.test.ts
  • src/main/system-fonts.ts

Comment thread src/main/system-fonts.test.ts Resolved
Windows PowerShell 5.1 can write localized font names with the console
code page while Node always decodes stdout as UTF-8, which garbles
Korean and other non-ASCII family names in the font picker. Force
UTF-8 OutputEncoding before enumerating InstalledFontCollection (stablyai#12590).
@bbingz
bbingz force-pushed the fix/12590-windows-font-picker-utf8 branch from 66be0b2 to 6e511a2 Compare August 5, 2026 00:35
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Lock script order so OutputEncoding is set before InstalledFontCollection
enumeration, preventing a silent regression of the mojibake fix.
@AmethystLiang

Copy link
Copy Markdown
Contributor

Linked duplicate closed

Closing draft #12595 as the same fix for #12590 (Windows font family names need UTF-8 PowerShell output). Extra notes:

  • Draft was from the issue author (dpfwpfahs1-coder) on agent/fix-windows-font-list-utf8
  • Same files: src/main/system-fonts.ts + tests
  • Continue landing review on this ready PR

@bbingz

bbingz commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the triage on #12595. Nothing outstanding here:

  • CodeRabbit's only finding is addressed — src/main/system-fonts.test.ts now pins ordering by index ([Console]::OutputEncoding → $OutputEncoding = [Console]::OutputEncoding → $fonts.Families | ForEach-Object) instead of just asserting both strings exist, so enumeration can't drift above the UTF-8 setup.
  • The round-trip test covers the reported symptom directly: 굴림 / G마켓 산스 Medium / Consolas survive the PowerShell → Node hop.
  • MERGEABLE against current main, no unresolved threads.

Ready whenever you have a review slot.

One ask: the Actions suite on the current head is sitting at action_required (fork gate) — an "Approve and run workflows" click would give you a full green rollup to judge against.

`$OutputEncoding` only governs bytes piped to a native executable's stdin;
this script pipes to ForEach-Object, so it was inert. Drop it, and drop the
script-builder export whose only consumer was a test — the one-shot
`-Command` shape now matches windows-foreground-process-rows and ssh-browse,
while the BOM-less `UTF8Encoding::new($false)` spelling matches
powershell-osc133-bootstrap and antigravity/hook-service.

The test reaches the script through the public listSystemFontFamilies path
and pins the assignment as the script's first statement, so it fails on
removal, on a stdout write above it, and on a swapped encoding.
@bbingz

bbingz commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@brennanb2025 thanks for the cut-down — dropping $OutputEncoding (inert for this pipe shape) and the script-builder export, and matching the existing one-shot -Command / BOM-less UTF-8 patterns, is cleaner. Appreciated the public-path test pin too.

@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for this — the diagnosis is exactly right, and the one-line encoding pin is what ships.

Heads-up that I pushed a commit to your branch (563443486f) tightening it:

  • Dropped $OutputEncoding = [Console]::OutputEncoding. That variable only governs bytes PowerShell writes to a native executable's stdin; this script pipes to ForEach-Object, a cmdlet, so it was inert. [Console]::OutputEncoding alone is what controls redirected stdout, and it matches what our other one-shot PowerShell probes already do.
  • Removed the exported buildWindowsFontListScript(). Its only caller was the test, and the test can reach the same script through the public listSystemFontFamilies() path — so the module keeps its smaller surface.
  • Made the guard stronger. The old assertion only required the pin to appear somewhere above the enumeration, so a Write-Host inserted above it would ship every localized name in the old code page with a green suite. It now pins the assignment as the script's first statement and matches it exactly, so it fails on removal, on anything emitted above it, and on a swapped encoding.
  • Dropped the Korean round-trip assertion. execFile is mocked there, so it received an already-decoded JS string — it asserted the mock's own text and couldn't fail for an encoding reason. The first-statement guard covers the real contract.

Worth knowing: on localized systems the picker list will get longer after this, because distinct families previously decoded to the same run of replacement characters and were deduped into one entry.

Two follow-ups I noticed but deliberately left out of this PR:

  • A user who already selected a garbled name keeps that stored value — the picker shows the correct names, but the saved setting isn't migrated until they re-pick.
  • The enumeration forks PowerShell without windowsHide, so a console window flashes exactly when the picker opens. Pre-existing and unrelated to this fix.

@brennanb2025
brennanb2025 merged commit 371cc26 into stablyai:main Aug 9, 2026
43 checks passed
@bbingz

bbingz commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@brennanb2025 thank you for landing this — and for the earlier cut-down that kept the one-shot -Command / BOM-less UTF-8 shape. Glad #12590 is closed.

@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for the PR!! Appreciate the support 🙏

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(settings): emit Windows font family names as UTF-8

Windows PowerShell 5.1 can write localized font names with the console
code page while Node always decodes stdout as UTF-8, which garbles
Korean and other non-ASCII family names in the font picker. Force
UTF-8 OutputEncoding before enumerating InstalledFontCollection (stablyai#12590).

* test(settings): assert UTF-8 pin precedes Windows font enumeration

Lock script order so OutputEncoding is set before InstalledFontCollection
enumeration, preventing a silent regression of the mojibake fix.

* refactor(settings): cut the Windows font UTF-8 pin to the standard shape

`$OutputEncoding` only governs bytes piped to a native executable's stdin;
this script pipes to ForEach-Object, so it was inert. Drop it, and drop the
script-builder export whose only consumer was a test — the one-shot
`-Command` shape now matches windows-foreground-process-rows and ssh-browse,
while the BOM-less `UTF8Encoding::new($false)` spelling matches
powershell-osc133-bootstrap and antigravity/hook-service.

The test reaches the script through the public listSystemFontFamilies path
and pins the assignment as the script's first statement, so it fails on
removal, on a stdout write above it, and on a swapped encoding.

---------

Co-authored-by: Brennan Benson <[email protected]>
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 garbles localized font names without UTF-8 PowerShell output

3 participants