Click or drag to resize
CanvasFontSet Constructor
Initializes a new instance of the CanvasFontSet class from an application URI.

Namespace:  Microsoft.Graphics.Canvas.Text
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
C#
public CanvasFontSet(
	Uri uri
)

Parameters

uri
Type: SystemUri
Remarks

The passed-in URI must be a valid application URI, which begins with either ms-appx:// or ms-appdata://. This allows apps to specify a font file- for example, a TTF file, that's distributed with the application.

The resulting CanvasFontSet contains font faces from the specified URI, and no other fonts.

Often, a single font file contains not just one font face, but several. For example, the built-in system font Gabriola contains the font faces "Regular", "Oblique", and "Bold", all within the file "Gabriola.ttf". For this reason a URI is used to produce a CanvasFontSet, rather than a single CanvasFontFace.

Constructing a font set is a way of verifying that a font file is valid and supported by Win2D.

For example:

var fontSet = new CanvasFontSet(new Uri("ms-appx:///imageTiger.jpg"));
if (fontSet.Fonts.Count == 0)
{
    // No fonts could be loaded from the set.
    // ...
}

Constructing a font set from a URI which isn't a supported font file will yield an empty font set.

See Also