### Install Font Package Source: https://fontsource.org/docs/getting-started/install.md Use your preferred package manager to install a font package. This example shows installation for Open Sans. ```bash npm install @fontsource/open-sans ``` ```bash yarn add @fontsource/open-sans ``` ```bash pnpm add @fontsource/open-sans ``` ```bash bun add @fontsource/open-sans ``` -------------------------------- ### Install Webpack Loaders for Fontsource Source: https://fontsource.org/docs/guides/webpack.md Install `css-loader` and `file-loader` using npm, yarn, pnpm, or bun. ```sh npm install css-loader file-loader yarn add css-loader file-loader pnpm add css-loader file-loader bun add css-loader file-loader ``` -------------------------------- ### Example Font ID Requests Source: https://fontsource.org/docs/api/font-id.md These are example HTTP GET requests to retrieve font details. The first requests details for the 'abel' font, and the second for 'open-sans'. ```http GET https://api.fontsource.org/v1/fonts/abel ``` ```http GET https://api.fontsource.org/v1/fonts/open-sans ``` -------------------------------- ### Version Response Example Source: https://fontsource.org/docs/api/version.md This is an example of the JSON response structure for the Version endpoint, detailing available NPM versions for a package. ```json { "latest": "5.0.4", "static": [ "5.0.4", "5.0.3", "5.0.2", "5.0.1", "5.0.0", "4.2.2", "4.2.1", "4.2.0", "4.1.1", "4.1.0", "4.0.1", "4.0.0" ], "latestVariable": "5.0.7", "variable": [ "5.0.7", "5.0.6", "5.0.5", "5.0.4", "5.0.3", "5.0.2", "5.0.1", "5.0.0" ] } ``` -------------------------------- ### Example API Calls for Version Source: https://fontsource.org/docs/api/version.md These examples demonstrate how to call the Version endpoint for specific Fontsource packages like 'abel' and 'open-sans'. ```http GET https://api.fontsource.org/v1/version/abel ``` ```http GET https://api.fontsource.org/v1/version/open-sans ``` -------------------------------- ### Variable Endpoint Request Examples Source: https://fontsource.org/docs/api/variable.md Examples of HTTP GET requests to the Variable endpoint for different font IDs. ```http GET https://api.fontsource.org/v1/variable/inter ``` ```http GET https://api.fontsource.org/v1/variable/roboto-flex ``` ```http GET https://api.fontsource.org/v1/variable/wavefont ``` -------------------------------- ### Install Fontsource Package Source: https://fontsource.org/docs/guides Install the desired Fontsource variable font package using npm, yarn, or pnpm. ```bash npm install @fontsource-variable/open-sans ``` -------------------------------- ### Response Example for Fonts Endpoint Source: https://fontsource.org/docs/api/fonts.md An example of the JSON response structure for a single font object. ```json [ { "id": "abeezee", "family": "ABeeZee", "subsets": ["latin"], "weights": [400], "styles": ["italic", "normal"], "defSubset": "latin", "variable": false, "lastModified": "2020-09-02", "category": "sans-serif", "version": "v14", "type": "google" } ... ] ``` -------------------------------- ### Install Fontsource SCSS Package Source: https://fontsource.org/docs/getting-started/faces-mixin.md Install the necessary helper package for using Fontsource mixins in your project. ```sh npm install @fontsource-utils/scss yarn add @fontsource-utils/scss pnpm add @fontsource-utils/scss bun add @fontsource-utils/scss ``` -------------------------------- ### Install CSS Bundle Plugin for Classic Remix Compiler Source: https://fontsource.org/docs/guides/remix.md Install the necessary plugin for CSS bundling in Classic Remix projects. ```sh npm install @remix-run/css-bundle yarn add @remix-run/css-bundle pnpm add @remix-run/css-bundle bun add @remix-run/css-bundle ``` -------------------------------- ### Install Fontsource Package Source: https://fontsource.org/docs/guides/svelte.md Install your chosen Fontsource font package using npm, yarn, pnpm, or bun. ```sh npm install @fontsource-variable/inter yarn add @fontsource-variable/inter pnpm add @fontsource-variable/inter bun add @fontsource-variable/inter ``` -------------------------------- ### Install Variable Font Package Source: https://fontsource.org/docs/getting-started/variable.md Install the Fontsource variable font package using npm, yarn, pnpm, or bun. ```sh npm install @fontsource-variable/nunito-sans yarn add @fontsource-variable/nunito-sans pnpm add @fontsource-variable/nunito-sans bun add @fontsource-variable/nunito-sans ``` -------------------------------- ### Install Fontsource with npm, yarn, pnpm, or bun Source: https://fontsource.org/docs/guides/nextjs.md Use your preferred package manager to install the Fontsource package for Open Sans Variable. ```sh npm install @fontsource-variable/open-sans yarn add @fontsource-variable/open-sans pnpm add @fontsource-variable/open-sans bun add @fontsource-variable/open-sans ``` -------------------------------- ### Axis Registry Response Example Source: https://fontsource.org/docs/api/axis-registry.md This JSON object illustrates the structure of a response from the Axis Registry endpoint. It shows an example entry for the 'ARRR' axis, detailing its properties. ```json { "...":{ "name":"AR Retinal Resolution", "description":"Resolution-specific enhancements in AR/VR typefaces to optimize rendering across the different resolutions of the headsets making designs accessible and easy to read.", "min":10, "max":60, "default":10, "precision":0 }, "..." } ``` -------------------------------- ### Query Fontlist API by Subsets Source: https://fontsource.org/docs/api/fontlist.md Example of querying the Fontlist API to retrieve fonts by their supported subsets. Only one query property can be used at a time. ```http GET https://api.fontsource.org/fontlist?subsets ``` -------------------------------- ### Stats API Response Example Source: https://fontsource.org/docs/api/stats.md This JSON object details the download statistics for a font, including total, static, and variable counts from NPM and jsDelivr. ```json { "total":{ "npmDownloadTotal":8566215, "npmDownloadMonthly":731202, "jsDelivrHitsTotal":46488758, "jsDelivrHitsMonthly":8210654 }, "static":{ "npmDownloadTotal":8288204, "npmDownloadMonthly":637495, "jsDelivrHitsTotal":46483427, "jsDelivrHitsMonthly":8207141 }, "variable":{ "npmDownloadTotal":278011, "npmDownloadMonthly":93707, "jsDelivrHitsTotal":5331, "jsDelivrHitsMonthly":3513 } } ``` -------------------------------- ### Get All Fonts Source: https://fontsource.org/docs/api/introduction.md This endpoint retrieves a list of all fonts supported by the Fontsource repository. It accepts a GET request. ```APIDOC ## GET api.fontsource.org/v1/fonts ### Description Retrieves a list of all fonts supported by the Fontsource repository. ### Method GET ### Endpoint /v1/fonts ### Parameters None ### Request Example None ### Response #### Success Response (200) - **fonts** (array) - A list of font objects. #### Response Example { "example": "[\n {\n \"id\": \"roboto\",\n \"family\": \"Roboto\",\n \"subsets\": [\n \"cyrillic\",\n \"greek\",\n \"latin\",\n \"latin-ext\",\n \"vietnamese\"\n ],\n \"weights\": [\n 100, 300, 400, 500, 700, 900\n ],\n \"styles\": [\n \"italic\",\n \"normal\"\n ],\n \"defSubset\": \"latin\",\n \"variable\": false,\n \"lastModified\": \"2023-01-01T00:00:00.000Z\",\n \"category\": \"sans-serif\"\n }\n]" ``` -------------------------------- ### Fontlist API Response Example Source: https://fontsource.org/docs/api/fontlist.md This is an example of the JSON response structure from the Fontlist API. It maps font IDs to their respective types (e.g., 'google', 'icons', 'other'). ```json { "...": "...", "abeezee": "google", "material-icons": "icons", "yakuhanjp": "other", "...": "..." } ``` -------------------------------- ### Get All Fonts Source: https://fontsource.org/docs/api/fonts.md Retrieve a list of all available fonts from the API. ```http GET https://api.fontsource.org/v1/fonts ``` -------------------------------- ### Filter Fonts by Weights and Styles Source: https://fontsource.org/docs/api/fonts.md Example of filtering fonts to include specific weights (400, 900) and styles (normal). ```http GET https://api.fontsource.org/v1/fonts?weights=400,900&styles=normal ``` -------------------------------- ### Query Fontlist API by Family Source: https://fontsource.org/docs/api/fontlist.md Example of querying the Fontlist API to retrieve fonts by their family name. Only one query property can be used at a time. ```http GET https://api.fontsource.org/fontlist?family ``` -------------------------------- ### Get Fonts with Query Parameters Source: https://fontsource.org/docs/api/fonts.md Filter the list of fonts by applying query parameters to the request URL. ```http GET https://api.fontsource.org/v1/fonts?{query} ``` -------------------------------- ### Import Material Icons Source: https://fontsource.org/docs/getting-started/material-icons.md Import the installed Material Icons font variations into your application's entry file or component. Ensure you have installed the desired packages using your package manager. ```jsx import "@fontsource/material-icons"; import "@fontsource/material-icons-round"; import "@fontsource/material-icons-outlined"; import "@fontsource/material-icons-sharp"; import "@fontsource/material-icons-two-tone"; ``` -------------------------------- ### Get NPM Version Information Source: https://fontsource.org/docs/api/version.md Use this endpoint to fetch the latest and historical NPM version data for a specific Fontsource package. The response includes static and variable version details. ```http GET https://api.fontsource.org/v1/version/{id} ``` -------------------------------- ### Get Package Version Information Source: https://fontsource.org/docs/api/version.md Fetches the NPM version details for a given Fontsource package ID. This includes the latest static version, a list of all static versions, and optionally the latest and all available variable font versions. ```APIDOC ## GET /v1/version/{id} ### Description Retrieves NPM version information for a specific Fontsource package. ### Method GET ### Endpoint `/v1/version/{id}` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the Fontsource package (e.g., 'abel', 'open-sans'). ### Response #### Success Response (200) Returns an object with the following attributes: - **latest** (string) - The latest static NPM version of the package. - **static** (string[]) - An array of static NPM versions, sorted from newest to oldest. - **latestVariable** (string, optional) - The latest variable NPM version of the package. - **variable** (string[], optional) - An array of variable NPM versions, sorted from newest to oldest. ### Response Example ```json { "latest": "5.0.4", "static": [ "5.0.4", "5.0.3", "5.0.2", "5.0.1", "5.0.0", "4.2.2", "4.2.1", "4.2.0", "4.1.1", "4.1.0", "4.0.1", "4.0.0" ], "latestVariable": "5.0.7", "variable": [ "5.0.7", "5.0.6", "5.0.5", "5.0.4", "5.0.3", "5.0.2", "5.0.1", "5.0.0" ] } ``` ### Example * `GET https://api.fontsource.org/v1/version/abel` * `GET https://api.fontsource.org/v1/version/open-sans` ``` -------------------------------- ### Font ID API Response Example Source: https://fontsource.org/docs/api/font-id.md This JSON object illustrates the structure of the response when querying the Font ID endpoint. It includes all available attributes for a font. ```json { "id": "abel", "family": "Abel", "subsets": ["latin"], "weights": [400], "styles": ["normal"], "unicodeRange": { "latin": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD" }, "defSubset": "latin", "variable": false, "lastModified": "2020-09-10", "category": "sans-serif", "version": "v12", "type": "google", "variants": { "400": { "normal": { "latin": { "url": { "woff2": "https://cdn.jsdelivr.net/fontsource/fonts/abel@latest/latin-400-normal.woff2", "woff": "https://cdn.jsdelivr.net/fontsource/fonts/abel@latest/latin-400-normal.woff", "ttf": "https://cdn.jsdelivr.net/fontsource/fonts/abel@latest/latin-400-normal.ttf" } } } } } } ``` -------------------------------- ### Get All Fonts Source: https://fontsource.org/docs/api/fonts.md Retrieves a list of all available fonts. This endpoint can be filtered using various query parameters to narrow down the results. ```APIDOC ## GET /v1/fonts ### Description Retrieves a list of all available fonts. Supports filtering via query parameters. ### Method GET ### Endpoint /v1/fonts ### Query Parameters - **id** (string) - Optional - The font ID. - **family** (string) - Optional - The font family name. - **subsets** (string) - Optional - Language subsets (e.g., `latin,latin-ext`). - **weights** (number[]) - Optional - Font weights (e.g., `400,900`). - **styles** (string[]) - Optional - Font styles (e.g., `normal,italic`). - **defSubset** (string) - Optional - The default subset. - **variable** (boolean) - Optional - Whether the font is variable (e.g., `true`). - **lastModified** (string) - Optional - Last modified date (e.g., `2020-09-02`). - **category** (string) - Optional - Font category (e.g., `sans-serif`). - **version** (string) - Optional - Font version (e.g., `v14`). - **type** (string) - Optional - Font type (e.g., `google`). ### Response #### Success Response (200) - **id** (string) - The font ID. - **family** (string) - The font family. - **subsets** (string[]) - Language subsets. - **weights** (number[]) - Font weights. - **styles** (string[]) - Font styles. - **defSubset** (string) - Default subset. - **variable** (boolean) - Indicates if the font is variable. - **lastModified** (string) - Last modified date. - **category** (string) - Font category. - **version** (string) - Font version. - **type** (string) - Font type. ### Response Example ```json [ { "id": "abeezee", "family": "ABeeZee", "subsets": ["latin"], "weights": [400], "styles": ["italic", "normal"], "defSubset": "latin", "variable": false, "lastModified": "2020-09-02", "category": "sans-serif", "version": "v14", "type": "google" } ] ``` ``` -------------------------------- ### Filter Fonts by Last Modified Date Source: https://fontsource.org/docs/api/fonts.md Example of filtering fonts that were last modified on a specific date. ```http GET https://api.fontsource.org/v1/fonts?lastModified=2022-09-22 ``` -------------------------------- ### Get Font Stats by ID Source: https://fontsource.org/docs/api/stats.md Retrieves download statistics for a specific font using its ID. ```APIDOC ## GET /v1/stats/{id} ### Description Retrieves download statistics for a specific font identified by its ID. ### Method GET ### Endpoint `/v1/stats/{id}` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the font. ### Response #### Success Response (200) - **total** (DownloadStats) - Total download counts. - **static** (DownloadStats) - Static download counts. - **variable** (DownloadStats) - Optional. Variable download counts. #### DownloadStats Object - **npmDownloadTotal** (number) - Total NPM download count. - **npmDownloadMonthly** (number) - Monthly NPM download count. - **jsDelivrHitsTotal** (number) - Total jsDelivr hits. - **jsDelivrHitsMonthly** (number) - Monthly jsDelivr hits. ### Response Example ```json { "total":{ "npmDownloadTotal":8566215, "npmDownloadMonthly":731202, "jsDelivrHitsTotal":46488758, "jsDelivrHitsMonthly":8210654 }, "static":{ "npmDownloadTotal":8288204, "npmDownloadMonthly":637495, "jsDelivrHitsTotal":46483427, "jsDelivrHitsMonthly":8207141 }, "variable":{ "npmDownloadTotal":278011, "npmDownloadMonthly":93707, "jsDelivrHitsTotal":5331, "jsDelivrHitsMonthly":3513 } } ``` ### Example Usage `GET https://api.fontsource.org/v1/stats/abel` `GET https://api.fontsource.org/v1/stats/open-sans` ``` -------------------------------- ### Query Fontlist API by Last Modified Date Source: https://fontsource.org/docs/api/fontlist.md Example of querying the Fontlist API to retrieve fonts based on their last modified date. Only one query property can be used at a time. ```http GET https://api.fontsource.org/fontlist?lastModified ``` -------------------------------- ### Import Material Symbols Variable Font Sets Source: https://fontsource.org/docs/getting-started/material-symbols.md Import the entire Material Symbols variable font set for outlined, rounded, and sharp styles. Ensure these packages are installed first. ```jsx import "@fontsource-variable/material-symbols-outlined"; import "@fontsource-variable/material-symbols-rounded"; import "@fontsource-variable/material-symbols-sharp"; ``` -------------------------------- ### Variable Endpoint Response Example Source: https://fontsource.org/docs/api/variable.md This JSON object details the axis data for a variable font, including its family name and specific axis properties like default, min, max, and step. ```json { "axes": { "slnt": { "default": "0", "min": "-10", "max": "0", "step": "1" }, "wght": { "default": "400", "min": "100", "max": "900", "step": "1" } }, "family": "Inter" } ``` -------------------------------- ### Get Font Details by ID Source: https://fontsource.org/docs/api/font-id.md Use this endpoint to fetch detailed information for a specific font. Replace `{id}` with the font's unique identifier. ```http GET https://api.fontsource.org/v1/fonts/{id} ``` -------------------------------- ### Filter Fonts by Subsets and Variable Status Source: https://fontsource.org/docs/api/fonts.md Example of filtering fonts to include specific subsets (latin, latin-ext) and only variable fonts. ```http GET https://api.fontsource.org/v1/fonts?subsets=latin,latin-ext&variable=true ``` -------------------------------- ### Apply Imported Font Styles Source: https://fontsource.org/docs/getting-started/sass-import.md Once imported, apply the font styles to elements using the `font-family` CSS property. This example sets 'Open Sans' as the font for the `body` element. ```css body { font-family: "Open Sans", sans-serif; } ``` -------------------------------- ### Get Axis Registry Source: https://fontsource.org/docs/api/axis-registry.md Retrieves a comprehensive list of all available variable font axis tags and their associated details. ```APIDOC ## GET https://api.fontsource.org/v1/axis-registry ### Description Retrieves a JSON object containing details for each variable font axis tag. ### Method GET ### Endpoint /v1/axis-registry ### Response #### Success Response (200) Returns an object where keys are axis tags (e.g., "ARRR") and values are `AxisRegistryItem` objects. - **tag** (Record) - Axis tag object #### AxisRegistryItem: - **name** (string) - Axis name - **description** (string) - Axis description - **min** (number) - Minimum value possible for axis - **max** (number) - Maximum value possible for axis - **default** (number) - Default value for axis - **precision** (number) - Precision ### Response Example ```json { "ARRR":{ "name":"AR Retinal Resolution", "description":"Resolution-specific enhancements in AR/VR typefaces to optimize rendering across the different resolutions of the headsets making designs accessible and easy to read.", "min":10, "max":60, "default":10, "precision":0 } } ``` ``` -------------------------------- ### Get Font List Source: https://fontsource.org/docs/api/fontlist.md Fetches a JSON object containing a list of fonts and their types. You can optionally query for specific font properties. ```APIDOC ## GET /fontlist ### Description Retrieves a list of all available fonts and their types. ### Method GET ### Endpoint https://api.fontsource.org/fontlist ### Query Parameters #### Query - **family** (string) - Optional - Filters by font family names. - **subsets** (string[]) - Optional - Filters by supported subsets. - **weights** (number[]) - Optional - Filters by supported weights. - **styles** (string[]) - Optional - Filters by supported styles. - **variable** (boolean) - Optional - Filters for variable fonts. - **category** (string) - Optional - Filters by font category. - **lastModified** (string) - Optional - Filters by last modified date. - **version** (string) - Optional - Filters by font version. - **type** (string) - Optional - Filters by font type (google, icons, other). **Note:** Only one query parameter can be used at a time. ### Response #### Success Response (200) - **{id}** (string) - The font ID. - **type** (google | icons | other) - The font type. ### Response Example ```json { "...", "abeezee": "google", "material-icons": "icons", "yakuhanjp": "other", "..." } ``` ``` -------------------------------- ### Import Standard Material Symbols Font Sets Source: https://fontsource.org/docs/getting-started/material-symbols.md Import the standard (non-variable) Material Symbols font sets for outlined, rounded, and sharp styles. This is an alternative if variable font support is not needed. Ensure these packages are installed. ```jsx import "@fontsource/material-symbols-outlined"; import "@fontsource/material-symbols-rounded"; import "@fontsource/material-symbols-sharp"; ``` -------------------------------- ### Fetch Stats for a Specific Font Source: https://fontsource.org/docs/api/stats.md Use this HTTP GET request to retrieve download statistics for a particular font by its ID. Replace '{id}' with the font's identifier. ```http GET https://api.fontsource.org/v1/stats/{id} ``` ```http GET https://api.fontsource.org/v1/stats/abel ``` ```http GET https://api.fontsource.org/v1/stats/open-sans ``` -------------------------------- ### Import Specific Material Symbols Variable Font Axes Source: https://fontsource.org/docs/getting-started/material-symbols.md Import specific axes (like fill, opsz, or full) for Material Symbols variable fonts. This allows for more granular control over icon styling. Ensure the corresponding packages are installed. ```jsx import "@fontsource-variable/material-symbols-outlined/fill.css"; import "@fontsource-variable/material-symbols-rounded/opsz.css"; import "@fontsource-variable/material-symbols-sharp/full.css"; ``` -------------------------------- ### Get Font by ID Source: https://fontsource.org/docs/api/font-id.md Fetches detailed information about a specific font using its unique ID. This endpoint is useful for retrieving all available metadata for a font, including its variants and file locations. ```APIDOC ## GET /v1/fonts/{id} ### Description Retrieves detailed information about a specific font using its unique ID. ### Method GET ### Endpoint /v1/fonts/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the font. ### Response #### Success Response (200) - **id** (string) - The font ID. - **family** (string) - The font family name. - **subsets** (string[]) - An array of language subsets supported by the font. - **weights** (number[]) - An array of font weights available. - **styles** (string[]) - An array of font styles available (e.g., 'normal', 'italic'). - **unicodeRange** (Record) - An object mapping subsets to their respective Unicode character ranges. - **defSubset** (string) - The default language subset for the font. - **variable** (boolean) - Indicates if the font is a variable font. - **lastModified** (string) - The date when the font was last modified. - **category** (string) - The font category (e.g., 'sans-serif', 'serif'). - **version** (string) - The version of the font. - **type** (string) - The type of font source (e.g., 'google', 'local'). - **variants** (Record) - An object detailing the available file variants for each weight, style, and subset, including URLs for different file formats (woff2, woff, ttf). ### Response Example ```json { "id": "abel", "family": "Abel", "subsets": ["latin"], "weights": [400], "styles": ["normal"], "unicodeRange": { "latin": "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD" }, "defSubset": "latin", "variable": false, "lastModified": "2020-09-10", "category": "sans-serif", "version": "v12", "type": "google", "variants": { "400": { "normal": { "latin": { "url": { "woff2": "https://cdn.jsdelivr.net/fontsource/fonts/abel@latest/latin-400-normal.woff2", "woff": "https://cdn.jsdelivr.net/fontsource/fonts/abel@latest/latin-400-normal.woff", "ttf": "https://cdn.jsdelivr.net/fontsource/fonts/abel@latest/latin-400-normal.ttf" } } } } } } ``` ``` -------------------------------- ### CSS Usage for Open Sans Variable Source: https://fontsource.org/docs/guides/nextjs.md Apply the imported 'Open Sans Variable' font to elements using standard CSS `font-family` property. This example shows usage for an `h1` tag. ```css h1 { font-family: "Open Sans Variable", sans-serif; } ``` -------------------------------- ### Configure CSS Bundle Plugin in Remix Source: https://fontsource.org/docs/guides/remix.md Configure your `root.tsx` file to use the CSS bundling plugin and import fonts. ```tsx import { cssBundleHref } from "@remix-run/css-bundle"; import type { LinksFunction } from "@remix-run/node"; import "@fontsource-variable/open-sans/wght.css"; export const links: LinksFunction = () => { return [ ...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []), // ... ]; }; ``` -------------------------------- ### Import Specific Open Sans Variations Source: https://fontsource.org/docs/getting-started/sass-import.md Import specific font weights and styles like 300-weight or 700-weight italic for Open Sans. Use `as` to alias the imported styles for cleaner usage. ```scss @use "pkg:@fontsource/open-sans/300.css" as OpenSansLight; ``` ```scss @use "pkg:@fontsource/open-sans/700-italic.css" as OpenSansBoldItalic; ``` -------------------------------- ### Import Specific Font Weights and Styles Source: https://fontsource.org/docs/getting-started/install.md Import only the specific weights and styles needed to minimize bundle size. Each import loads one font file. ```jsx import "@fontsource/open-sans/300.css"; // Includes weight 300. ``` ```jsx import "@fontsource/open-sans/900-italic.css"; // Includes weight 900 in italic style. ``` ```jsx import "@fontsource/open-sans/900.css"; // Includes weight 900. ``` ```jsx import "@fontsource/open-sans/900-italic.css"; // Includes weight 900 in italic style. ``` -------------------------------- ### Get Variable Font Data Source: https://fontsource.org/docs/api/variable.md Retrieves axis data for a specific variable font by its ID. ```APIDOC ## GET /v1/variable/{id} ### Description Retrieves axis data for a specific variable font. ### Method GET ### Endpoint `/v1/variable/{id}` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the variable font. ### Response #### Success Response (200) - **family** (string) - The name of the font family. - **axes** (Record) - An object containing axis data for the font. ##### AxesData - **default** (number) - The default value for the axis. - **min** (number) - The minimum value for the axis. - **max** (number) - The maximum value for the axis. - **step** (number) - The step value for the axis. ### Response Example ```json { "axes": { "slnt": { "default": "0", "min": "-10", "max": "0", "step": "1" }, "wght": { "default": "400", "min": "100", "max": "900", "step": "1" } }, "family": "Inter" } ``` ``` -------------------------------- ### Configure Webpack Loaders Source: https://fontsource.org/docs/guides/webpack.md Add rules to your `webpack.config.js` to process font files and CSS. ```javascript module.exports = { module: { rules: [ { test: /\.(woff|woff2|eot|ttf|otf)$/, use: ["file-loader"], }, { test: /\.css$/i, use: ["css-loader"], }, ], }, }; ``` -------------------------------- ### Import Standard Variable Axes CSS Files Source: https://fontsource.org/docs/getting-started/variable.md Import CSS files for standard variable font axes, including italic variations. ```jsx import "@fontsource-variable/nunito-sans/standard.css"; import "@fontsource-variable/nunito-sans/standard-italic.css"; ``` -------------------------------- ### Preload Open Sans Font with Vite Source: https://fontsource.org/docs/getting-started/preload.md Import the font file URL using Vite's `?url` directive and include a preload link in the HTML head. Avoid preloading all font files to prevent increased initial load times. ```jsx import '@fontsource-variable/open-sans'; import openSansWoff2 from '@fontsource-variable/open-sans/files/open-sans-latin-wght-normal.woff2?url'; const App = () => { return ( ); }; ``` -------------------------------- ### Import Fontsource Stylesheets using Direct URLs Source: https://fontsource.org/docs/getting-started/sass-introduction.md If the pkg: import directive is not usable, import Fontsource stylesheets directly by referencing the CSS file path within your node_modules directory. ```scss // Adjust path as necessary. @use "../node_modules/@fontsource-utils/src/mixins.scss" as fontsource; @use "../node_modules/@fontsource-variable/recursive/scss/metadata.scss" as recursive; ``` -------------------------------- ### Compile Sass with pkg: Importer via Command Line Source: https://fontsource.org/docs/getting-started/sass-introduction.md Use the `--pkg-importer=node` flag when compiling Sass files from the command line to enable resolution of pkg: imports. ```sh sass --pkg-importer=node style.scss style.css ``` -------------------------------- ### Import Font Variant in Qwik Layout Source: https://fontsource.org/docs/guides/qwik.md Import a chosen font variant into the `routes/layout.tsx` file for global availability. This is the recommended approach for Qwik City projects. ```tsx import { component$ } from "@builder.io/qwik"; import "@fontsource-variable/open-sans/wght.css"; export default component$(() => { return ( <>