Fonts.GetTypefaces 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从指定的目录位置返回对象的集合 Typeface 。
重载
| 名称 | 说明 |
|---|---|
| GetTypefaces(String) |
从表示字体目录位置的 Typeface 字符串值返回对象的集合。 |
| GetTypefaces(Uri) |
从表示字体位置的 Typeface 统一资源标识符(URI)值返回对象的集合。 |
| 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<T>Typeface表示字体的对象location。
例外
location 是 null。 无法传递 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)
从表示字体位置的 Typeface 统一资源标识符(URI)值返回对象的集合。
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<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<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