import type { PostextConfig, Resource } from '../types.js'; import type { SvgPictureFontWarning } from '../vdt.js'; import { type SvgFontSyncProvider } from '../svg/fonts.js'; import type { PostextBundle } from './api.js'; /** The fields of a bundle the adapters read: an opened `PostextBundle`, or * any object with the same shape. */ export type BundleSource = Pick & Partial>; /** The single-ink colour SVG figures are recoloured to, or null when * `diagramStyle.singleInk` is off. */ export declare function diagramInkHex(config: PostextConfig): string | null; /** Whether an SVG resource's pictures get the document's fonts inlined * (`diagramStyle.inlineFonts`, `svg.inlineFonts`, #630). */ export declare function svgInlinesFonts(config: PostextConfig, r: Resource): boolean; /** The bundle's own faces as an SVG font provider (#630): the cut nearest * to the weight asked for, the same style first, as stored (WOFF2 stays * WOFF2: an image takes it). */ export declare function bundleSvgFontProvider(bundle: Pick): SvgFontSyncProvider; /** What the bundle adapters that inline SVG fonts accept. */ export interface BundleImageOptions { /** Told of an SVG family with no face to embed and of the size cap * (`svgFontUnavailable`, `svgFontsTooLarge`). */ onWarning?: (warning: SvgPictureFontWarning) => void; /** Most font bytes embedded in one SVG (default 2 MiB). */ maxBytes?: number; } /** What {@link loadBundleFonts} takes besides the font set. */ export interface LoadBundleFontsOptions { /** The bytes of a face of the family a missing face is set in (#978), * for a family of `bundle.config.customFonts` that names a `fallback` * the bundle does not carry. Answers null for a face it has not. */ fallback?: (family: string, weight: number, style: 'normal' | 'italic') => Promise | ArrayBuffer | Uint8Array | null | undefined; } /** Register the bundle's fonts with the browser (`document.fonts` by * default) so layout measures text with them, and drop what was measured * in their families before. Call it — and await it — before * `buildDocument`. Resolves to the faces added. A family that names a * `fallback` (#978) gets the regular, the bold and their italics of the * slants it has no file of from that family, added under its own name: the * bundle's faces of the fallback, else `options.fallback`'s. */ export declare function loadBundleFonts(bundle: Pick & Partial>, fontSet?: FontFaceSet | undefined, options?: LoadBundleFontsOptions): Promise; /** Decode the bundle's pictures and register them with the canvas backend * (`registerResourceImage`), recolouring SVG figures when the config asks * for single-ink diagrams — with the markup pass, which gives the PDF's * colours exactly, and registered with `singleInk: false`, so the canvas * never tints them again — and embedding in each SVG the faces its text * names (#630): the bundle's own, then those registered with * `registerFontBytes` / `registerFontUrl` or declared by the page's * `@font-face` rules (`diagramStyle.inlineFonts`, `svg.inlineFonts`). * Await it before painting. */ export declare function registerBundleImages(bundle: BundleSource, options?: BundleImageOptions): Promise; /** A `resourceImageUrl` resolver for `renderToHtml`: object URLs over the * bundle's pictures, built once. `revoke()` frees them. Its SVGs are * recoloured for single ink already, which `singleInk: false` tells * `renderToHtml` (so it adds no filter of its own), and carry the faces * their text names (#630): the bundle's own, and registered faces held in * memory (`registerFontBytes`). */ export declare function bundleImageUrl(bundle: BundleSource, options?: BundleImageOptions): ((fileId: string) => string | undefined) & { revoke: () => void; singleInk: false; }; /** A `resourceVideoUrl` resolver for `renderToHtml` (#454): object URLs * over the bundle's self-hosted videos, built once. `revoke()` frees * them. */ export declare function bundleVideoUrl(bundle: BundleSource): ((fileId: string) => string | undefined) & { revoke: () => void; }; /** A `resourceBytes` resolver for `postext-pdf`'s `renderToPdf`: an SVG * figure resolves to its vector print master (`svg.pdfFileId`) when it has * one — unless single-ink is on, which recolours SVG markup only. The * bytes are the bundle's own: the PDF backend recolours them once (it * leaves markup `applySingleInkToSvg` marked as it is). */ export declare function bundleResourceBytes(bundle: BundleSource): (fileId: string) => Uint8Array | undefined; /** What `postext-pdf` tells a font provider about a face: the characters * the pages set in it (its `PdfFontRequest`). */ export interface BundleFontRequest { codePoints: ReadonlySet; } export interface BundleFontProviderOptions { /** Turns WOFF2 into the TrueType/OpenType bytes a PDF embeds — pass * `decompressWoff2` from `postext-pdf`. Required when the bundle carries * `.woff2` faces. */ decodeWoff2?: (bytes: Uint8Array) => Promise | Uint8Array; /** Where a family the bundle does not carry comes from (Google Fonts * families such as the default heading face). It is handed the * renderer's `request` and may answer with several files, like any * `postext-pdf` font provider: a Chinese family served as Fontsource's * unicode-range slices needs the files that hold the text's characters. */ fallback?: (family: string, weight: number, style: 'normal' | 'italic', request?: BundleFontRequest) => Promise; } /** A `fontProvider` for `postext-pdf`'s `renderToPdf`: the bundle's own * faces (nearest weight, same style first), else `fallback`, which gets * the renderer's `request` (see {@link BundleFontProviderOptions}). A * family of `bundle.config.customFonts` that names a `fallback` family * (#978) has the faces it has no file of (all of them, or the slant it has * none of) taken from that family: the bundle's own faces of it, else * `options.fallback` asked for it. */ export declare function bundleFontProvider(bundle: Pick & Partial>, options?: BundleFontProviderOptions): (family: string, weight: number, style: 'normal' | 'italic', request?: BundleFontRequest) => Promise; //# sourceMappingURL=adapters.d.ts.map