Export (0) Print
Expand All

FontCollection.GetFamilies method

Applies to: desktop apps only

The FontCollection::GetFamilies method gets the font families contained in this font collection.

Syntax

Status GetFamilies(
  [in]   INT numSought,
  [out]  FontFamily *gpfamilies,
  [out]  INT *numFound
) const;

Parameters

numSought [in]

Type: INT

Integer that specifies the number of font families in this font collection.

gpfamilies [out]

Type: FontFamily*

Pointer to an array that receives the FontFamily objects.

numFound [out]

Type: INT*

Pointer to an INT that receives the number of font families found in this collection. This number should be the same as the numSought value.

Return value

Type:

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration. If the method fails, it returns one of the other elements of the Status enumeration.

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 FontFamily objects contained within the collection, and uses one of the font families to draw text.


VOID Example_GetFamilies(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");

   // Create an array to hold the font families, and get the font families of
   // fontCollection.
   FontFamily families[3];
   int numFamilies;
   fontCollection.GetFamilies(3, families, &numFamilies);

   // Create a Font object from the first FontFamily object in the array.
   Font myFont(&families[0], 16);

   // Use myFont to draw text.
   SolidBrush solidbrush(Color(255, 0, 0, 0));
   WCHAR string[] = L"This is an Arial font";
   graphics.DrawString(string,
                       21, &myFont, 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
FontFamily
FontCollection::GetFamilyCount
PrivateFontCollection
Using Text and Fonts

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show:
© 2014 Microsoft