Frage

Ich habe einen WPF -Combobox, an das bindend ist

Me.fontComboFast.ItemsSource = Fonts.SystemFontFamilies


<ComboBox x:Name="fontComboFast">
    <ComboBox.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel />
        </ItemsPanelTemplate>
    </ComboBox.ItemsPanel>
    <ComboBox.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding}" FontFamily="{Binding}" FontSize="15" Height="20"/>
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>

Die folgende Ausnahme tritt auf. Wie wäre der beste Weg, um die Schriftarten zu beseitigen.

'Datei: /// c:/Programmdateien (x86)/Common Dateien/Adobe/Sing/Assoccache/generic.otf' Datei entspricht nicht der erwarteten Dateiformat -Spezifikation.

War es hilfreich?

Lösung

Okay, die folgende Stichprobe half Beispiel Schriftart Wähler

Der folgende Code schließt auch Symbol -Schriftarten aus, die in meiner Situation nicht verwendbar sind:

Friend Function IsSymbolFont(ByVal FontFamily As FontFamily) As Boolean
    For Each typeface As Typeface In FontFamily.GetTypefaces()
        Dim Face As New GlyphTypeface

        Try
            If typeface.TryGetGlyphTypeface(Face) Then
                Return Face.Symbol
            End If
        Catch e As Exception
            Return True
        End Try

    Next
    Return False
End Function
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top