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.
Warning 0.9.45.0 BETA 1005
Neither derived class can be created, so none of the members on this page can be used. See the warning on InstalledFontCollection and on PrivateFontCollection. The rest of this page describes the members as the source defines them.
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
- InstalledFontCollection class – the fonts installed on the system
- PrivateFontCollection class – fonts loaded from files or memory for one program
- FontFamily class – one member of a collection
- Font class
- FontCollection class – Microsoft’s GDI+ reference