Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a list box on a form that shows font files that are stored on a network drive. Works great, but i need the list to show the font "family name" / "Title" and not the file name. ie: Arial, Arial Black, Calibri, Tahoma, etc.......

What I have tried:

Public Sub LoadList2()
       'loading list of fonts in network folder
       Dim directory = "c:\Odds & Ends\FontSync\MasterFontList"
       Dim files() As System.IO.FileInfo
       Dim dirinfo As New System.IO.DirectoryInfo(Directory)
       files = dirinfo.GetFiles()
       For Each file In files
           ListBox2.Items.Add(file.Name)
       Next
   End Sub
Posted
Updated 15-Jun-17 1:18am
Comments
ZurdoDev 15-Jun-17 7:09am    
How do you get the font family name from a font file?

1 solution

Try:
VB
Dim fontCol As New PrivateFontCollection()
fontCol.AddFontFile("D:\Test Data\MyFont.otf")
Console.WriteLine(fontCol.Families(0).Name)
 
Share this answer
 
Comments
Member 13009053 15-Jun-17 8:29am    
Thank you for the quick response. The code you provided appears to me that it would return the data for 1 single font. My desire is to populate the list box with all fonts that reside in a network folder.?
OriginalGriff 15-Jun-17 8:45am    
So use a loop ...
Member 13009053 16-Jun-17 22:24pm    
I have been looking for a solution to the "loop" thing, but have had no luck. Could you please provide a little assistance in displaying all fonts in a directory?
OriginalGriff 17-Jun-17 2:07am    
What part of it do you know how to do? Which bit is giving you problems?
OriginalGriff 17-Jun-17 2:08am    
Because you do say:
"I have created a list box on a form that shows font files that are stored on a network drive. Works great"
So it's difficult to see what help you need! :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900