import { FontBytesByVariant } from '../font/index.js'; /** A curated open substitute family (the Croscore + Carlito/Caladea set, like LibreOffice). */ export type FamilyKey = 'arimo' | 'tinos' | 'cousine' | 'carlito' | 'caladea'; /** * A WRITING SYSTEM the curated five cannot draw at all. They are Latin families * — Greek, Cyrillic and Hebrew ride along, everything else is a notdef box — * and 2145 characters of the corpus fall outside them: Han, Kana, Hangul, * Arabic, the geometric symbols a form's checkbox is made of. * * These are fetched only when a document actually holds such a character, and * only in the regular weight: Noto Sans SC is ten megabytes, and a bold run in * it is better stroked (see `SyntheticFace`) than downloaded four times over. */ export type ScriptKey = 'jp' | 'kr' | 'sc' | 'arabic' | 'hebrew' | 'thai' | 'symbols1' | 'symbols2'; /** Either kind of substitute — a Latin family or a per-script face. */ export type SubstituteKey = FamilyKey | ScriptKey; /** Whether a substitute key names a writing system rather than a Latin family. */ export declare function isScriptKey(key: SubstituteKey): key is ScriptKey; /** * Fetch the ONE face a writing system is drawn with. * * @param script The writing system. * @param fetchImpl Injectable `fetch` (defaults to the global one). * @returns The regular face, or `undefined` when the download fails. */ export declare function fetchScriptFont(script: ScriptKey, fetchImpl?: FetchLike): Promise; /** A family name, read: which substitute it maps to and what it says about the face. */ export interface FamilyStyle { readonly key: FamilyKey; /** The NAME asks for a heavy face (`Arial Black`, `DIN-Bold`). */ readonly bold?: boolean; /** …or a slanted one (`Frutiger Oblique`). */ readonly italic?: boolean; /** * …or a narrow one (`Arial Narrow`), as the fraction of the normal advance it * sets at. No curated family ships a condensed cut, so the substitute is * squeezed instead — Arial Narrow's own widths are 82 % of Arial's, which is * also what LibreOffice's Liberation Sans Narrow reproduces. */ readonly widthScale?: number; } /** * Map a document-referenced font family to a curated open substitute: an exact * metric twin when one is known (e.g. Calibri → Carlito), otherwise a * serif/mono/sans style fallback. * * The name may also carry the FACE — `Times New Roman Bold` is the Times * family, and read whole it matches no twin at all and fell through to the * generic sans, which is how a Times heading came out in a grotesque. * * @param name The referenced family name (case-insensitive); empty ⇒ Arimo. * @returns The chosen family and what the name said about the face. */ export declare function resolveFamilyStyle(name: string | undefined): FamilyStyle; /** * The curated substitute for a family name — {@link resolveFamilyStyle} without * the face it also carries. * * @param name The referenced family name (case-insensitive); empty ⇒ Arimo. * @returns The chosen {@link FamilyKey}. */ export declare function resolveFamilyKey(name: string | undefined): FamilyKey; /** A minimal `fetch`-like function (injectable for tests / offline use). */ export type FetchLike = (url: string) => Promise<{ ok: boolean; arrayBuffer: () => Promise; }>; /** Options for {@link fetchFontSet}. */ export interface FetchFontSetOptions { /** Document font family name to substitute, or a curated {@link FamilyKey} directly. */ readonly family?: string | FamilyKey; /** Injectable fetch (defaults to the global `fetch`); lets tests run offline. */ readonly fetch?: FetchLike; } /** * Download a full variant set (regular required; bold/italic/bold-italic * best-effort) for the open family that best matches the requested name. * * @param options The family to substitute and an optional fetch override. * @returns The downloaded font bytes per variant. * @throws Error when the required regular face cannot be downloaded. */ export declare function fetchFontSet(options?: FetchFontSetOptions): Promise; /** Test / diagnostic helper: clear the in-memory font-download cache. */ export declare function clearFontCache(): void;