Renderer · function

parseSdfFont

Validate and index a metrics document.

Explained in Hello world.

function parseSdfFont(document: unknown): SdfFont
import { parseSdfFont } from '@driftengine/core';

Parameters

ParameterTypeDescription
documentunknown

In depth

Throws on a version it does not recognise, which is the fail-fast-at-init rule earning its keep: the alternative is reading a field that moved and drawing text that is subtly misplaced, and misplaced text looks like a layout bug for as long as it takes to suspect the file.

Required numeric fields fail at load, not draw: unitsPerEm scales every plane and atlas coordinate, so a missing one produces wrong sizes that look plausible until a frame lands beside a reference and they do not match. Every other required field is checked the same way.