Table of Contents

Struct FontExtents

Namespace
Egami.Fonts
Assembly
Egami.Fonts.dll

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

Ascent float

The distance from the baseline up to the top of the line, positive.

Descent float

The distance from the baseline down to the bottom of the line, negative.

LineGap float

The extra space between lines.

CapHeight float

The height of capital letters.

XHeight float

The height of lowercase letters such as x.

UnderlinePosition float

The top of the underline, relative to the baseline (usually negative).

UnderlineThickness float

The underline's thickness.

StrikeoutPosition float

The top of the strikeout line, relative to the baseline.

StrikeoutSize float

The strikeout line's thickness.

ItalicAngle float

The slant in degrees counter-clockwise from vertical: negative for text leaning right.

BoundingBox GlyphExtents

The 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

float

BoundingBox

The box around every glyph of the face.

public GlyphExtents BoundingBox { get; init; }

Property Value

GlyphExtents

CapHeight

The height of capital letters.

public float CapHeight { get; init; }

Property Value

float

Descent

The distance from the baseline down to the bottom of the line, negative.

public float Descent { get; init; }

Property Value

float

ItalicAngle

The slant in degrees counter-clockwise from vertical: negative for text leaning right.

public float ItalicAngle { get; init; }

Property Value

float

LineGap

The extra space between lines.

public float LineGap { get; init; }

Property Value

float

LineHeight

Gets the distance from one baseline to the next: Ascent - Descent + LineGap.

public float LineHeight { get; }

Property Value

float

StrikeoutPosition

The top of the strikeout line, relative to the baseline.

public float StrikeoutPosition { get; init; }

Property Value

float

StrikeoutSize

The strikeout line's thickness.

public float StrikeoutSize { get; init; }

Property Value

float

UnderlinePosition

The top of the underline, relative to the baseline (usually negative).

public float UnderlinePosition { get; init; }

Property Value

float

UnderlineThickness

The underline's thickness.

public float UnderlineThickness { get; init; }

Property Value

float

XHeight

The height of lowercase letters such as x.

public float XHeight { get; init; }

Property Value

float

Methods

Scale(float)

Returns these extents scaled by scale; the italic angle stays.

public FontExtents Scale(float scale)

Parameters

scale float

The factor, such as a font size over units per em.

Returns

FontExtents

The scaled extents.