共用方式為


HOW TO:列舉系統字型

更新:2007 年 11 月

範例

下列範例顯示如何列舉系統字型集合中的字型。SystemFontFamilies 內每個 FontFamily 的字型系列名稱都會加入成為下拉式方塊的項目。

public void FillFontComboBox(ComboBox comboBoxFonts)
{
    // Enumerate the current set of system fonts,
    // and fill the combo box with the names of the fonts.
    foreach (FontFamily fontFamily in Fonts.SystemFontFamilies)
    {
        // FontFamily.Source contains the font family name.
        comboBoxFonts.Items.Add(fontFamily.Source);
    }

    comboBoxFonts.SelectedIndex = 0;
}

如果同一字型系列,在相同目錄中有多個版本,則 Windows Presentation Foundation (WPF) 字型列舉型別會傳回最新的字型版本。如果版本資訊並未提供解決方式,則會傳回具有最近時間戳記的字型。如果時間戳記資訊相同,則會按照字母順序傳回第一個字型檔案。