API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classGlyphMetrics

@codexo/exojs / rendering / stable

The LOGICAL typographic metrics of one font variant - advances and kerning, in logical pixels, at the logical font size. This is the half of a glyph that layout consumes, and it is deliberately kept out of GlyphAtlas: an atlas is a RASTER resource whose identity includes a pixel density, while an advance is a property of the typeface and the font size alone. Splitting them is what makes the two invariants of HiDPI text hold by construction rather than by luck: - the same string lays out identically at every `pixelRatio`, because the numbers layout reads never went near a raster grid; - Text.measure answers without rasterizing anything, so a measurement cannot allocate an atlas, cannot claim atlas space, and cannot depend on which Application happens to exist. One instance per `family` x `fontStyle` x `fontVariant` x `fontWeight`, shared by every atlas of that variant regardless of mode, SDF radius or pixel ratio - see GlyphAtlasPool.getMetrics. Satisfies GlyphProvider so it can drive a measurement-only layout pass. The GlyphInfo it hands out carries a real `advance` and zero geometry: there is no tile, no page and no UV rectangle behind it, and a caller that needs those wants an atlas instead.

0
props
6
methods
0
events
Import
import { GlyphMetrics } from '@codexo/exojs'

The LOGICAL typographic metrics of one font variant - advances and kerning, in logical pixels, at the logical font size.

This is the half of a glyph that layout consumes, and it is deliberately kept out of GlyphAtlas: an atlas is a RASTER resource whose identity includes a pixel density, while an advance is a property of the typeface and the font size alone. Splitting them is what makes the two invariants of HiDPI text hold by construction rather than by luck:

- the same string lays out identically at every `pixelRatio`, because the numbers layout reads never went near a raster grid; - Text.measure answers without rasterizing anything, so a measurement cannot allocate an atlas, cannot claim atlas space, and cannot depend on which Application happens to exist.

One instance per `family` x `fontStyle` x `fontVariant` x `fontWeight`, shared by every atlas of that variant regardless of mode, SDF radius or pixel ratio - see GlyphAtlasPool.getMetrics.

Satisfies GlyphProvider so it can drive a measurement-only layout pass. The GlyphInfo it hands out carries a real `advance` and zero geometry: there is no tile, no page and no UV rectangle behind it, and a caller that needs those wants an atlas instead.

Constructors1
Methods6
advance(char: string, fontSize: number): number
Horizontal advance of char at fontSize logical pixels.
clear(): void
Drop every cached measurement. Called when the variant's FontFace finishes loading: everything measured before that point came from the fallback face and is wrong.
cssFont(size: number): string
The CSS font shorthand for this variant at size logical pixels.
Vertical metrics of this variant at fontSize. The ascent and descent come from the font's own bounding box where the platform reports one, so every string of the variant shares one baseline; the x-height is measured from a lowercase letter's ink, which is the only way to get it from Canvas 2D at all. Where a measurement is missing the value degrades to a fraction of the font size.
Return metrics for the given character at the given font size.
getKerning(prev: string, next: string, fontSize: number): number
Return the kerning adjustment (in pixels) between two adjacent characters. Positive values add space; negative values pull glyphs together. Optional - callers treat a missing method as zero kerning.
Source