We help IT Professionals succeed at work.

List font names and their appropriate family font names

tfos asked
Last Modified: 2012-05-05
I am looking to get a list of font family names and the font names side by sides.

I found this code from microsoft's site, I am not a programmer but learning :-)

This is what I would like to output
File Name        Font Family Name
Arial.ttf              Arial
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
 strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Fonts"
objReg.EnumValues HKEY_LOCAL_MACHINE, _
For Each entry in arrEntryNames
    iTotalFonts = iTotalFonts + 1
    If InStr(1, LCase(entry), "truetype") Then
        iTTFonts = iTTFonts + 1
        Wscript.Echo entry
    End If
Wscript.Echo "TrueType:  " & iTTFonts
Wscript.Echo "Total:  " & iTotalFonts

Open in new window

Watch Question

This will do what you're looking for, just run it with cscript.exe from a command line.  Output to a file if you want a txt version of it.  i.e.  --  cscript.exe c:\pathtoscript\fonts.vbs > c:\temp\fonts.txt

This only enumerates the values of the Fonts registry key.  There may be a better way to display the list of installed fonts programatically, but I dunno how.
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
wscript.echo "File Name" & vbTab & vbTab & "Font Family Name"
wscript.echo "---------------------------------------------------------------"
oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames
For each strValueName in arrValueNames
	oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
	wscript.echo strValue & vbTab & vbTab & strValueName
set oReg = Nothing

Open in new window

Hi tfos

I have tidied up your code and added comments to help you learn what is happening. I've also tested it.
I've added the crucial extra that gives you your file name as well as the font name.

Copy and paste into notepad and save as a .vbs file (turn off word wrap)
from a CMD window type
go to the path location you saved script to and type
cscript.exe filename.vbs

The output is each entry per line.
You can output to file by adding the > c:\outputfile.txt to the end of the command above and even change the Dash in the code to a coma to make it a csv output for Excel or like.

Apologies if i'm  over helping here but i'm assuming nothing.

Hope it helps


Option Explicit ' use only declared variables (avoids errors)
' Declare variables
	Dim oReg			' Registry Object
	Dim strComputer		' Holds computer name
	dim sRegKeyPath		' Holds the Registry Path
	dim sRegName		' Holds the Registry Name
	dim sRegData		' Gets the value for each Name
	Dim iTotalFonts		' Counter for each font found
	dim iTTFonts		' Counter for each font name that has TrueType in its name
	Dim aRegName		' Array for each name found
	Const HKEY_LOCAL_MACHINE = &H80000002		' Permanent HEX value held in this variable
' Set the value to the computer this script runs on
	strComputer = "."
' Use WMI to bind to the registry on this computer
	Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
		strComputer & "\root\default:StdRegProv")
' Set the registry path we want to look in
	sRegKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Fonts"
' Bind to the path and get all the names in to the array variable
	oReg.EnumValues HKEY_LOCAL_MACHINE, sRegKeyPath, aRegName
' Loop through each name found (held in array variable)
	For Each sRegName in aRegName
		iTotalFonts = iTotalFonts + 1	' Count each font found as we go round
			' Only count the ones with truetype in name
			If InStr(1, LCase(sRegName), "truetype") Then
				iTTFonts = iTTFonts + 1
			End If
		' Get the string value from the name
		oReg.GetStringValue HKEY_LOCAL_MACHINE, sRegKeyPath, sRegName, sRegData
		' Output in a Command window the result on each line
		Wscript.Echo sRegName & " - " & sRegData
	Next	' look at the next name in the array variable
' At the end tell us the numbers of all fonts and TrueType fonts
	Wscript.Echo "TrueType:  " & iTTFonts
	Wscript.Echo "Total:  " & iTotalFonts

Open in new window

Unlock this solution and get a sample of our free trial.
(No credit card required)
If you want to shed the "(TrueType)" from the end of all the TTF entries, add the following line above the echo in the for loop:

if instr(strValueName," (TrueType)") then strValueName = replace(strValueName, " (TrueType)","")
ltlbearand3's way is probably the best way to do it.  I forgot about using .Namespace(FONTS) - that's what I was trying to think of before.


That is exactly what I was looking for, much thanks

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.