GoogleFont
A Google Fonts family and the faces to take from it.
A Google Fonts family and the faces to take from it.
Import#
ts
import type { GoogleFont } from "@shadow-js/dusk/vite";
Signature#
ts
interface GoogleFont {
/** The family name as the API spells it (`Inter`, `Roboto Flex`). Letters, digits and spaces only. */
readonly family: string;
/** CSS custom property that holds the font stack, for example `--font-sans`. */
readonly variable?: string;
/** Static weights (`[400, 700]`), when the family has no `wght` axis you vary. Not with `axes.wght`. */
readonly weights?: readonly number[];
/**
* Variable axes: a value (`400`) or a range (`"100..900"`) per axis tag (`wght`, `wdth`, `opsz`, `slnt`, `GRAD`).
* Every combination is requested.
*/
readonly axes?: Readonly<Record<string, number | string>>;
/** Also request the italic faces (the `ital` axis). Default false. */
readonly italic?: boolean;
/** Only these subsets (`latin`, `latin-ext`, `cyrillic`, ...). Default: every subset the API returns. */
readonly subsets?: readonly string[];
/**
* What to preload in the head. Default (absent or `true`): the first subset you declare in `subsets`, or `latin` when
* you declare none, as `next/font` preloads the first screen's text font and not every script. Only the subsets and
* weights you asked for are downloaded at all. `false`: nothing. A list: exactly those subsets.
*/
readonly preload?: boolean | readonly string[];
/** Default `swap`. */
readonly display?: FontDisplay;
/** Generic and system families after the font. Default `["sans-serif"]`. */
readonly fallback?: readonly string[];
/**
* The size-adjusted fallback face, built from the downloaded file's metrics and measured against this system font (the
* family is then `"<family> fallback"` in the stack). Absent: the face is built against Arial, or against Times New
* Roman when `fallback` has `serif`, as `next/font`'s `adjustFontFallback` does. `false`: no fallback face.
*/
readonly fallbackFace?: false | "Arial" | "Times New Roman";
}
Members#
| Name | Type | Description |
|---|---|---|
family |
readonly family: string |
The family name as the API spells it (Inter, Roboto Flex). Letters, digits and spaces only. |
variable? |
readonly variable?: string |
CSS custom property that holds the font stack, for example --font-sans. |
weights? |
readonly weights?: readonly number[] |
Static weights ([400, 700]), when the family has no wght axis you vary. Not with axes.wght. |
axes? |
readonly axes?: Readonly<Record<string, number | string>> |
Variable axes: a value (400) or a range ("100..900") per axis tag (wght, wdth, opsz, slnt, GRAD). Every combination is requested. |
italic? |
readonly italic?: boolean |
Also request the italic faces (the ital axis). Default false. |
subsets? |
readonly subsets?: readonly string[] |
Only these subsets (latin, latin-ext, cyrillic, ...). Default: every subset the API returns. |
preload? |
readonly preload?: boolean | readonly string[] |
What to preload in the head. Default (absent or true): the first subset you declare in subsets, or latin when you declare none, as next/font preloads the first screen's text font and not every script. Only the subsets and weights you asked for are downloaded at all. false: nothing. A list: exactly those subsets. |
display? |
readonly display?: FontDisplay |
Default swap. |
fallback? |
readonly fallback?: readonly string[] |
Generic and system families after the font. Default ["sans-serif"]. |
fallbackFace? |
readonly fallbackFace?: false | "Arial" | "Times New Roman" |
The size-adjusted fallback face, built from the downloaded file's metrics and measured against this system font (the family is then "<family> fallback" in the stack). Absent: the face is built against Arial, or against Times New Roman when fallback has serif, as next/font's adjustFontFallback does. false: no fallback face. |