FontCollection.GetFamilyCount method

Applies to: desktop apps only

The FontCollection::GetFamilyCount method gets the number of font families contained in this font collection.

Syntax

INT GetFamilyCount() const;

Parameters

This method has no parameters.

Return value

Type:

Type: INT

This method returns the number of font families contained in this font collection.

Remarks

A font family consists of a single font type with related styles. An example of a single font type is Arial Regular. An example of a font family is a set of fonts containing Arial Regular, Arial Italic, and Arial Bold style fonts.

Examples

The following example creates a PrivateFontCollection object, gets the number of FontFamily objects contained within the collection, and outputs that number.


VOID Example_GetFamilyCount(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a PrivateFontCollection object, and add three families.
   PrivateFontCollection fontCollection;
   fontCollection.AddFontFile(L"C:\\WINNT\\Fonts\\Arial.ttf");
   fontCollection.AddFontFile(L"C:\\WINNT\\Fonts\\CourBI.ttf");
   fontCollection.AddFontFile(L"C:\\WINNT\\Fonts\\TimesBd.ttf");

   // Get the number of font families in the collection.
   int numFamilies = fontCollection.GetFamilyCount();

   // Print the number of families as text.
   SolidBrush solidbrush(Color(255, 0, 0, 0));
   Font       font(L"Arial", 16);
   WCHAR      string[256];
   swprintf_s(string, L"There are %i families in fontCollection.", numFamilies);
   graphics.DrawString(string,
                       wcslen(string), &font, PointF(0, 0), &solidbrush);
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusheaders.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

FontCollection
PrivateFontCollection
Using Text and Fonts

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show: