Click or drag to resize
CanvasTextFormat Class
Describes font and layout options for drawing text.
Inheritance Hierarchy
SystemObject
  Microsoft.Graphics.Canvas.TextCanvasTextFormat

Namespace:  Microsoft.Graphics.Canvas.Text
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
C#
public sealed class CanvasTextFormat : IDisposable

The CanvasTextFormat type exposes the following members.

Constructors
  NameDescription
Public methodCanvasTextFormat
Initializes a new instance of the CanvasTextFormat class.
Top
Properties
  NameDescription
Public propertyCustomTrimmingSign
Gets or sets a custom trimming sign.
Public propertyDirection
Specifies the direction in which the text is read.
Public propertyFontFamily
Specifies the font family name (Arial, Times New Roman, etc.)
Public propertyFontSize
Specifies the font size.
Public propertyFontStretch
Specifies the degree to which the font is stretched, compared to the normal aspect ratio of that font.
Public propertyFontStyle
Specifies the style of a font face (for example, normal or italic).
Public propertyFontWeight
Specifies the density of a typeface, in terms of the lightness or heaviness of the strokes.
Public propertyHorizontalAlignment
Specifies the horizontal paragraph alignment.
Public propertyIncrementalTabStop
Specifies the incremental tab stop position.
Public propertyLastLineWrapping
Specifies whether the last line is wrapped.
Public propertyLineSpacing
Negative values use default line spacing; non-negative values specify the line height.
Public propertyLineSpacingBaseline
Specifies the distance from top of line to baseline. A reasonable ratio to lineSpacing is 80 percent.
Public propertyLineSpacingMode
[Win10] Specifies how lines are spaced apart.
Public propertyLocaleName
Specifies the locale name.
Public propertyOpticalAlignment
Specifies how glyphs are aligned to the margin.
Public propertyOptions
Specifies text drawing options.
Public propertyTrimmingDelimiter
A character code used as the delimiter that signals the beginning of the portion of text to be preserved. Most useful for path ellipsis, where the delimiter would be a slash.
Public propertyTrimmingDelimiterCount
A value that indicates how many occurrences of the delimiter to step back.
Public propertyTrimmingGranularity
Specifies the granularity used to trim text overflowing the layout box.
Public propertyTrimmingSign
Specifies the type of trimming sign used, when text is drawn outside a text layout's requested size extents.
Public propertyVerticalAlignment
Specifies the vertical paragraph alignment.
Public propertyVerticalGlyphOrientation
Specifies the orientation of glyphs when a vertical reading direction is used.
Public propertyWordWrapping
Specifies word wrapping behavior.
Top
Methods
Remarks

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

Examples
Create a CanvasTextFormat with reasonable defaults:
var format = new CanvasTextFormat();
Using a specific font:
var format = new CanvasTextFormat()
{
    FontFamily = "Arial"
};
With clipping enabled:
var format = new CanvasTextFormat()
{
    Options = CanvasDrawTextOptions.Clip
};
Using a font loaded from a TTF file shipped with the application:
var format = new CanvasTextFormat()
{
    FontFamily = "CustomFont.ttf#CustomFont"
};
See Also