You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix user mode fonts to install & add repair support - #6619
Align user-scope font installation with the machine-scope model to address fonts missing from Windows discovery after sign-out or restart.
Install user fonts directly into %LOCALAPPDATA%\Microsoft\Windows\Fonts and register their absolute paths under HKCU\Software\Microsoft\Windows NT\CurrentVersion\Fonts.
Track original filenames separately from collision-renamed installed files using the same package inventory mapping strategy for both scopes.
Add font repair using installed package metadata. Repair migrates existing nested user installations to the flat layout and restores discovery registrations without downloading fonts.
Update validation, inventory, and uninstall to handle both layouts. Remove only mapped files and matching registrations, preserving unrelated files and the shared Fonts directory.
Machine-scope discovery registrations retain their relative filename values. Migration rollback is per-file and best effort.
AppInstallerCLITests.exe '[fonts],[FontHelper],[RepairFlow]' Passed: 334 assertions in 29 test cases. wingetdev font list --details --disable-interactivity: passed against the locally deployed dev build with fonts enabled.
Did manual validation of corrupt fonts and font repair with Microsoft.FluentFonts and ryanoasis.CaskaydiaCove fonts being installed in the user scope. I installed these using existing Winget, confirmed after reboot that the fonts stopped working. Then ran the repair using the updated winget cli winget repair FONT\User\Microsoft.FluentFonts
The repair was successful, the detailed font list no longer showed as corrupt, and the fonts were showing up in the font list again. After reboot I confirmed the repaired user fonts are still available in the font list, which confirms the bug, successful repair, and that the new user install works.
Preserve font and pre-indexed source test hooks.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a9e21d38-9ab1-4358-963d-9aadad897ad0
Add a regression for volatile shared test keys and acknowledge fontlayout in the spelling dictionary.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a9e21d38-9ab1-4358-963d-9aadad897ad0
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved font-path collisions and overly restrictive filename validation can block valid installs, repairs, and uninstalls, while malformed inventory mappings can truncate font listings.
This PR addresses user fonts disappearing after sign-out or restart by aligning their installation layout with machine-scope fonts. It also adds repair support using installed metadata, without downloading fonts.
Changes:
Install user fonts directly in the shared Fonts directory with absolute-path discovery registrations.
Add repair to migrate legacy nested installations and restore registrations.
Update inventory, validation, uninstall, and tests for both layouts and filename collisions.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Font filename collisions can block installation or repair at the 255-character boundary, while repeated per-font mapping scans introduce quadratic overhead in font listings and installed-source population.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Suffix collisions can exceed the filesystem filename limit
src/AppInstallerCommonCore/Fonts.cpp:241
When a 255-character ASCII font filename collides, appending the first numeric suffix produces a 256-character name that exceeds the filesystem component limit and fails IsFontFileNameSafe. This prevents a second user-scope package with that filename from installing, and prevents legacy repair when the destination name is occupied. Reserve space for the suffix and extension using a Unicode-safe truncation or hashing strategy, and add a collision test at the 255-character boundary.
Repeated mapping scans make package font enumeration quadratic
src/AppInstallerCommonCore/Fonts.cpp:621
GetRegisteredFontInstallPath now reads and validates every package mapping for each font, so enumerating a package with N fonts performs N² mapping reads and validations. This affects both detailed font listings and installed-source population through FontHelper::PopulateIndex, where installed paths previously bypassed the mapping scan. Load and validate the mappings once per package version and reuse them across its files in both inventory paths.
I don't know why, but the last review brought up some missed items and then didn't make them specific comments. Maybe people don't like the never-ending churn of feedback.
The one about making the lookup N^2 seems bad though. The max path one less so, but if you are going to push an update...
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A malformed font mapping in one package version aborts enumeration of all remaining versions, causing valid legacy user fonts to disappear from the detailed inventory.
I don't know why, but the last review brought up some missed items and then didn't make them specific comments. Maybe people don't like the never-ending churn of feedback.
The one about making the lookup N^2 seems bad though. The max path one less so, but if you are going to push an update...
Yes that was no bueno; I fixed the quadratic issue in the previous push after seeing the obscured finding. A little annoying that something like that doesn't bubble up to a meaningful comment but a comment typo is urgent!
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Repeated scans of the shared font registry can cause quadratic work during package enumeration and routine source indexing, warranting human assessment of the performance impact.
The reason will be displayed to describe this comment to others. Learn more.
Could this use Windows-compatible filename identity instead of full Unicode case folding? For example, ß.ttf and ss.ttf are distinct Windows filenames but FoldCase maps both paths to the same key. GetFontRegistrations then selects both registrations, so uninstalling one font deletes the other font's discovery registration as well. Please add a cross-package regression showing that uninstalling ß.ttf preserves the registration for ss.ttf.
The reason will be displayed to describe this comment to others. Learn more.
If the key needs to map uniqueness onto the file system, we would probably need to find a Windows API to canonicalize (it is possible that the existing normalized string can do it the way the filesystem does). For direct path comparison, it is probably better to use std::filesystem::equivalent than case folded comparison. But that doesn't allow for a sort and thus a map container.
A middle ground would be to use case-folded strings for the initial hash map, then a vector of items containing the original path and linear std::filesystem::equivalent search.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📖 Description
Align user-scope font installation with the machine-scope model to address fonts missing from Windows discovery after sign-out or restart.
%LOCALAPPDATA%\Microsoft\Windows\Fontsand register their absolute paths underHKCU\Software\Microsoft\Windows NT\CurrentVersion\Fonts.Machine-scope discovery registrations retain their relative filename values. Migration rollback is per-file and best effort.
🔗 References
Addresses #6535.
🔍 Validation
Automated coverage checks exact inventory filenames, flat installation paths, REG_SZ discovery values, scope isolation, filename collisions, repair migration, failure handling, and uninstall cleanup.
AppInstallerCLITests.exe '[fonts],[FontHelper],[RepairFlow]'
Passed: 334 assertions in 29 test cases.
wingetdev font list --details --disable-interactivity: passed against the locally deployed dev build with fonts enabled.Did manual validation of corrupt fonts and font repair with Microsoft.FluentFonts and ryanoasis.CaskaydiaCove fonts being installed in the user scope. I installed these using existing Winget, confirmed after reboot that the fonts stopped working. Then ran the repair using the updated winget cli
winget repair FONT\User\Microsoft.FluentFontsThe repair was successful, the detailed font list no longer showed as corrupt, and the fonts were showing up in the font list again. After reboot I confirmed the repaired user fonts are still available in the font list, which confirms the bug, successful repair, and that the new user install works.
✅ Checklist
🤖 AI Assistance
📋 Issue Type
Microsoft Reviewers: Open in CodeFlow