npm.io
12.7.0 • Published 1 month agoCLI

webfont

Licence
MIT
Version
12.7.0
Deps
17
Size
252 kB
Vulns
0
Weekly
0
Stars
308

webfont

Generator of fonts from SVG icons; decompress WOFF/WOFF2 to embedded TTF/OTF (not TTFOTF transcoding).

Requires Node.js >= 24.14.0. Use at build time only — do not import from browser or React client bundles (#198).

Install

npm install --save-dev webfont

Add a CLI script (optional):

{
  "scripts": {
    "icons": "webfont 'src/icons/*.svg' -d dist/fonts -t css"
  }
}

Full setup (cosmiconfig, verification, first run): install.md · webfont.js.org/introduction/install

Usage

Use the named export (recommended for ESM and CommonJS):

import { webfont } from "webfont";

const result = await webfont({
  files: "src/svg-icons/**/*.svg",
  fontName: "my-font-name",
});

CommonJS:

const { webfont } = require("webfont");

import webfont from "webfont" works on 12.x+ (default export is the function). On older releases use the named import — see migration notes.

Pipelines

Each run uses one mode (inputs cannot be mixed):

  • SVG icons (default) — .svgsvg, ttf, eot, woff, woff2
  • TTF encoding.ttfwoff, woff2, and optional svg / eot (auto-detected)
  • Webfont decompress.woff / .woff2 (paths, globs, or URLs) → ttf and/or otf per file

Details and limits: webfont.js.org/introduction/getting-started · Features

Documentation (shipped with this package)

Guide File
Install & CLI wiring install.md
webfont() options & svgicons2svgfont docs/configuration.md
CLI flags & exit codes docs/cli.md
Font licensing & legal notices NOTICE.md

More documentation

License

The webfont software is licensed under the MIT License. That license does not apply to fonts or icons you process with the tool — see NOTICE.md.

Keywords