Click or drag to resize
CanvasGeometryCreateText Method
Creates a geometry based on a text layout.

Namespace:  Microsoft.Graphics.Canvas.Geometry
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version:
public static CanvasGeometry CreateText(
	CanvasTextLayout textLayout


Type: Microsoft.Graphics.Canvas.TextCanvasTextLayout

Return Value

Type: CanvasGeometry

Treating text as geometry expands your app's options for how it can draw text, and do things not ordinarily possible when drawing text through text layouts. Once text is turned into geometry, it can be manipulated with CombineWith Overload, or used to produce widened strokes, or read back by the app, like any arbitrary geometry.

For example, if an app needs to trace the contours of some text with a dashed line, it could do the following:

CanvasGeometry geometry = CanvasGeometry.CreateText(textLayout);            

CanvasStrokeStyle dashedStroke = new CanvasStrokeStyle()
    DashStyle = CanvasDashStyle.Dash

drawingSession.DrawGeometry(geometry, Colors.White, 2.0f, dashedStroke);

For simple text-drawing scenarios which don't actually require text as geometry, it's recommended that you use DrawText Overload or DrawTextLayout Overload to draw text.

Creating geometry from text is a one-directional operation; it isn't possible to obtain text back from a geometry.

See Also