get_font_css
Generate ready-to-use CSS font embedding snippets for any Fontsource font, including CDN links, @import, npm, font-family, and @font-face rules. Supports weights, styles, subsets, and variable fonts.
Instructions
Font embedding snippets: CDN tags, @import lines, npm install and import lines, the font-family rule, and the @font-face CSS text with absolute URLs, safe to inline. Defaults to weight 400 normal. Each extra weight and style combination adds about 1.5KB of CSS. Set variable:true for the variable package; the font-family then becomes " Variable".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Fontsource id slug such as "inter", "open-sans", or "noto-sans-jp". Get it from search_fonts. It is not the display name. | |
| styles | No | Default ["normal"]. | |
| subsets | No | Static only. Omit for the all-subsets file per weight, or set it for the smaller per-subset files. | |
| weights | No | Static only. Default [400]. | |
| variable | No | Use @fontsource-variable/<id>. The font must be variable. | |
| variableFile | No | Variable only. CSS file stem: "wght" (default, always exists), or "standard", "full", "opsz", and so on where the package ships them. |