Skip to content

Feature: Added thumbnail generation for items in the Windows Fonts folder#17843

Open
workbysaran wants to merge 4 commits into
files-community:mainfrom
workbysaran:sg/feature-sysfonts-thumbnails
Open

Feature: Added thumbnail generation for items in the Windows Fonts folder#17843
workbysaran wants to merge 4 commits into
files-community:mainfrom
workbysaran:sg/feature-sysfonts-thumbnails

Conversation

@workbysaran

@workbysaran workbysaran commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

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 thread src/Files.App/ViewModels/ShellViewModel.cs Outdated
Comment thread src/Files.App/Utils/Storage/Helpers/FileThumbnailHelper.cs
@yair100 yair100 added the ready for review Pull requests that are ready for review label Nov 11, 2025
…thumbnail generation to system fonts folder only
@yair100 yair100 added changes requested Changes are needed for this pull request and removed ready for review Pull requests that are ready for review labels Apr 26, 2026
@yair100

yair100 commented Jun 5, 2026

Copy link
Copy Markdown
Member

@workbysaran can you please rebase this PR from main and share a screenshot comparing the generated thumbnails with File Explorer? Thanks!

@workbysaran

workbysaran commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@workbysaran can you please rebase this PR from main and share a screenshot comparing the generated thumbnails with File Explorer? Thanks!

@yair100 Done, rebased from main

I have also attached the screenshots.
Windows Explorer
Windows Explorer

Files
Files

During my testing, I noticed the following,

  1. Windows File Explorer groups font thumbnails by font family, whereas Files displays each font separately.
  2. There is a sorting issue because the sorting is based on the file name rather than the font name.

@yair100

yair100 commented Jun 8, 2026

Copy link
Copy Markdown
Member

During my testing, I noticed the following,
Windows File Explorer groups font thumbnails by font family, whereas Files displays each font separately.
There is a sorting issue because the sorting is based on the file name rather than the font name.

@workbysaran I can reproduce both of these as well. For the time being, let's go back to displaying the actual file name. This will resolve the sorting issue and will prevent duplicate names from appearing in the list of fonts.

I pushed a commit with this change.

@yair100 yair100 force-pushed the sg/feature-sysfonts-thumbnails branch from 9ea4bd1 to 205c49e Compare June 8, 2026 22:02
@yair100 yair100 requested review from 0x5bfa and d2dyno1 June 9, 2026 14:09
@yair100 yair100 added ready for review Pull requests that are ready for review and removed changes requested Changes are needed for this pull request labels Jun 9, 2026
@yair100 yair100 changed the title Feature: Add font file thumbnail generation and display font names Feature: Added thumbnail generation for items in the Windows Fonts folder Jun 9, 2026

@0x5bfa 0x5bfa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, in File Explorer, there's a custom shell folder CLSID_FontFolder in fontext.dll. In that DLL, I found a similar implementation to this, extracting a font file to draw "Abg". We can switch to this in the future.

Comment on lines +21 to +34
if (!isFolder && !iconOptions.HasFlag(IconOptions.ReturnIconOnly))
{
var extension = Path.GetExtension(path);

//Restrict to only %windir%\fonts
if (FileExtensionHelpers.IsFontFile(extension) && PathHelpers.IsInSystemFontsFolder(path))
{
var winrtThumbnail = await FontFileHelper.GetWinRTThumbnailAsync(path, (uint)size);
if (winrtThumbnail is not null)
return winrtThumbnail;

if (!extension.Equals(".fon", StringComparison.OrdinalIgnoreCase))
{
var fontThumbnail = await STATask.Run(() => FontFileHelper.GenerateFontThumbnail(path, (int)size), App.Logger);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IconOptions.ReturnOnlyIfCached is ignored?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you see that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReturnOnlyIfCached is not taken into account for this scenario. This returns thumbnail regardless

try
{
var fullPath = Path.GetFullPath(path);
var windowsFontsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Fonts");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to add trailing backslash.

}
}

public static string? GetFontName(string fontPath)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not used?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anymore. @workbysaran can you please remove this?

return memoryStream.ToArray();
}
}
catch (Exception ex)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
catch (Exception ex)
catch (Exception ex)

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

3 participants