Click or drag to resize
CanvasTypography Class
Represents a collection of typography features.
Inheritance Hierarchy

Namespace:  Microsoft.Graphics.Canvas.Text
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version:
public sealed class CanvasTypography : IDisposable

The CanvasTypography type exposes the following members.

Public methodCanvasTypography
Initializes a new instance of the CanvasTypography class.
Public methodAddFeature(CanvasTypographyFeature)
Adds an OpenType font feature.
Public methodAddFeature(CanvasTypographyFeatureName, UInt32)
Adds an OpenType font feature.
Public methodDispose
Releases all resources used by the CanvasTypography.
Public methodGetFeatures
Gets an array of all the OpenType font features that comprise this CanvasTypography.

As an example of how to apply a typography option to a piece of text:

var typography = new CanvasTypography();
typography.AddFeature(CanvasTypographyFeatureName.ContextualSwash, 1);

var format = new CanvasTextFormat();
var textLayout = new CanvasTextLayout(resourceCreator, "Abc", format, 100, 100);
textLayout.SetTypography(1, 1, typography);

A CanvasTypography is mutable; adding features will modify it. It's valid to add the same feature multiple times, regardless of the parameter.

Not all features are supported by all fonts. If a feature is not supported by the font being used with the typography option, the feature will simply be ignored.

While font features treat their parameters in different ways, there is a general convention that setting a feature's parameter to zero disables the feature, and a nonzero parameter enables it.

When using Direct2D interop, this Win2D class corresponds to the DirectWrite interface IDWriteTypography.

See Also