Fonts.GetTypefaces 方法

定义

从指定的目录位置返回 Typeface 对象的集合。

重载

GetTypefaces(String)

从表示字体目录位置的字符串值返回 Typeface 对象的集合。

GetTypefaces(Uri)

从表示字体位置的统一资源标识符 (URI) 值返回 Typeface 对象的集合。

GetTypefaces(Uri, String)

通过使用基本统一资源标识符 (URI) 值来解析字体位置,返回 Typeface 对象的集合。

GetTypefaces(String)

从表示字体目录位置的字符串值返回 Typeface 对象的集合。

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)

参数

location
String

包含字体的位置。

返回

ICollection<Typeface>

ICollection<T> 对象的 Typeface,这些对象表示 location 中的字体。

例外

locationnull。 不能传递 null,因为此参数将作为路径或 URI 处理。

示例

下面的示例演示如何使用此方法从字体位置返回对象的集合 Typeface

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

适用于

GetTypefaces(Uri)

从表示字体位置的统一资源标识符 (URI) 值返回 Typeface 对象的集合。

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)

参数

baseUri
Uri

字体位置的基 URI 值。

返回

ICollection<Typeface>

ICollection<T> 对象的 Typeface,这些对象表示 baseUri 中的字体。

示例

以下示例演示如何使用此方法从基本 URI 位置返回对象的集合 Typeface

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

若要返回应用程序资源中的对象的集合 Typeface ,请使用以下示例中显示的“pack://application”URI 表示法。

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

适用于

GetTypefaces(Uri, String)

通过使用基本统一资源标识符 (URI) 值来解析字体位置,返回 Typeface 对象的集合。

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)

参数

baseUri
Uri

字体位置的基 URI 值。

location
String

包含字体的位置。

返回

ICollection<Typeface>

ICollection<T> 对象的 Typeface,这些对象表示已解析的字体位置中的字体。

示例

下面的示例演示如何使用此方法从解析的字体位置返回对象的集合 Typeface 。 在本示例中,应用程序包含一个名为“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

适用于