Paint all available font families : Font Collection « GUI « VB.Net Tutorial






Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Drawing.Text

public class PaintAllAvailableFonts
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class

public class Form1
  Inherits System.Windows.Forms.Form

  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim g As Graphics = e.Graphics

        g.Clear(Me.BackColor)

        Dim families As FontFamily() = FontFamily.GetFamilies(g)

        Dim familiesFont As Font
        Dim familyString As String
        Dim spacing As Single = 0
        Dim family As FontFamily
        For Each family In families
            familiesFont = New Font(family, 16, FontStyle.Bold)
            familyString = "This is the " + family.Name + "family."
            g.DrawString(familyString, familiesFont, Brushes.Black, New PointF(0, spacing))
            spacing += familiesFont.Height
        Next family

        g.Dispose()
  End Sub

  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen

  End Sub

End Class








14.72.Font Collection
14.72.1.Installed Font Collection
14.72.2.List all font family name
14.72.3.Paint all available font families