FontFamily 建構函式

定義

初始化 FontFamily 類別的新執行個體。

多載

FontFamily()

初始化匿名 FontFamily 類別的新執行個體。

FontFamily(String)

從指定的字型系列名稱初始化 FontFamily 類別的新執行個體。

FontFamily(Uri, String)

從指定的字型系列名稱和選擇性基底統一資源識別項 (URI) 值,初始化 FontFamily 類別的新執行個體。

FontFamily()

初始化匿名 FontFamily 類別的新執行個體。

public:
 FontFamily();
public FontFamily ();
Public Sub New ()

備註

當您想要以程式設計方式建立複合字型時,請使用這個無參數建構函式。 這表示您不需要指定建構函式的字型系列名稱,但您必須先填入 和 FamilyNames 集合中的 FamilyMaps 集合,才能使用建構的實例。

適用於

FontFamily(String)

從指定的字型系列名稱初始化 FontFamily 類別的新執行個體。

public:
 FontFamily(System::String ^ familyName);
public FontFamily (string familyName);
new System.Windows.Media.FontFamily : string -> System.Windows.Media.FontFamily
Public Sub New (familyName As String)

參數

familyName
String

組成新 FontFamily 的系列名稱。 多個系列名稱應該以逗號分隔。

例外狀況

familyName 不可以是 null

範例

// Return the font family using an implied reference for a font in the default system font directory.
FontFamily fontFamily1 = new FontFamily("Arial Narrow");

// Return the font family using a directory reference for the font name.
FontFamily fontFamily2 = new FontFamily("C:/MyFonts/#Pericles Light");

// Return the font family using a URI reference for the font name.
FontFamily fontFamily3 = new FontFamily("file:///C:\\Windows\\Fonts\\#Palatino Linotype");
' Return the font family using an implied reference for a font in the default system font directory.
Dim fontFamily1 As New FontFamily("Arial Narrow")

' Return the font family using a directory reference for the font name.
Dim fontFamily2 As New FontFamily("C:/MyFonts/#Pericles Light")

' Return the font family using a URI reference for the font name.
Dim fontFamily3 As New FontFamily("file:///C:\Windows\Fonts\#Palatino Linotype")

備註

參數中指定的 familyName 每個系列名稱都可以在目錄或統一資源識別項 (URI) 的位置參考前面。 位置參考會以) 字元的磅 # (來分隔系列名稱。 參數中指定的 familyName 多個系列名稱必須以逗號分隔。

每個系列都可以是實際字型,直接代表共用相同系列名稱的一組字型檔案,也可以是複合字型檔案中定義之系列名稱的參考。

識別多個系列時,第二個和後續字型系列會做為後援系列,處理第一個字型系列不支援的程式碼點。 針對第一個字型系列不支援的每個字碼點,會接著檢查每個後續系列。

適用於

FontFamily(Uri, String)

從指定的字型系列名稱和選擇性基底統一資源識別項 (URI) 值,初始化 FontFamily 類別的新執行個體。

public:
 FontFamily(Uri ^ baseUri, System::String ^ familyName);
public FontFamily (Uri baseUri, string familyName);
new System.Windows.Media.FontFamily : Uri * string -> System.Windows.Media.FontFamily
Public Sub New (baseUri As Uri, familyName As String)

參數

baseUri
Uri

指定用來解析 familyName 的基底 URI。

familyName
String

組成新 FontFamily 的系列名稱。 多個系列名稱應該以逗號分隔。

範例

下列程式碼顯示由基底 URI 值和相對 URI 值組成的字型參考。

// The font resource reference includes the base URI reference (application directory level),
// and a relative URI reference.
myTextBlock.FontFamily = new FontFamily(new Uri("pack://application:,,,/"), "./resources/#Pericles Light");
' The font resource reference includes the base URI reference (application directory level),
' and a relative URI reference.
myTextBlock.FontFamily = New FontFamily(New Uri("pack://application:,,,/"), "./resources/#Pericles Light")

備註

此值 familyName 可以指定相對 URI 值,這需要基底 URI 來解析字型參考。 此值 baseUri 可以是 null

適用於