Uredi

Deli z drugimi prek


FontFamily Constructors

Definition

Initializes a new instance of the FontFamily class.

Overloads

FontFamily()

Initializes a new instance of an anonymous FontFamily class.

FontFamily(String)

Initializes a new instance of the FontFamily class from the specified font family name.

FontFamily(Uri, String)

Initializes a new instance of the FontFamily class from the specified font family name and an optional base uniform resource identifier (URI) value.

FontFamily()

Initializes a new instance of an anonymous FontFamily class.

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

Remarks

Use this parameterless constructor when you want to create a composite font programmatically. This means that you do not have to specify a font family name for the constructor, but you must populate the collections in the FamilyMaps and FamilyNames collections prior to using the constructed instance.

Applies to

FontFamily(String)

Initializes a new instance of the FontFamily class from the specified font family name.

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)

Parameters

familyName
String

The family name or names that comprise the new FontFamily. Multiple family names should be separated by commas.

Exceptions

familyName cannot be null.

Examples

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

Remarks

Each family name that is specified in the familyName parameter can be preceded by a location reference to either a directory or a uniform resource identifier (URI). The location reference is separated from the family name by a pound (#) character. Multiple family names that are specified in the familyName parameter must be separated by commas.

Each family can be a real font that directly represents a set of font files that share the same family name, or can be a reference to a family name that is defined in a composite font file.

When multiple families are identified, the second and subsequent font families serve as fallback families, handling code points that are not supported by the first font family. For every code point that is not supported by the first font family, each subsequent family is checked in turn.

Applies to

FontFamily(Uri, String)

Initializes a new instance of the FontFamily class from the specified font family name and an optional base uniform resource identifier (URI) value.

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)

Parameters

baseUri
Uri

Specifies the base URI that is used to resolve familyName.

familyName
String

The family name or names that comprise the new FontFamily. Multiple family names should be separated by commas.

Examples

The following code shows a font reference that is composed of a base URI value and a relative URI value.

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

Remarks

The familyName value can specify a relative URI value, which requires a base URI to resolve the font reference. The baseUri value can be null.

Applies to