/**
* Font optimization helpers.
*
* Three concerns:
* 1. `buildFontPreloadLink` — `` descriptor
* for a self-hosted font file. Caller renders the JSX/HTML.
* 2. `buildFontFaceCss` — emits `@font-face` blocks with `font-display: swap`
* so the browser shows fallback glyphs instead of an invisible flash.
* 3. `googleFontsUrl` — composes a Google Fonts CSS2 URL with weight axes
* and `display=swap`, plus its preconnect link pair.
*
* All helpers are pure-data; no DOM access, no fetch, safe in workers.
*/
export type FontFormat = 'woff2' | 'woff' | 'ttf' | 'otf';
export interface FontFaceDescriptor {
family: string;
src: string;
/** File format (used for `format()` hint + preload `type`). */
format?: FontFormat;
weight?: number | string;
style?: 'normal' | 'italic' | 'oblique';
/** `font-display`. Default: `swap` — prevents FOIT (flash of invisible text). */
display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
/** Unicode range to subset the font (e.g. `U+0000-00FF` for latin-1). */
unicodeRange?: string;
}
export interface FontPreloadLink {
rel: 'preload';
as: 'font';
href: string;
type: string;
crossorigin: 'anonymous';
fetchpriority?: 'high' | 'low';
}
export declare function buildFontPreloadLink(src: string, format?: FontFormat, opts?: {
fetchPriority?: 'high' | 'low';
}): FontPreloadLink;
export declare function buildFontFaceCss(descriptors: FontFaceDescriptor[]): string;
export interface GoogleFontFamily {
family: string;
/** Weight axes — single number or array of weights. */
weights?: Array;
}
export interface GoogleFontsUrlOptions {
families: GoogleFontFamily[];
display?: FontFaceDescriptor['display'];
/** Subset (e.g. `latin`, `latin-ext`). */
subset?: string;
/** Override the base URL — test hook. */
baseUrl?: string;
}
export declare function googleFontsUrl(opts: GoogleFontsUrlOptions): string;
/**
* Preconnect to Google's font hosts. Two links: the CSS host + the static
* file host (separate origin so two TLS warmups beat any latency hides).
*/
export declare function googleFontsPreconnectLinks(): Array<{
rel: 'preconnect';
href: string;
crossorigin?: 'anonymous';
}>;
//# sourceMappingURL=fonts.d.ts.map