Struct FontExtents
A face's vertical metrics and decoration positions, with y up: in font units from Extents, or in canvas units from Extents.
public readonly record struct FontExtents : IEquatable<FontExtents>
- Implements
- Inherited Members
Examples
// Character map, advance, ink box and kerning, all in font units with y up.
ushort a = face.GetGlyph('A'), v = face.GetGlyph('V');
float advance = face.GetAdvance(a);
GlyphExtents ink = face.GetGlyphExtents(a);
float kern = face.GetKerning(a, v);
FontExtents extents = face.Extents;
// An outline arrives through a sink: lines and quadratics for TrueType, lines and cubics for CFF.
var counter = new SegmentCounter();
face.GetGlyphOutline(a, counter);
Remarks
Ascent, Descent and LineGap follow the browsers' rule: the OS/2 typo metrics when the face sets USE_TYPO_METRICS, else the hhea
metrics, falling back to the typo and then the Windows metrics when those are zero. The line height is
Ascent - Descent + LineGap.
Constructors
FontExtents(float, float, float, float, float, float, float, float, float, float, GlyphExtents)
A face's vertical metrics and decoration positions, with y up: in font units from Extents, or in canvas units from Extents.
public FontExtents(float Ascent, float Descent, float LineGap, float CapHeight, float XHeight, float UnderlinePosition, float UnderlineThickness, float StrikeoutPosition, float StrikeoutSize, float ItalicAngle, GlyphExtents BoundingBox)
Parameters
AscentfloatThe distance from the baseline up to the top of the line, positive.
DescentfloatThe distance from the baseline down to the bottom of the line, negative.
LineGapfloatThe extra space between lines.
CapHeightfloatThe height of capital letters.
XHeightfloatThe height of lowercase letters such as x.
UnderlinePositionfloatThe top of the underline, relative to the baseline (usually negative).
UnderlineThicknessfloatThe underline's thickness.
StrikeoutPositionfloatThe top of the strikeout line, relative to the baseline.
StrikeoutSizefloatThe strikeout line's thickness.
ItalicAnglefloatThe slant in degrees counter-clockwise from vertical: negative for text leaning right.
BoundingBoxGlyphExtentsThe box around every glyph of the face.
Examples
// Character map, advance, ink box and kerning, all in font units with y up.
ushort a = face.GetGlyph('A'), v = face.GetGlyph('V');
float advance = face.GetAdvance(a);
GlyphExtents ink = face.GetGlyphExtents(a);
float kern = face.GetKerning(a, v);
FontExtents extents = face.Extents;
// An outline arrives through a sink: lines and quadratics for TrueType, lines and cubics for CFF.
var counter = new SegmentCounter();
face.GetGlyphOutline(a, counter);
Remarks
Ascent, Descent and LineGap follow the browsers' rule: the OS/2 typo metrics when the face sets USE_TYPO_METRICS, else the hhea
metrics, falling back to the typo and then the Windows metrics when those are zero. The line height is
Ascent - Descent + LineGap.
Properties
Ascent
The distance from the baseline up to the top of the line, positive.
public float Ascent { get; init; }
Property Value
BoundingBox
The box around every glyph of the face.
public GlyphExtents BoundingBox { get; init; }
Property Value
CapHeight
The height of capital letters.
public float CapHeight { get; init; }
Property Value
Descent
The distance from the baseline down to the bottom of the line, negative.
public float Descent { get; init; }
Property Value
ItalicAngle
The slant in degrees counter-clockwise from vertical: negative for text leaning right.
public float ItalicAngle { get; init; }
Property Value
LineGap
The extra space between lines.
public float LineGap { get; init; }
Property Value
LineHeight
Gets the distance from one baseline to the next: Ascent - Descent + LineGap.
public float LineHeight { get; }
Property Value
StrikeoutPosition
The top of the strikeout line, relative to the baseline.
public float StrikeoutPosition { get; init; }
Property Value
StrikeoutSize
The strikeout line's thickness.
public float StrikeoutSize { get; init; }
Property Value
UnderlinePosition
The top of the underline, relative to the baseline (usually negative).
public float UnderlinePosition { get; init; }
Property Value
UnderlineThickness
The underline's thickness.
public float UnderlineThickness { get; init; }
Property Value
XHeight
The height of lowercase letters such as x.
public float XHeight { get; init; }
Property Value
Methods
Scale(float)
Returns these extents scaled by scale; the italic angle stays.
public FontExtents Scale(float scale)
Parameters
scalefloatThe factor, such as a font size over units per em.
Returns
- FontExtents
The scaled extents.