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(string location);

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.
}

Applies to

.NET Framework 4.8.1 i inne wersje
Produkt Wersje
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

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);

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.
}

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.
}

Applies to

.NET Framework 4.8.1 i inne wersje
Produkt Wersje
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

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, string location);

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.
}

Applies to

.NET Framework 4.8.1 i inne wersje
Produkt Wersje
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10