Feature: Added thumbnail generation for items in the Windows Fonts folder#17843
Feature: Added thumbnail generation for items in the Windows Fonts folder#17843workbysaran wants to merge 4 commits into
Conversation
…thumbnail generation to system fonts folder only
|
@workbysaran can you please rebase this PR from |
@yair100 Done, rebased from main I have also attached the screenshots. During my testing, I noticed the following,
|
@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. |
9ea4bd1 to
205c49e
Compare
0x5bfa
left a comment
There was a problem hiding this comment.
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.
| 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); |
There was a problem hiding this comment.
IconOptions.ReturnOnlyIfCached is ignored?
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
Make sure to add trailing backslash.
| } | ||
| } | ||
|
|
||
| public static string? GetFontName(string fontPath) |
There was a problem hiding this comment.
Not anymore. @workbysaran can you please remove this?
| return memoryStream.ToArray(); | ||
| } | ||
| } | ||
| catch (Exception ex) |
There was a problem hiding this comment.
| catch (Exception ex) | |
| catch (Exception ex) |


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