Table of Contents

Struct DeviceFontMetrics

Namespace
DocWright.Fonts
Assembly
DocWright.Fonts.dll

A face's metrics in whole device pixels at one size, as the Windows text engine (GDI) reports them for a font selected at that many pixels per em.

public readonly struct DeviceFontMetrics : IEquatable<DeviceFontMetrics>
Implements
Inherited Members

Remarks

Programs that lay content out on a pixel grid - a spreadsheet's rows and columns are the case this was built for - size things from these numbers, not from the design metrics, and the two disagree by rounding and, for a face with a VDMX table, by the font designer's own choice. Get one from GetDeviceMetrics(int).

Measured against GDI for twelve faces at thirty-one sizes and two resolutions (Phase 192): ascent, descent and both leadings agree for every size of two points and more. The digit width is the face's own device advance where it records one for the size (its hdmx table) and the rounded design advance otherwise, which is what GDI reports at printer resolutions; at screen sizes a face that is hinted and records nothing may differ by a pixel (Calibri at 15 pixels per em is 7 wide where the advance rounds to 8), because hinting moves the advance and this library runs no hinting.

Properties

Ascent

Gets the pixels above the baseline (GDI's tmAscent).

Descent

Gets the pixels below the baseline, as a positive number (GDI's tmDescent).

ExternalLeading

Gets the space the face asks for between lines, beyond its cell (GDI's tmExternalLeading): the amount by which the hhea ascender, descender and line gap exceed the Windows ascent and descent, and never negative.

Height

Gets the height of the face's cell: ascent plus descent (GDI's tmHeight).

InternalLeading

Gets the part of the cell above the em: the height less the pixels per em (GDI's tmInternalLeading). Negative for a face whose cell is shorter than its em.

MaxDigitWidth

Gets the advance of the widest of the digits 0 to 9, rounded to whole pixels.

PixelsPerEm

Gets the size the metrics are for, in pixels per em.

Methods

Equals(DeviceFontMetrics)
Equals(object?)
GetHashCode()

Operators

operator ==(DeviceFontMetrics, DeviceFontMetrics)

Determines whether two values are equal.

operator !=(DeviceFontMetrics, DeviceFontMetrics)

Determines whether two values differ.