Fonts are organized by purpose under assets/fonts/: headline/, body/, mono/. Production and dev builds (npm run build / npm run start) copy those files into build/fonts/ via webpack, so PHP does not need to run on every compile. The npm run fonts tool is optional for day-to-day builds; use it when you add, remove, or rename font files and want to regenerate inc/setup/font-preload.php and refresh theme.json from disk (see tools). Runtime font registration also considers assets/fonts/ and build/fonts/ via inc/setup/dynamic-theme-json.php. Use in SCSS as var(--wp--preset--font-family--headline) etc.
npm run build/npm run start— Bundles the theme and copiesassets/fonts/**/*intobuild/fonts/(same layout as source).npm run fonts— PHP: scanassets/fonts/, copy tobuild/fonts/, regenerate preload PHP, updatetheme.json. Run when the font set changes and you want generated artifacts refreshed.npm run fonts:detect— List detected fonts (paths, family, weight, style).npm run fonts:generate— Regeneratetheme.jsonfont families from scanned font files (php tools/generate-theme-json.php).
- Place font files in the correct folder (
headline/,body/,mono/). - Run
npm run build(ornpm run start); confirmbuild/fonts/contains the expected files. - When you change which fonts exist or their filenames, run
npm run fonts(or at leastnpm run fonts:generateif you only needtheme.json), then commit updatedtheme.jsonif applicable. Checkinc/setup/font-preload.phpafternpm run fonts(that file is gitignored; generate it locally or in CI if you rely on preloads).
Family, weight, and style are inferred from folder and filename (e.g. weights 100–900, styles normal/italic/oblique). See inc/setup/dynamic-theme-json.php and tools for patterns.
When WP_DEBUG is true, the WDSBT Settings page can show font detection debug: counts, families, variants. If fonts don’t appear, confirm folder names and supported extensions (e.g. .woff2, .woff), and run npm run fonts:detect.