Skip to content

Conversation

@workbysaran
Copy link
Contributor

@workbysaran workbysaran commented Nov 11, 2025

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

  1. Font file thumbnail display
    • Navigate to C:\Windows\Fonts
    • Verify font thumbnails load correctly for .ttf, .otf and .fon files
  2. Font name display
    • Verify file list shows "Arial Bold" instead of "arialbd.ttf"
    • Verify font names display correctly for various font files

Comment on lines +1228 to +1238
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);
}
}
Copy link

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))
Copy link
Member

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?

@yaira2 yaira2 added the ready for review Pull requests that are ready for review label Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Pull requests that are ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Show font file thumbnails in C:\WINDOWS\Fonts

2 participants