How to Get Font Properties from a Font File Name?

Instead of doing that you can use the framwework System.Drawing.Text. InstalledFontCollection class 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.

PrivateFontCollection then 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 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts.

Instead of doing that you can use the framwework System.Drawing.Text. InstalledFontCollection class 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. PrivateFontCollection then 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" HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts.

I do need access to the physical file once I've found what I needed. For example, in this case, I need to find the one that has Arial as the title and then copy the font file to a different directory. If InstalledFontCollection has a property of Path then I would use it for sure.

– Otaku Feb 25 '10 at 3:52 I remember I have done something on this in C++. Dig out some old code and found the way :) You actually have to enumerate registry key to find all the name of the font and the data is the font file. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts Write some code that will go through all the entries in this key.

The path to the font is always %windows%\Fonts folder. If you are not in controlled environment, try also to read this key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts – Fadrian Sudaman Feb 25 '10 at 12:44 This is really good. I've been looking at this key and it looks like it has what I need, for the most part.

How did you handle parsing of stuff that didn't match the " Name (TrueType)" pattern? I'm finding just a few odd balls, like Batang & BatangChe & Gungsuh & GungsuhChe (TrueType) *, *Roman (All res), Small Fonts (120), Segoe Condensed and Courier 10,12,15. Not too many, but I'm just wondering if it is documented somewhere about how names of fonts sit in this key so I can apply some RegEx against them.

– Otaku Feb 25 '10 at 15:53.

You should probably be using the System.Drawing.Text. InstalledFontCollection class instead of probing the filesystem directly. You could then do something like so: var arialFontFamilies = from fontFamily in new InstalledFontCollection().

Families where fontFamily.Name. Contains("Arial"); If you wanted to access more properties, you could create Font objects: var arialFonts = from fontFamily in new InstalledFontCollection(). Families where fontFamily.Name.

Contains("Arial") select new Font(fontFamily, FontSize. Regular); If you still need to access a custom set of fonts from anywhere on disk, you could use the PrivateFontCollection class: var fontFiles = from fileInfo in (from file in My.Computer.FileSystem. GetFiles(fontDir) select Computer.FileSystem.

GetFileInfo(file)); var privateFonts = new PrivateFontCollection(); foreach (var fontFile in fontFiles) { privateFonts. AddFontFile(fontFile. FullName); } var arialFonts = from fontFamily in new privateFonts.

Families where fontFamily.Name. Contains("Arial") select new Font(fontFamily, FontSize. Regular).

Interesting, I hadn't thought of that. Let me check it out. – Otaku Feb 25 '10 at 3:49 Unfortunately, it's not working.It still doesn't give me the font properties of Title, Font style, etc. – Otaku Feb 25 '10 at 4:10.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions