Table of Contents

Class GlyphContour

Namespace
Stride.CommunityToolkit.Rendering.Text
Assembly
Stride.CommunityToolkit.dll

One closed curve of a glyph: a start point and the segments that lead back to it.

public sealed class GlyphContour
Inheritance
GlyphContour

Remarks

Coordinates are EM units with the baseline at y = 0 and the pen at x = 0, y up: a capital letter is about 0.7 high. The last segment always ends at Start. Whether the contour is the outside of a shape or a hole in one is not known here; Flatten(int) works it out from how the contours nest.

Constructors

GlyphContour(Vector2, IEnumerable<OutlineSegment>)

Creates a contour.

public GlyphContour(Vector2 start, IEnumerable<OutlineSegment> segments)

Parameters

start Vector2

Where the first segment begins.

segments IEnumerable<OutlineSegment>

The segments, the last of which ends at start.

Exceptions

ArgumentNullException

The segments are null.

ArgumentException

There are no segments, or the last one does not end at start.

Properties

Segments

The segments in drawing order.

public IReadOnlyList<OutlineSegment> Segments { get; }

Property Value

IReadOnlyList<OutlineSegment>

Start

Where the first segment begins, and the last one ends.

public Vector2 Start { get; }

Property Value

Vector2

Methods

Flatten(int)

Turns the curves into a closed polygon.

public Vector2[] Flatten(int curveQuality = 32)

Parameters

curveQuality int

How many points a full turn of curve gets, so a tight bowl gets more points than a shallow one and a straight run gets none: a curve that bends through a quarter turn gets a quarter of this many segments, and never fewer than one. 32 is smooth at letter sizes; 8 is visibly faceted.

Returns

Vector2[]

The corners in order, without repeating the first at the end. Duplicate and collinear points are dropped, so a contour can come back with fewer than three points when it is degenerate.

Exceptions

ArgumentOutOfRangeException

The quality is not positive.