I’m trying to use Linq to loop through all fonts in the %windir%\Fonts folder and find the one that has a property title of “Arial” (or any Font Family name supplied), but I can’t seem to access the font properties (things like “Title”, “Font style”, “Designed for”, etc.).
The following is only giving me the basic file info:
Dim fontDir = Environment.GetEnvironmentVariable("windir") & "\Fonts\"
Dim fontFiles = From file In My.Computer.FileSystem.GetFiles(fontDir)
Dim fontInfo = From fontFile In fontFiles Select _
My.Computer.FileSystem.GetFileInfo(fontFile)
What I’d love to put on the end is something like ...Where fontFile.Title = "Arial". Any advice here?
The reason I need to do this is to find the one with one or more properties, like Title, and then physically copy that font file to another directory.
Instead of doing that you can use the framwework
System.Drawing.Text.InstalledFontCollectionclass and ask for the installed font. Get the list and use linq to execute that.Alternatively, doing it with your way above you will have to load the font into
System.Drawing.Text.PrivateFontCollectionthen applied query just like above to find the font.Edited to add this so other can spot it easily:
To find the file association, I had to do it by enumerating one or both of these registry key to find the font name and their corresponding font file. The font folder is always located in “%Windows%\Fonts”