Generate optimal font subsets for your Astro-powered websites
npm install @namchee/astro-subfontAstro integration of subfont library. Generate optimized font subset for your Astro site.
1. Astro 4.x
You can install this package through astro add
``bashUsing pnpm
pnpm astro add @namchee/astro-subfont
Additionaly, you can also install this package manually
`bash
Using pnpm
pnpm install -D @namchee/astro-subfontUsing npm
npm install -D @namchee/astro-subfontUsing yarn
yarn add -D @namchee/astro-subfontUsing bun
bun add -D @namchee/astro-subfont
`After installation, you can integrate this integration in your Astro config
`js
import { defineConfig } from 'astro/config';import { subset } from '@namchee/astro-subfont';
export default defineConfig({
integrations: [
subset(),
]
})
`Configuration
This integration can be configured by passing a configuration object with the following properties:
| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
|
whitelist | string | '' | Additional characters to be included in font subsets. Use this option if you find some characters are missing after subset. |
| optimizeVariableFonts | boolean | true | Allow optimization of variable font features, such as weights and axes. Experimental. |
| inline | boolean | false | Inline the optimized fonts directly in the @font-face declaration. |
| dynamic | boolean | false | Analyze webfonts usage dynamically by running headless browsers. |
| debug | boolean | false | Enable verbose output to stdout`. |