Editar

Compartilhar via


Fonts.GetTypefaces Method

Definition

Returns the collection of Typeface objects from a specified directory location.

Overloads

GetTypefaces(String)

Returns the collection of Typeface objects from a string value that represents the font directory location.

GetTypefaces(Uri)

Returns a collection of Typeface objects from a uniform resource identifier (URI) value that represents the font location.

GetTypefaces(Uri, String)

Returns a collection of Typeface objects using a base uniform resource identifier (URI) value to resolve the font location.

GetTypefaces(String)

Returns the collection of Typeface objects from a string value that represents the font directory location.

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

Parameters

location
String

The location that contains the fonts.

Returns

An ICollection<T> of Typeface objects that represent the fonts in location.

Exceptions

The location is null. You cannot pass null, because this parameter is treated as a path or URI.

Examples

The following example shows how to use this method to return the collection of Typeface objects from a font location.

foreach (Typeface typeface in Fonts.GetTypefaces("D:/MyFonts/"))
{
    // Perform action.
}
For Each typeface As Typeface In Fonts.GetTypefaces("D:/MyFonts/")
    ' Perform action.
Next typeface

Applies to

GetTypefaces(Uri)

Returns a collection of Typeface objects from a uniform resource identifier (URI) value that represents the font location.

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

Parameters

baseUri
Uri

The base URI value of the location of the fonts.

Returns

An ICollection<T> of Typeface objects that represent the fonts in baseUri.

Examples

The following example shows how to use this method to return the collection of Typeface objects from a base URI location.

foreach (Typeface typeface in Fonts.GetTypefaces("file:///D:/MyFonts/"))
{
    // Perform action.
}
For Each typeface As Typeface In Fonts.GetTypefaces("file:///D:/MyFonts/")
    ' Perform action.
Next typeface

To return the collection of Typeface objects in an application's resources, use the "pack://application" URI notation shown in the following example.

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

Applies to

GetTypefaces(Uri, String)

Returns a collection of Typeface objects using a base uniform resource identifier (URI) value to resolve the font location.

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

Parameters

baseUri
Uri

The base URI value of the location of the fonts.

location
String

The location that contains the fonts.

Returns

An ICollection<T> of Typeface objects that represent the fonts in the resolved font location.

Examples

The following example shows how to use this method to return the collection of Typeface objects from the resolved font location. In this case, the application contains a subdirectory named "resources".

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

Applies to