Skip to content

Class: FontMetricsRegistry ​

Registry of FontMetrics keyed by (face, bold, italic). Variant advances differ, so bold/italic are stored separately; lookup falls back to the regular variant (then any registered variant of the face) so a deck that only registers the regular weight still measures bold runs approximately rather than not at all.

Constructors ​

Constructor ​

new FontMetricsRegistry(): FontMetricsRegistry

Returns ​

FontMetricsRegistry

Accessors ​

size ​

Get Signature ​

get size(): number

Returns ​

number

Methods ​

get() ​

get(face, bold?, italic?): FontMetrics | undefined

Resolve metrics for a run, falling back from exact variant → regular → any variant.

Parameters ​

ParameterTypeDefault value
facestring | null | undefinedundefined
boldbooleanfalse
italicbooleanfalse

Returns ​

FontMetrics | undefined


hasCodepoint() ​

hasCodepoint(face, cp, opts?): boolean | undefined

Coverage of code point cp for face, read from the registered font's cmap: true/false when a variant of face is registered (see get for the exact→regular→any-variant fallback), or undefined when the face has no registered metrics — "unknown", deliberately distinct from a false "registered but not covered". A coverage audit must not treat an unregistered face as fully covered, so callers get undefined here rather than the per-face FontMetrics.hasCodepoint boolean (which, for the heuristic fallback, always reports covered). Register the face via parseFontMetrics + set first.

Parameters ​

ParameterType
facestring | null | undefined
cpnumber
opts?{ bold?: boolean; italic?: boolean; }
opts.bold?boolean
opts.italic?boolean

Returns ​

boolean | undefined


hasFace() ​

hasFace(face): boolean

True if any variant of face has registered metrics.

Parameters ​

ParameterType
facestring

Returns ​

boolean


set() ​

set(face, metrics, opts?): void

Parameters ​

ParameterType
facestring
metricsFontMetrics
opts?{ bold?: boolean; italic?: boolean; }
opts.bold?boolean
opts.italic?boolean

Returns ​

void