Fonts.GetFontFamilies Methode

Definition

Gibt die Auflistung von FontFamily-Objekten aus einem angegebenen Speicherort für Schriftarten zurück.

Überlädt

GetFontFamilies(String)

Gibt die Auflistung von FontFamily-Objekten aus einem Zeichenfolgenwert zurück, der den Speicherort der Schriftarten darstellt.

GetFontFamilies(Uri)

Gibt eine Sammlung von FontFamily-Objekten aus einem URI-Wert (Uniform Resource Identifier) zurück, der den Speicherort der Schriftarten darstellt.

GetFontFamilies(Uri, String)

Gibt unter Verwendung eines URI-Basiswerts (Uniform Resource Identifier) zum Auflösen des Schriftartspeicherorts eine Sammlung von FontFamily-Objekten zurück.

GetFontFamilies(String)

Gibt die Auflistung von FontFamily-Objekten aus einem Zeichenfolgenwert zurück, der den Speicherort der Schriftarten darstellt.

public:
 static System::Collections::Generic::ICollection<System::Windows::Media::FontFamily ^> ^ GetFontFamilies(System::String ^ location);
public static System.Collections.Generic.ICollection<System.Windows.Media.FontFamily> GetFontFamilies (string location);
static member GetFontFamilies : string -> System.Collections.Generic.ICollection<System.Windows.Media.FontFamily>
Public Shared Function GetFontFamilies (location As String) As ICollection(Of FontFamily)

Parameter

location
String

Der Speicherort, der die Schriftarten enthält.

Gibt zurück

ICollection<FontFamily>

Eine ICollection<T> von FontFamily-Objekten, die die Schriftarten in location darstellen.

Ausnahmen

location ist null. Sie können null nicht übergeben, da dieser Parameter als Pfad oder URI behandelt wird.

Beispiele

Im folgenden Beispiel wird gezeigt, wie Sie diese Methode verwenden, um die Auflistung von FontFamily Objekten an einem Schriftartspeicherort zurückzugeben.

// Return the font family collection for the selected directory location.
System.Collections.Generic.ICollection<FontFamily> fontFamilies = Fonts.GetFontFamilies("C:/MyFonts");

// Enumerate through the font family collection.
foreach (FontFamily fontFamily in fontFamilies)
{
    // Separate the URI directory source info from the font family name.
    string[] familyName = fontFamily.Source.Split('#');

    // Add the font family name to the fonts combo box.
    comboBoxFonts.Items.Add(familyName[familyName.Length - 1]);
}

comboBoxFonts.SelectedIndex = 0;
' Return the font family collection for the selected directory location.
Dim fontFamilies As System.Collections.Generic.ICollection(Of FontFamily) = Fonts.GetFontFamilies("C:/MyFonts")

' Enumerate through the font family collection.
For Each fontFamily As FontFamily In fontFamilies
    ' Separate the URI directory source info from the font family name.
    Dim familyName() As String = fontFamily.Source.Split("#"c)

    ' Add the font family name to the fonts combo box.
    comboBoxFonts.Items.Add(familyName(familyName.Length - 1))
Next fontFamily

comboBoxFonts.SelectedIndex = 0

Gilt für

GetFontFamilies(Uri)

Gibt eine Sammlung von FontFamily-Objekten aus einem URI-Wert (Uniform Resource Identifier) zurück, der den Speicherort der Schriftarten darstellt.

public:
 static System::Collections::Generic::ICollection<System::Windows::Media::FontFamily ^> ^ GetFontFamilies(Uri ^ baseUri);
public static System.Collections.Generic.ICollection<System.Windows.Media.FontFamily> GetFontFamilies (Uri baseUri);
static member GetFontFamilies : Uri -> System.Collections.Generic.ICollection<System.Windows.Media.FontFamily>
Public Shared Function GetFontFamilies (baseUri As Uri) As ICollection(Of FontFamily)

Parameter

baseUri
Uri

Der URI-Basiswert des Speicherorts für die Schriftarten.

Gibt zurück

ICollection<FontFamily>

Eine ICollection<T> von FontFamily-Objekten, die die Schriftarten in baseUri darstellen.

Beispiele

Im folgenden Beispiel wird gezeigt, wie Sie diese Methode verwenden, um die Auflistung von FontFamily Objekten aus einem Basis-URI-Speicherort zurückzugeben.

foreach (FontFamily fontFamily in Fonts.GetFontFamilies("file:///D:/MyFonts/"))
{
    // Perform action.
}
For Each fontFamily As FontFamily In Fonts.GetFontFamilies("file:///D:/MyFonts/")
    ' Perform action.
Next fontFamily

Um die Auflistung von Objekten in den Ressourcen einer FontFamily Anwendung zurückzugeben, verwenden Sie die URI-Notation "pack://application", die im folgenden Beispiel gezeigt wird.

foreach (FontFamily fontFamily in Fonts.GetFontFamilies(new Uri("pack://application:,,,/")))
{
    // Perform action.
}
For Each fontFamily As FontFamily In Fonts.GetFontFamilies(New Uri("pack://application:,,,/"))
    ' Perform action.
Next fontFamily

Gilt für

GetFontFamilies(Uri, String)

Gibt unter Verwendung eines URI-Basiswerts (Uniform Resource Identifier) zum Auflösen des Schriftartspeicherorts eine Sammlung von FontFamily-Objekten zurück.

public:
 static System::Collections::Generic::ICollection<System::Windows::Media::FontFamily ^> ^ GetFontFamilies(Uri ^ baseUri, System::String ^ location);
public static System.Collections.Generic.ICollection<System.Windows.Media.FontFamily> GetFontFamilies (Uri baseUri, string location);
static member GetFontFamilies : Uri * string -> System.Collections.Generic.ICollection<System.Windows.Media.FontFamily>
Public Shared Function GetFontFamilies (baseUri As Uri, location As String) As ICollection(Of FontFamily)

Parameter

baseUri
Uri

Der URI-Basiswert des Speicherorts für die Schriftarten.

location
String

Der Speicherort, der die Schriftarten enthält.

Gibt zurück

ICollection<FontFamily>

Eine ICollection<T> von FontFamily-Objekten, die die Schriftarten am aufgelösten Schriftartspeicherort darstellen.

Beispiele

Im folgenden Beispiel wird gezeigt, wie Sie diese Methode verwenden, um die Auflistung von FontFamily Objekten vom aufgelösten Schriftspeicherort zurückzugeben. In diesem Fall enthält die Anwendung ein Unterverzeichnis mit dem Namen „Ressourcen“.

foreach (FontFamily fontFamily in Fonts.GetFontFamilies(new Uri("pack://application:,,,/"), "./resources/"))
{
    // Perform action.
}
For Each fontFamily As FontFamily In Fonts.GetFontFamilies(New Uri("pack://application:,,,/"), "./resources/")
    ' Perform action.
Next fontFamily

Gilt für