FontCollection::GetFamilyCount 方法 (gdiplusheaders.h)

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

Syntax

INT GetFamilyCount();

傳回值

類型: INT

這個方法會傳回這個字型集合中包含的字型系列數目。

備註

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

範例

下列範例會建立 PrivateFontCollection 物件、取得集合中包含的 FontFamily 物件數目,以及輸出該數位。

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

規格需求

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

另請參閱

FontCollection

PrivateFontCollection

使用文字和字型