-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Feature: Add font file thumbnail generation and display font names #17843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feature: Add font file thumbnail generation and display font names #17843
Conversation
| var fontDisplayName = FontFileHelper.GetFontName(item.ItemPath); | ||
| if (!string.IsNullOrEmpty(fontDisplayName) && fontDisplayName != item.Name) | ||
| { | ||
| cts.Token.ThrowIfCancellationRequested(); | ||
| await dispatcherQueue.EnqueueOrInvokeAsync(() => | ||
| { | ||
| item.ItemNameRaw = fontDisplayName; | ||
| }); | ||
| await fileListCache.AddDisplayName(item.ItemPath, fontDisplayName); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: FontFileHelper.GetFontName() performs synchronous blocking I/O directly, potentially blocking the UI thread.
Severity: HIGH | Confidence: 0.95
🔍 Detailed Analysis
The FontFileHelper.GetFontName() method performs synchronous blocking file I/O operations, including reading font files and binary parsing, directly on the calling thread within LoadExtendedItemPropertiesAsync. This violates established threading patterns, causes inconsistent behavior compared to similar operations in the codebase, and can lead to noticeable UI delays when browsing directories containing multiple font files.
💡 Suggested Fix
Wrap the call to FontFileHelper.GetFontName(item.ItemPath) at line 1228 with await Win32Helper.StartSTATask() to offload the blocking operation to a background thread.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/Files.App/ViewModels/ShellViewModel.cs#L1225-L1238
Potential issue: The `FontFileHelper.GetFontName()` method performs synchronous blocking
file I/O operations, including reading font files and binary parsing, directly on the
calling thread within `LoadExtendedItemPropertiesAsync`. This violates established
threading patterns, causes inconsistent behavior compared to similar operations in the
codebase, and can lead to noticeable UI delays when browsing directories containing
multiple font files.
Did we get this right? 👍 / 👎 to inform future reviews.
| // Ensure size is at least 1 to prevent layout errors | ||
| size = Math.Max(1, size); | ||
|
|
||
| if (!isFolder && !iconOptions.HasFlag(IconOptions.ReturnIconOnly)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the issue with font thumbnails is only in the official fonts folder, would it make things simpler to only run this code in that location?
Resolved / Related Issues
Added support for generating font file thumbnails and displaying proper font names instead of filenames when browsing font directories.
Closes #17786
Steps used to test these changes