import { FetchLike } from './remote-fonts.js'; import { FontBytesByVariant, FontRegistry } from '../font/index.js'; /** A font resolution request: the wanted family and style. */ export interface FontRequest { /** Family name as the document references it (e.g. "Times New Roman"). */ readonly family?: string; /** Whether a bold face is wanted. */ readonly bold: boolean; /** Whether an italic face is wanted. */ readonly italic: boolean; } /** A provider's answer: resolved bytes, or `none` to fall through to the next provider. */ export type FontAnswer = { readonly kind: 'bytes'; readonly bytes: Uint8Array; /** Face the bytes actually are (for substitution reporting). */ readonly faceName: string; /** Which provider answered (chain bookkeeping). */ readonly providerId: string; } | { readonly kind: 'none'; }; /** The shared `none` answer — a provider that cannot satisfy a request. */ export declare const NO_FONT: FontAnswer; /** One stage in the font-resolution chain (ir-design §8). */ export interface FontProvider { /** Provider id: `'embedded'` | `'caller'` | `'local'` | `'remote'` | a custom id. */ readonly id: string; /** Resolve a request to bytes, or {@link NO_FONT} to defer to the next provider. */ resolve: (req: FontRequest) => Promise; } /** First byte-level answer wins; 'none' falls through to the next provider. */ export declare function chainProviders(providers: ReadonlyArray): FontProvider; /** * Caller-supplied bytes — answers every family (the caller chose these fonts * deliberately). Falls back through bold/italic → regular like the registry. */ export declare function callerFontProvider(fonts: FontBytesByVariant): FontProvider; /** * Fonts embedded in the source document itself (docx fontTable), keyed by the * normalized family name — an exact-name match, never a substitution. */ export declare function embeddedDocFontProvider(embedded: ReadonlyMap): FontProvider; /** * Open CDN substitutes (Arimo / Tinos / Cousine / Carlito / Caladea — the * LibreOffice metric-compatible mapping). * Always answers; the chain reports it as a substitution. */ export declare function remoteFontProvider(options?: { readonly fetch?: FetchLike; }): FontProvider; /** * OS/2 fsType embedding permissions (OpenType §OS/2). Returns undefined when * the table is absent/corrupt. The licensing nibble: 0 = installable, * 2 = RESTRICTED (no embedding), 4 = preview & print, 8 = editable. */ export declare function readOs2FsType(bytes: Uint8Array): number | undefined; /** True when the fsType licensing nibble forbids embedding entirely. */ export declare function isEmbeddingRestricted(fsType: number | undefined): boolean; /** * System fonts via the Local Font Access API (Chromium 103+, permission * prompt). OPT-IN by design: never wired in implicitly. Returns 'none' when * the API is unavailable (Node, Safari, Firefox), the family is not installed, * or the face's OS/2 fsType marks embedding as restricted — embedding a * restricted font into a PDF would violate its license, so the chain falls * through to a substitute instead. */ export declare function localFontProvider(): FontProvider;