Finding a Font file from a Font name (VB.Net version)






1.77/5 (8 votes)
how to get the Font File Name from the Font Name
Finding a Font file from a Font name (VB.NET version)
Someone asked me to help him getting the "font file's name" from the "font name" (e.g. the file of "Arial" is "ARIAL.TTF" and located in %systemroot%\fonts folder); I found a nice solution on CodeProject site: http://www.codeproject.com/gdi/fontfile.asp. It was written using VisualC++ 6; I converted the code into VB.NET
What it Does
Retrieve font file name from a font's display name (which is name you will see in MS Word font combobox, for example). All Win32 versions of Windows, going back to original Win95, have a directory called "Fonts" under Windows directory. This directory is mirrored in registry under key HKLM\Software\Microsoft\Windows\CurrentVersion\Fonts. Except, of course, under NT, where "Windows" is replaced with "Windows NT".
I am searching the registery for the font name if not found I append "(True Type)" if not found I append "(All Res)".
How to Use It
There are 2 main functions in a VB.NET module
getOSVer
to get the OS version (to detrmine which registry key will be used)RegValue
to read a value from the registry