|
How to list the installed fonts with VB.NET |
|
|
|
|
Source Codes -
.NET
|
|
Written by Thomas Kaloyani
|
You have an application and you want to display all fonts that are installed on the system.
How would you do that?
Simply create a new instance of the class System.Drawing.Text.InstalledFontCollection. The specific class contains a list of object type of FontFamily which represent the installed fonts.
A sample code of retrieving the fonts that are installed on the system is the one below:
Private Function ListFonts()
Dim FontFamilyCollection As New InstalledFontCollection
Dim iOffset As Integer = 10
Dim oFontFamily As FontFamily
Try
For Each oFontFamily In FontFamilyCollection.Families
Dim lbl As New Label
lbl.Text = oFontFamily.Name
lbl.Font = New Font(oFontFamily, 14)
lbl.Left = 10
lbl.Width = Me.Width
lbl.Top = iOffset
Me.Controls.Add(lbl)
iOffset += 30
Next
Catch ex As Exception
End Try
End Function
Happy Coding!
About the author: Thomas is an experienced Visual Basic developer, with expertise of 7+ years developing especially financial applications. His main IT skills are VB, SQL, Crystal Reports - should you need a Visual Basic developer for your projects feel free to contact Thomas through his personal website at www.Kaloyani.com
Source: www.VBprofs.com |