FontCollection::GetFamilies 方法 (gdiplusheaders.h)

FontCollection::GetFamilies 方法會取得這個字型集合中包含的字型系列。

語法

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

參數

[in] numSought

類型: INT

指定這個字型集合中字型系列數目的整數。

[out] gpfamilies

類型: FontFamily*

接收 FontFamily 對象的陣列指標。

[out] numFound

類型: INT*

接收這個集合中找到字型系列數目的 INT 指標。 這個數字應該與 numSought 值相同。

傳回值

類型: 狀態

如果方法成功,它會傳回Ok,這是 Status 列舉的元素。 如果方法失敗,它會傳回 Status 列舉的其中一個其他元素。

備註

字型系列是由具有相關樣式的單一字型類型所組成。 單一字型別的範例是 Arial Regular。 字型系列範例是一組字型,其中包含 Arial Regular、Arial Italic 和 Arial Bold 樣式字型。

範例

下列範例會建立 PrivateFontCollection 物件、取得集合中包含的 FontFamily 物件,並使用其中一個字型系列來繪製文字。

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);
}

規格需求

需求
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限傳統型應用程式]
最低支援的伺服器 Windows 2000 Server [僅限傳統型應用程式]
目標平台 Windows
標頭 gdiplusheaders.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

FontCollection

FontCollection::GetFamilyCount

FontFamily

PrivateFontCollection

使用文字和字型