/** * Canvas text never triggers a font download by itself: `ctx.font` silently * falls back to a system face while the @font-face is still being fetched, so a * chart that switches to a not-yet-loaded family draws — and measures — with the * wrong one. Every family the options mention is therefore requested explicitly, * and the chart lays out again once the real faces arrive: text metrics decide * the geometry of axes, legend and labels. */ export interface FontsOptions { /** * Redraw the chart once a web font it uses has finished loading (on by * default). Turning it off keeps the very first frame as the only one — the * chart then draws with whatever face the browser has at that moment and * never asks for the missing ones, since canvas text loads no fonts on its own. */ autoReload?: boolean; } interface FontUsage { families: Set; weights: Set; } /** * Watches the faces a chart draws with: `request` pulls in the fonts declared * when the options were applied, `recheck` catches the ones the document * declares later on. */ export declare class FontWatcher { /** Families the current options draw with, normalized for comparison. */ private families; /** Faces already accounted for — every other loaded face is news. */ private seen; /** * Asks the browser for every font family the options mention and resolves when * they are in. `true` means a face actually arrived, i.e. the chart has to be * laid out and drawn again. */ request(options: unknown, ...extraFamilies: string[]): Promise; /** * `true` when a face of one of our families has finished loading since the last * look — a font the page declared after the chart was built. */ recheck(): boolean; /** Marks every loaded face as seen; `true` if one of ours was new. */ private absorbLoaded; } /** * Calls `onLoadingDone` every time the document finishes loading a batch of * fonts; returns the unsubscribe. */ export declare function watchDocumentFonts(onLoadingDone: () => void): () => void; /** Every `fontFamily`/`fontWeight` reachable in the options tree. */ export declare function collectFontUsage(value: unknown, depth?: number, usage?: FontUsage): FontUsage; export {};