Skip to main content

Metrics

Namespace: PinataLabs.Typography. Guide: Font and glyph metrics.

All values on this page are in font units unless the description says otherwise.

FontMetrics​

public abstract class FontMetrics

The metrics of one font face. Get it from Font.FontMetrics or FontFamily.TryGetMetrics.

PropertyTypeDescription
DescriptionFontDescriptionThe names and style of the face.
UnitsPerEmushortThe size of the design grid.
ScaleFactorfloatUnitsPerEm × 72.
HorizontalMetricsHorizontalMetricsMetrics for horizontal text.
VerticalMetricsVerticalMetricsMetrics for vertical text. Made from the horizontal metrics when the font has no vhea table.
UnderlinePositionshortThe distance from the baseline to the top of the underline. Negative is below the baseline.
UnderlineThicknessshortThe thickness of the underline.
StrikeoutPositionshortThe distance from the baseline to the top of the strike-out line.
StrikeoutSizeshortThe thickness of the strike-out line.
SubscriptXSize, SubscriptYSizeshortThe size of subscript glyphs.
SubscriptXOffset, SubscriptYOffsetshortThe offset of subscript glyphs.
SuperscriptXSize, SuperscriptYSizeshortThe size of superscript glyphs.
SuperscriptXOffset, SuperscriptYOffsetshortThe offset of superscript glyphs.
ItalicAnglefloatThe italic angle in degrees, counter-clockwise from vertical.
MethodDescription
TryGetGlyphMetrics(CodePoint, TextAttributes, TextDecorations, LayoutMode, ColorFontSupport, out IReadOnlyList<GlyphMetrics>? metrics)Gets the metrics of the glyphs for a code point.

HorizontalMetrics and VerticalMetrics​

public class HorizontalMetrics : IMetricsHeader public class VerticalMetrics : IMetricsHeader

Both have the members of IMetricsHeader:

PropertyTypeDescription
AscendershortThe distance from the baseline to the top of the line.
DescendershortThe distance from the baseline to the bottom of the line. Usually negative.
LineGapshortThe extra space between lines.
LineHeightshortThe distance between baselines: ascender − descender + line gap.
AdvanceWidthMaxshortThe largest advance width of any glyph.
AdvanceHeightMaxshortThe largest advance height of any glyph.

Glyph​

public readonly struct Glyph

A glyph of a Font, at that font's size.

MemberDescription
GlyphMetricsThe metrics of the glyph.
BoundingBox(GlyphLayoutMode mode, Vector2 location, float dpi)The ink box of the glyph in pixels at dpi, placed at location.

GlyphMetrics​

public abstract class GlyphMetrics

The metrics of one glyph. TrueTypeGlyphMetrics is the subclass for TrueType outlines.

PropertyTypeDescription
GlyphIdushortThe index of the glyph in its font.
CodePointCodePointThe code point that the glyph is for.
GlyphTypeGlyphTypeStandard, Fallback or ColrLayer.
GlyphColorGlyphColor?The color of a color layer, or null.
UnitsPerEmushortThe units per em of the font.
ScaleFactorVector2The scale factor of the font, for each axis.
AdvanceWidthushortHow far the pen moves after the glyph in horizontal text.
AdvanceHeightushortHow far the pen moves after the glyph in vertical text.
LeftSideBearingshortThe space from the pen position to the left edge of the ink.
RightSideBearingshortThe space from the right edge of the ink to the end of the advance.
TopSideBearingshortThe space above the ink in vertical text.
BottomSideBearingshortThe space below the ink in vertical text.
WidthfloatThe width of the ink.
HeightfloatThe height of the ink.
TextAttributesTextAttributesThe attributes that the metrics were made for.
TextDecorationsTextDecorationsThe decorations that the metrics were made for.