PeachDrawing.Text

PeachDrawing.Text

Typeface Class

One face of a family: what a TypefaceFamily hands back when it matches a TypefaceQuery. It has no size; the size of text is the caller’s to keep.

public sealed class Typeface : System.IEquatable<PeachDrawing.Text.Typeface>

Inheritance System.Object → Typeface

Implements System.IEquatable<Typeface>

Remarks

Two typefaces are equal when they read the same font data, whichever query matched them. A typeface stays valid for as long as it is referenced, including after the FontSet that found it is gone. Reading a typeface, its Metrics included, is safe from any number of threads at once.

Properties  
Axes The axes of a variable font, in the order the font lists them. Empty for a font that is not variable.
AxisSettings Where this typeface reads its font’s design space: the value on every axis, in the order of Axes. Empty for a font that is not variable.
ColorPalette The colours that colour glyphs of this face are painted with, or null when HasColorGlyphs is false or the face has no CPAL table, as a face with pictures for glyphs has not.
ContentHash A hash of the font data the face reads, as 32 lowercase hexadecimal digits. Two typefaces that read the same data have the same hash, so it can key a cache of things made from a face, such as an embedded copy of it.
FamilyName The family name the font file declares, in English, such as Arial.
FullName The full name of the face as its font file declares it, such as Arial Bold Italic: the family and the style together. A font that does not declare one gets a name made from its family name.
HasBitmapGlyphs Whether the face draws colour glyphs as pictures, one per glyph and size (CBDT/CBLC or sbix), and not from outlines. Almost every font has none.
HasColorGlyphs Whether the face is one that a renderer draws colour glyphs from: it has COLR and CPAL tables over TrueType outlines, it draws its glyphs as pictures (HasBitmapGlyphs), or it has SVG documents for glyphs (HasSvgGlyphs). A colour font with CFF outlines and only COLR reports false.
HasMathData Whether the face is made for setting mathematics, which is to say it has a MATH table.
HasSvgGlyphs Whether the face has SVG documents that draw glyphs (the SVG table). Almost every font has none.
HasVerticalMetrics Whether the font has vertical metrics of its own (vhea and vmtx). Without them GetVerticalAdvance(ushort) answers one em, which is what the OpenType specification allows.
HasVerticalOrigin Whether the font has a VORG table that is trusted. The specification allows one only in a font with CFF outlines, so a TrueType-outline font never reports it, whatever tables it carries.
IsBold Whether the font file declares the face bold (in its OS/2 table).
IsItalic Whether the font file declares the face italic (in its OS/2 table).
IsVariable Whether the face is a variable font: one file that holds a whole design space, which WithAxes(IEnumerable<AxisSetting>) reads at a location.
MathData The MATH table of a face that has one: the constants, per-glyph information and stretchy-glyph variants a math layout algorithm reads.
Metrics The vertical dimensions of the face, in design units.
NamedVariations The named locations of a variable font (such as Bold or Light Condensed). Empty for a font that is not variable.
StyleName The style name the font file declares, in English, such as Bold Italic.
VariationKey A string that names the location of this typeface in its font’s design space, such as wght=700;wdth=100, and is empty for a typeface at its font’s defaults (and for a font that is not variable). Together with ContentHash it identifies what a typeface draws, so it can key a cache of things made from it.
Methods  
GetAdvance(ushort) The horizontal advance of a glyph, in design units (the hmtx table).
GetColorLayerPaint(int) The paint at an entry of the layer list, which a PaintColrLayers node refers to by index, at this typeface’s location.
GetColorPaint(ushort) The root of the paint graph of a version 1 colour glyph, or null when the glyph has none: the face has no version 1 COLR table, or no paint for this glyph.
GetVerticalAdvance(ushort) The advance of a glyph along the vertical axis that a vertical run of text stacks its glyphs on, in design units.
GetVerticalOrigin(ushort) The vertical origin of a glyph, in design units relative to its horizontal origin: where the glyph hangs from when text is set vertically.
HasGlyph(Rune) Whether the font has a glyph of its own for a character, which is to say TryMapRune(Rune, ushort) succeeds.
MatchesEmojiPresentation(Rune, EmojiPresentation) Whether the face is one to prefer for a character drawn in a presentation: its cmap format 14 says it supports the matching variation sequence or, when it declares nothing, its colour-ness agrees (a colour font for emoji presentation, an outline font for text presentation).
SupportsFeatures(IReadOnlySet<string>) Whether the font’s GSUB table has an active lookup for every one of the OpenType feature tags.
TryGetBitmap(ushort, double, EmbeddedBitmap) The picture of a glyph from the strike best suited to a font size.
TryGetColorClipBox(ushort, ColorClipBox) The clip box of a version 1 colour glyph: a rectangle that holds everything the glyph paints, at this typeface’s location.
TryGetColorLayers(ushort, IReadOnlyList<ColorLayer>) The layers of a version 0 colour glyph, painted in order from the bottom layer up, each a glyph in one palette colour.
TryGetGridFittedAdvance(ushort, OutlineRequest, double) The advance of a glyph in pixels after grid-fitting at a size: a whole number of pixels, as the font’s hinting leaves it. It is what GridFittedAdvance gives too, and also answers for a glyph with no ink, which has no outline.
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.
TryGetScriptPosition(ScriptPlacement, ScriptPosition) How the font’s designer wants subscripts or superscripts drawn (the recommended values of the OS/2 table).
TryGetSvgGlyph(ushort, SvgGlyph) The SVG document that draws a glyph.
TryMapRune(Rune, ushort) Finds the glyph a character is drawn with, through the font’s cmap. Characters of the Basic Multilingual Plane are found in the format 4 subtable; the others need a format 12 subtable.
WithAxes(IEnumerable<AxisSetting>) The typeface of a variable font at a location in its design space.