FontCollection class

The base class of the two classes that hold a set of font families: InstalledFontCollection and PrivateFontCollection.

A FontCollection is not created on its own. It gives its two derived classes the members that list the families in the collection. A variable declared As FontCollection can hold either of them, which is how the fontCollection parameter of FontFamily and of Font accepts both. The class mirrors the GDI+ FontCollection class.

Creating

A FontCollection cannot be created. Create an InstalledFontCollection or a PrivateFontCollection instead.

Members

FamilyCount

Syntax: count = collection.FamilyCount

Returns a Long with the number of font families in the collection.

Families

Syntax: families = collection.Families( )

Returns an array of FontFamily objects, one for each family in the collection. The array is one-based: the lowest index is 1 and the highest is FamilyCount. When the call fails, nothing is returned.

A collection with no families has no array to return, and the call raises a run-time error. Check FamilyCount first when the collection may be empty.

Dim user As GdiPlusUser = GdiPlusUser()

Dim fonts As FontCollection = InstalledFontCollection()
Dim families() As FontFamily = fonts.Families
Dim i As Long
For i = 1 To fonts.FamilyCount
    Debug.Print families(i).FamilyName
Next

See Also