更新 : 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) のフォント列挙体は、そのフォントの最新のバージョンを返します。バージョン情報で解決できない場合は、タイムスタンプが最新のフォントが返されます。タイムスタンプ情報が同じである場合は、アルファベット順で最初のフォント ファイルが返されます。