다음을 통해 공유


방법: 시스템 글꼴 열거

예제

다음 예제에서는 시스템 글꼴 컬렉션에 글꼴을 열거하는 방법을 보여 줍니다. SystemFontFamilies 내에 있는 각 FontFamily의 글꼴 패밀리 이름은 항목으로 콤보 상자에 추가됩니다.

        Public Sub FillFontComboBox(ByVal comboBoxFonts As ComboBox)
            ' Enumerate the current set of system fonts,
            ' and fill the combo box with the names of the fonts.
            For Each fontFamily As FontFamily In Fonts.SystemFontFamilies
                ' FontFamily.Source contains the font family name.
                comboBoxFonts.Items.Add(fontFamily.Source)
            Next fontFamily

            comboBoxFonts.SelectedIndex = 0
        End Sub
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) 글꼴 열거는 글꼴의 최신 버전을 반환합니다. 버전 정보로 문제가 해결되지 않는 경우에는 최신 타임스탬프가 있는 글꼴이 반환됩니다. 타임스탬프 정보도 같은 경우 사전순으로 먼저 정렬되는 글꼴 파일이 반환됩니다.