Click or drag to resize
CanvasGeometryCreateGlyphRun Method
Creates a geometry based on a glyph run.

Namespace:  Microsoft.Graphics.Canvas.Geometry
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
C#
public static CanvasGeometry CreateGlyphRun(
	ICanvasResourceCreator resourceCreator,
	Vector2 point,
	CanvasFontFace fontFace,
	float fontSize,
	CanvasGlyph[] glyphs,
	bool isSideways,
	uint bidiLevel,
	CanvasTextMeasuringMode measuringMode,
	CanvasGlyphOrientation glyphOrientation
)

Parameters

resourceCreator
Type: Microsoft.Graphics.CanvasICanvasResourceCreator
point
Type: System.NumericsVector2
fontFace
Type: Microsoft.Graphics.Canvas.TextCanvasFontFace
fontSize
Type: SystemSingle
glyphs
Type: Microsoft.Graphics.Canvas.TextCanvasGlyph
isSideways
Type: SystemBoolean
bidiLevel
Type: SystemUInt32
measuringMode
Type: Microsoft.Graphics.Canvas.TextCanvasTextMeasuringMode
glyphOrientation
Type: Microsoft.Graphics.Canvas.TextCanvasGlyphOrientation

Return Value

Type: CanvasGeometry
Remarks

A custom text renderer's implementation of DrawGlyphRun may choose to convert the glyph run data it was passed into a geometry. This expands the app's options for how it can draw the geometry, and do things not ordinarily possible through DrawGlyphRun Overload. 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 individual glyph runs with a dashed line, it could do the following:

class MyTextRenderer : ICanvasTextRenderer
{
    ...

    public void DrawGlyphRun(
        Microsoft.Graphics.Canvas.Numerics.Vector2 position,
        CanvasFontFace fontFace,
        float fontSize,
        CanvasGlyph[] glyphs,
        bool isSideways,
        uint bidiLevel,
        object brush,
        CanvasTextMeasuringMode measuringMode,
        string locale,
        string textString,
        int[] custerMapIndices,
        uint textPosition,
        CanvasGlyphOrientation glyphOrientation)
        {
            CanvasGeometry geometry = CanvasGeometry.CreateGlyphRun(
                resourceCreator,
                position,
                fontFace,
                fontSize,
                glyphs,
                isSideways,
                bidiLevel,
                measuringMode,
                glyphOrientation);

            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 DrawGlyphRun Overload to draw the glyph runs.

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

The resource creator parameter can be null if the geometry will never be drawn onto a CanvasDevice.

See Also