PeachDrawing.Text

PeachDrawing.Text.Typeface

Typeface.TryGetOutline Method

Overloads  
TryGetOutline(ushort, GlyphOutline) Reads the shape of a glyph, in design units with the y axis up.
TryGetOutline(ushort, OutlineRequest, GlyphOutline) Reads the shape of a glyph as TryGetOutline(ushort, GlyphOutline) does, at a size and, if asked, fitted to the pixel grid.

Typeface.TryGetOutline(ushort, GlyphOutline) Method

Reads the shape of a glyph, in design units with the y axis up.

public bool TryGetOutline(ushort glyph, out PeachDrawing.Text.Outlines.GlyphOutline outline);

Parameters

glyph System.UInt16

The glyph.

outline GlyphOutline

The outline. It is empty when the method returns false.

Returns

System.Boolean
false when the font has no usable outline for the glyph, or the glyph has no ink (a space).

Remarks

TrueType (glyf) outlines are supported, with composite glyphs flattened into one outline (a component placed by matching points and not by an offset is placed at no offset), and so are CFF outlines where the charstrings use the supported operators, and the CFF2 outlines of a variable font at the location of this typeface (WithAxes(IEnumerable<AxisSetting>)), with every blend resolved (the coordinates are then not whole numbers). Nothing is grid-fitted: hinting instructions are not run.

Typeface.TryGetOutline(ushort, OutlineRequest, GlyphOutline) Method

Reads the shape of a glyph as TryGetOutline(ushort, GlyphOutline) does, at a size and, if asked, fitted to the pixel grid.

public bool TryGetOutline(ushort glyph, in PeachDrawing.Text.Outlines.OutlineRequest request, out PeachDrawing.Text.Outlines.GlyphOutline outline);

Parameters

glyph System.UInt16

The glyph.

request OutlineRequest

The size, and how much to fit the outline to the pixel grid.

outline GlyphOutline

The outline. It is empty when the method returns false.

Returns

System.Boolean
false when the font has no usable outline for the glyph, or the glyph has no ink (a space).

Exceptions

System.ArgumentOutOfRangeException
GridFitting is not a defined value, or is not None and PixelsPerEm is not a positive number.

Remarks

With None the result is exactly the design-unit outline of TryGetOutline(ushort, GlyphOutline). Otherwise the coordinates are in pixels at PixelsPerEm, y up, with the glyph origin at (0, 0). A TrueType font’s own instructions are run, and the stem hints and blue zones of a CFF font’s charstrings are applied, so points sit where the font’s designer put them at that size; the result is IsGridFitted and carries GridFittedAdvance. A font that cannot be grid-fitted (it has neither TrueType instructions nor CFF hints to apply, or they fail) gets the scaled design outline and IsGridFitted is false; nothing throws for a font that is merely unusable. Hinted outlines are cached, so asking again for the same glyph and size is cheap; the outline is then shared by every caller that asks, which is safe because an outline never changes. Only the outline is fitted: a caller that lays text out keeps using the design advances of GetAdvance(ushort). A font with CFF outlines is also thickened at its stems when StemDarkening asks for it.