/** * The mode-aware font resolver — the single decision point every converter * shares. Resolution order for one (family, bold, italic) variant: * 1. a registered URL (per-variant or family-level) supplied by the consumer * 2. a system font (base-14) — resolves locally, never fetches * 3. Google Fonts (network, retried + classified by ./discover) * 4. mode branch on failure: * - 'soft' → substitute the fallback family (base-14) and mark it * - 'strict' → propagate FONT_FAILED * * Registered + system fonts resolve identically in both modes, so real-world * files (Arial/Times/Courier + Google fonts) never trip strict mode. */ import { type DiscoverOptions } from './discover.js'; import { type SystemFontResolution } from './system-fonts.js'; export type FontMode = 'strict' | 'soft'; export interface ResolveOptions { bold?: boolean; italic?: boolean; /** Default 'strict'. Importers pass 'soft'. */ mode?: FontMode; /** * Family substituted in soft mode. Default 'Arial' — matches core's * canonical missing-font fallback. Arial is a system font (see the base-14 * table), so it resolves to Helvetica for PDF and to the native "Arial" in * the browser without ever hitting the network. */ fallbackFamily?: string; /** Consumer's registered-font lookup (per-variant → family-level). */ registeredUrl?: (family: string, bold: boolean, italic: boolean) => string | undefined; /** Passed to `fetchGoogleFontFaces` (cache/retries shape the shared load; signal/timeout bound this caller's wait). */ google?: DiscoverOptions; } export type ResolvedFont = { source: 'registered'; family: string; url: string; } | { source: 'google'; family: string; url: string; } | { source: 'system'; family: string; system: SystemFontResolution; } | { source: 'fallback'; /** The family that couldn't be resolved. The substitute is `system`. */ requestedFamily: string; system: SystemFontResolution; }; /** * Resolve a single font variant. Throws `FONT_FAILED` in strict mode when the * family is unknown/unreachable; in soft mode returns a `fallback` result * instead (never throws for an unknown font — transport errors still surface if * even the fallback can't resolve, which for base-14 it always can). */ export declare function resolveFontVariant(family: string, opts?: ResolveOptions): Promise;