GlyphHinter Class
Decodes the outlines of the glyphs of a font fitted to the pixel grid of a size: hinted outlines are sharper at small sizes, where an exactly scaled outline puts its edges across pixels.
public sealed class GlyphHinter : IDisposableRemarks
The outlines are given in font units, like those of FontFace.DecodeOutline: multiplied by the size divided by FontFace.UnitsPerEm, their hinted coordinates are on the pixel grid, with the origin of the glyph at a whole pixel. The y axis goes up.
GlyphHinting.Full runs the TrueType instructions of the font (OpenType specification, "TrueType Instructions"), with the version 40 interpreter of FreeType hinting for black and white pixels (FT_LOAD_TARGET_MONO) as the reference. A font program or a control value program that breaks a rule of the specification makes the font unhinted; instructions of a glyph that break one make that glyph unhinted. The work of the programs is bounded: each run charges every instruction to a GlyphBudget, and the stack, the storage area, the control values, the functions and the twilight zone are sized from the font and rented from the allocator.
A hinter keeps the state of the programs of the font at its size: it is used by one operation at a time, and must be disposed to give its storage back to the allocator.
- Implements
Properties
| Name | Description |
|---|---|
| Hinting | Gets how the outlines are hinted: the mode asked for, or GlyphHinting.Light when GlyphHinting.Full was asked for a font whose instructions cannot be run. |
| Size | Gets the size the outlines are hinted for, in pixels per em. |
Hinting
GlyphHinter.csGets how the outlines are hinted: the mode asked for, or GlyphHinting.Light when GlyphHinting.Full was asked for a font whose instructions cannot be run.
public GlyphHinting Hinting { get; }Property value
Size
GlyphHinter.csMethods
| Name | Description |
|---|---|
| Create(FontFace, double, GlyphHinting, GlyphScratch, FontAllocator) | Creates a hinter for a font at a size: with GlyphHinting.Full, runs the font program and the control value program. |
| DecodeOutline(int, OutlineSink, GlyphScratch, GlyphBudget) | Decodes the hinted outline of a glyph into a sink, in font units, and gives its advance. |
| Dispose() | Gives back the storage of the state of the instructions. |
Create(FontFace, double, GlyphHinting, GlyphScratch, FontAllocator)
GlyphHinter.csCreates a hinter for a font at a size: with GlyphHinting.Full, runs the font program and the control value program.
public static GlyphHinter Create(FontFace face, double size, GlyphHinting hinting, GlyphScratch scratch, FontAllocator allocator)Parameters
faceFontFace- The font.
sizedouble- The size, in pixels per em.
hintingGlyphHinting- How the outlines are hinted.
scratchGlyphScratch- The working storage of the glyphs the hinter measures to find the alignment zones of the font.
allocatorFontAllocator- The storage of the state of the TrueType instructions.
Returns
Exceptions
ArgumentOutOfRangeExceptionsizeis not a positive finite number, orhintingis not a defined value.InvalidFontException- The data of the font is malformed.
FontResourceLimitException- A program of the font exceeds the complexity limit, or its storage exceeds the allocation limit.
DecodeOutline(int, OutlineSink, GlyphScratch, GlyphBudget)
GlyphHinter.csDecodes the hinted outline of a glyph into a sink, in font units, and gives its advance.
public double DecodeOutline(int glyphId, OutlineSink sink, GlyphScratch scratch, ref GlyphBudget budget)Parameters
glyphIdint- The glyph.
sinkOutlineSink- The sink.
scratchGlyphScratch- The working storage of the outline.
budgetGlyphBudget- The budget of the glyph, which its instructions are charged to.
Returns
double The advance of the glyph, in pixels: a whole number with GlyphHinting.Full, the advance of the font scaled to the size otherwise.
Exceptions
ObjectDisposedException- The hinter is disposed.
InvalidFontException- The data of the glyph is malformed.
FontResourceLimitException- The glyph exceeds the complexity limit or the allocation limit.
Dispose()
GlyphHinter.csGives back the storage of the state of the instructions.
public void Dispose()