Share via


Fonts.GetTypefaces 方法

定義

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

多載

GetTypefaces(String)

從表示字型目錄位置的字串值傳回 Typeface 物件的集合。

GetTypefaces(Uri)

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

GetTypefaces(Uri, String)

使用基底統一資源識別項值傳回 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。 因為此參數會被視為路徑或 URI,所以您無法傳遞 null

範例

下列範例示範如何使用這個方法,從字型位置傳回物件的集合 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)

使用基底統一資源識別項值傳回 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

適用於