語言

Fonts.GetTypefaces 方法

定義

回傳指定目錄位置的物件集合 Typeface

多載

名稱 Description
GetTypefaces(String)

回傳來自字串值的物件集合 Typeface ,該值代表字型目錄的位置。

GetTypefaces(Uri)

從代表字型位置的統一資源識別碼(URI)值回傳一組 Typeface 物件。

GetTypefaces(Uri, String)

回傳一組 Typeface 物件,使用基本的統一資源識別碼(URI)值來解析字型位置。

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物件。

例外狀況

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

回傳一組 Typeface 物件,使用基本的統一資源識別碼(URI)值來解析字型位置。

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

適用於