webfont 12.3.0 → 12.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +1 -1
- package/README.md +73 -6
- package/dist/cli.mjs +273 -255
- package/dist/index.js +1 -1
- package/dist/index.mjs +142 -132
- package/dist/src/lib/ttfEncode.d.mts +3 -0
- package/dist/src/lib/ttfEncode.d.ts +3 -0
- package/dist/src/standalone/inputMode.d.mts +1 -1
- package/dist/src/standalone/inputMode.d.ts +1 -1
- package/dist/src/types/TranscodedFont.d.mts +1 -0
- package/dist/src/types/TranscodedFont.d.ts +1 -0
- package/package.json +9 -1
package/NOTICE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# webfont — Legal
|
|
1
|
+
# webfont — Legal Notices
|
|
2
2
|
|
|
3
3
|
This document covers **copyright and licensing for fonts you process**, **disclaimers** about using the webfont software, **community attribution guidelines**, and **third-party open-source components** bundled with or used by this project.
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ See **[FEATURES.md](./FEATURES.md)** for the canonical capability list (what is
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
18
18
|
- **SVG icon pipeline** (default): `.svg` icons → `svg`, `ttf`, `eot`, `woff`, `woff2` (not `otf`);
|
|
19
|
-
- **TTF encoding**: one or more `.ttf` files → `ttf` (pass-through), `eot`, `woff`, and/or `woff2` (auto-detected — no extra flag);
|
|
19
|
+
- **TTF encoding**: one or more `.ttf` files → `ttf` (pass-through), `svg` (SVG font), `eot`, `woff`, and/or `woff2` (auto-detected — no extra flag);
|
|
20
20
|
- **Webfont decompression**: one `.woff` or `.woff2` file → `ttf` and/or `otf` matching the **embedded SFNT flavor** (decompress only — not TTF ↔ OTF transcoding);
|
|
21
21
|
- Config files: `JavaScript`, `JSON`, or `YAML` via [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig);
|
|
22
22
|
- Built-in and custom CSS templates (`css`, `scss`, [`styl`](https://github.com/itgalaxy/webfont/pull/164/));
|
|
@@ -30,7 +30,7 @@ webfont runs one of three pipelines depending on matched input files. They canno
|
|
|
30
30
|
| Mode | Input | Outputs | Notes |
|
|
31
31
|
|------|--------|---------|--------|
|
|
32
32
|
| **SVG icons** | One or more `.svg` files | `svg`, `ttf`, `eot`, `woff`, `woff2` | Default. Builds TrueType via `svg2ttf`. **`otf` is rejected** — use `ttf`. |
|
|
33
|
-
| **TTF encoding** | One or more `.ttf` files | `ttf`, `eot`, `woff`, and/or `woff2` per input | Auto-detected. Default when SVG-pipeline `formats` are still configured: `woff` + `woff2
|
|
33
|
+
| **TTF encoding** | One or more `.ttf` files | `ttf`, `svg` (SVG font), `eot`, `woff`, and/or `woff2` per input | Auto-detected. Default when SVG-pipeline `formats` are still configured: `woff` + `woff2` (`svg` is opt-in). No templates. |
|
|
34
34
|
| **Webfont decompress** | One or more `.woff` / `.woff2` paths, globs, or `http(s)` URLs | `ttf` and/or `otf` per input | One output file per source (basename from filename; collisions get `-woff`/`-woff2`). Not a single merged font. |
|
|
35
35
|
|
|
36
36
|
**Not supported today**
|
|
@@ -49,12 +49,71 @@ webfont is a technical tool. **Decompressing or generating fonts does not grant
|
|
|
49
49
|
|
|
50
50
|
Full details, disclaimers, community attribution guidelines, and third-party library notices: **[NOTICE.md](./NOTICE.md)**.
|
|
51
51
|
|
|
52
|
+
## Comparison with `webfonts`
|
|
53
|
+
|
|
54
|
+
`webfont` (this project) is sometimes confused with the older, **unmaintained** [`webfonts`](https://github.com/uipoet/webfonts) package (note the trailing `s`). `webfonts` last shipped around 2015 and requires a **Java** runtime (it bundles `batik-ttf2svg`, `sfnt2woff`, and `ttf2eot`). `webfont` is **pure JavaScript**, actively maintained, and does everything the *useful* parts of `webfonts` did — plus SVG-icon fonts, WOFF2, decompression, templates, and a Node.js API.
|
|
55
|
+
|
|
56
|
+
| Capability | `webfont` (this project) | `webfonts` ([uipoet/webfonts](https://github.com/uipoet/webfonts)) |
|
|
57
|
+
|------------|:------------------------:|:-----------------------------------------------------------------:|
|
|
58
|
+
| Maintained | ✅ | ❌ (last release ~2015) |
|
|
59
|
+
| Runtime | Pure JS (Node.js) | Node.js **+ Java** |
|
|
60
|
+
| SVG icons → font | ✅ (default pipeline) | ❌ |
|
|
61
|
+
| TTF input → web formats | ✅ | ✅ |
|
|
62
|
+
| Output: `woff2` (Brotli) | ✅ | ❌ |
|
|
63
|
+
| Output: `woff` / `eot` | ✅ | ✅ |
|
|
64
|
+
| Output: `svg` font | ✅ (`-f svg`, opt-in) | ✅ |
|
|
65
|
+
| Choose which formats to emit | ✅ (`-f` / `formats`) | ❌ (always `woff` + `eot` + `svg`) |
|
|
66
|
+
| WOFF/WOFF2 → TTF/OTF decompression | ✅ | ❌ |
|
|
67
|
+
| Node.js / programmatic API | ✅ (`webfont()`) | ❌ (CLI only) |
|
|
68
|
+
| CSS / SCSS / Styl templates | ✅ | ❌ (manual `@font-face` snippet) |
|
|
69
|
+
| Config files (cosmiconfig) | ✅ | ❌ |
|
|
70
|
+
| `.otf` as a **source** | ❌ ([tracking #767](https://github.com/itgalaxy/webfont/issues/767)) | ❌ ([requested](https://github.com/uipoet/webfonts/issues/4)) |
|
|
71
|
+
|
|
72
|
+
### Migrating from `webfonts`
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# webfonts (unmaintained): converts a directory of TTFs, always emits woff + eot + svg
|
|
76
|
+
webfonts fonts/ -o dist/
|
|
77
|
+
|
|
78
|
+
# webfont: pick your formats explicitly (woff2 recommended for the web)
|
|
79
|
+
webfont "fonts/*.ttf" -f woff2,woff,eot,svg -d dist --dest-create
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`webfont` adds `woff2` (much smaller than the legacy formats), lets you emit only what you ship, and needs no Java toolchain.
|
|
83
|
+
|
|
84
|
+
## Comparison with `grunt-webfont`
|
|
85
|
+
|
|
86
|
+
[`grunt-webfont`](https://github.com/sapegin/grunt-webfont) is the classic "SVG → webfont" **Grunt plugin** (~1.1k★, MIT). It is **archived** (read-only since 2021, last release `v1.2.0`), and its best-fidelity output relies on a native **FontForge** binary (its pure-`node` engine can't do ligatures). `webfont` is a framework-agnostic, actively maintained, pure-JS library **and** CLI: it does everything grunt-webfont *generated* — plus TTF encoding, WOFF/WOFF2 decompression, more templates, and programmatic hooks. The one thing grunt-webfont has that `webfont` doesn't is native Grunt wiring (tracked in [#771](https://github.com/itgalaxy/webfont/issues/771)); you can already drive `webfont()` from a small custom Grunt task.
|
|
87
|
+
|
|
88
|
+
| Capability | `webfont` (this project) | `grunt-webfont` ([sapegin/grunt-webfont](https://github.com/sapegin/grunt-webfont)) |
|
|
89
|
+
|------------|:------------------------:|:----------------------------------------------------------------------------------:|
|
|
90
|
+
| Maintained | ✅ | ❌ (archived 2021, `v1.2.0`) |
|
|
91
|
+
| Runtime | Node API **+ CLI** (any build tool) | **Grunt task only** |
|
|
92
|
+
| Engine | Pure JS (`svg2ttf`) | `node` **or** FontForge binary |
|
|
93
|
+
| SVG icons → font | ✅ | ✅ |
|
|
94
|
+
| Output formats | `svg, ttf, eot, woff, woff2` | `eot, woff2, woff, ttf, svg` |
|
|
95
|
+
| TTF input → web formats | ✅ | ❌ |
|
|
96
|
+
| WOFF/WOFF2 → TTF/OTF decompression | ✅ | ❌ |
|
|
97
|
+
| Stylesheets | `css, scss, styl, html, json` + custom Nunjucks, multiple per run | `css, sass, scss, less, stylus` + custom |
|
|
98
|
+
| CSS syntax presets (BEM / Bootstrap) | ❌ (use a custom template) | ✅ |
|
|
99
|
+
| `data:uri` embedding in CSS | ❌ | ✅ (`embed`) |
|
|
100
|
+
| Autohinting (`ttfautohint`) | via `ttfPostProcess` hook (external, opt-in) | built-in (`autoHint`) |
|
|
101
|
+
| Ligatures | ✅ (opt-in) | ✅ (FontForge engine only) |
|
|
102
|
+
| Codepoint map persistence | ❌ | ✅ (`codepointsFile`) |
|
|
103
|
+
| Programmatic API | ✅ (`webfont()`) | ❌ (Grunt only) |
|
|
104
|
+
| SVG diagnostics | ✅ (alpha) | ❌ |
|
|
105
|
+
| Grunt integration | ⏳ ([#771](https://github.com/itgalaxy/webfont/issues/771)) | ✅ (native) |
|
|
106
|
+
|
|
107
|
+
If you only need the generation that grunt-webfont did, `webfont` is a maintained, FontForge-free replacement. If you specifically need BEM/Bootstrap CSS presets or `data:uri` embedding today, use a [custom template](#template).
|
|
108
|
+
|
|
52
109
|
## Table Of Contents
|
|
53
110
|
|
|
54
111
|
- [Webfont](#webfont)
|
|
55
112
|
- [Features](#features)
|
|
56
113
|
- [Input modes](#input-modes)
|
|
57
114
|
- [Font licensing](#font-licensing)
|
|
115
|
+
- [Comparison with `webfonts`](#comparison-with-webfonts)
|
|
116
|
+
- [Comparison with `grunt-webfont`](#comparison-with-grunt-webfont)
|
|
58
117
|
- [Installation](#installation)
|
|
59
118
|
- [Usage](#usage)
|
|
60
119
|
- [Options](#options)
|
|
@@ -68,7 +127,7 @@ Full details, disclaimers, community attribution guidelines, and third-party lib
|
|
|
68
127
|
- [Roadmap](#roadmap)
|
|
69
128
|
- [Contribution](#contribution)
|
|
70
129
|
- [Changelog](#changelog)
|
|
71
|
-
- [Legal
|
|
130
|
+
- [Legal Notices](#legal-notices)
|
|
72
131
|
- [License](#license)
|
|
73
132
|
|
|
74
133
|
---
|
|
@@ -157,6 +216,13 @@ const subset = await webfont({
|
|
|
157
216
|
formats: ["woff2"],
|
|
158
217
|
});
|
|
159
218
|
|
|
219
|
+
// TTF → SVG font (legacy format; opt-in, pure JS via fonteditor-core)
|
|
220
|
+
const svgFont = await webfont({
|
|
221
|
+
files: "path/to/font.ttf",
|
|
222
|
+
formats: ["svg"],
|
|
223
|
+
});
|
|
224
|
+
// svgFont.svg → SVG font as a string
|
|
225
|
+
|
|
160
226
|
// Batch: multiple TTF files in one run
|
|
161
227
|
const batch = await webfont({
|
|
162
228
|
files: ["fonts/Inter-Regular.ttf", "fonts/Inter-Bold.ttf"],
|
|
@@ -292,7 +358,7 @@ Notes:
|
|
|
292
358
|
- Possible values: `svg`, `ttf`, `otf`, `eot`, `woff`, `woff2`
|
|
293
359
|
- Description: Font file types to generate.
|
|
294
360
|
- **SVG input**: `svg`, `ttf`, `eot`, `woff`, `woff2` only. **`otf` is not supported** (pipeline uses TrueType outlines).
|
|
295
|
-
- **TTF input**: `ttf`, `eot`, `woff`, and/or `woff2`
|
|
361
|
+
- **TTF input**: `svg` (SVG font), `ttf`, `eot`, `woff`, and/or `woff2`. `svg` is **opt-in** (not in the default `woff` + `woff2` set); **`otf` is not produced** in this mode.
|
|
296
362
|
- **WOFF/WOFF2 input**: `ttf` and/or `otf` only — must match the decompressed SFNT flavor inside the file (not arbitrary transcoding). `eot`, `woff`, `woff2`, and `svg` are not produced in this mode.
|
|
297
363
|
- CLI: pass `-f` / `--formats` as a JSON array (for example `'["woff2"]'`) or as a comma-separated list (for example `woff2` or `svg, ttf, woff2`). Invalid format names throw an error.
|
|
298
364
|
- API and config files: `formats` must be an array of the values above; unknown names (for example `icon`) throw before the pipeline runs.
|
|
@@ -344,7 +410,7 @@ Notes:
|
|
|
344
410
|
|
|
345
411
|
- Type: `string`
|
|
346
412
|
- Default: Same as [`fontName`](#fontname) when not set.
|
|
347
|
-
- Description: CSS `font-family` name emitted by built-in templates (`fontFamily` in Nunjucks context). Output **font files** are always named after `fontName` (for example `icons-a.woff2`); built-in templates reference those files with `
|
|
413
|
+
- Description: CSS `font-family` name emitted by built-in templates (`fontFamily` in Nunjucks context). Output **font files** are always named after `fontName` (for example `icons-a.woff2`); built-in templates reference those files with Nunjucks `fontName` / `fontFamily` placeholders in `url(...)` and `font-family` ([#331](https://github.com/itgalaxy/webfont/issues/331)).
|
|
348
414
|
|
|
349
415
|
#### `templateCacheString`
|
|
350
416
|
|
|
@@ -860,6 +926,7 @@ The CLI can exit the process with the following exit codes:
|
|
|
860
926
|
- [ttf2eot](https://github.com/fontello/ttf2eot) - Converts TTF fonts to EOT format.
|
|
861
927
|
- [ttf2woff](https://github.com/fontello/ttf2woff) - Converts TTF fonts to WOFF format.
|
|
862
928
|
- [wawoff2](https://github.com/fontello/wawoff2) - Converts TTF fonts to WOFF2 and versa vice.
|
|
929
|
+
- [fontTools](https://github.com/fonttools/fonttools) - Complementary low-level font toolkit (Python) for jobs webfont does not cover: subsetting, variable fonts, OpenType feature compilation, table editing, and TTX (font ⇄ XML). Generate the font with webfont, then inspect or optimize it with fontTools.
|
|
863
930
|
|
|
864
931
|
## Roadmap
|
|
865
932
|
|
|
@@ -875,7 +942,7 @@ Feel free to push your code if you agree with publishing under the MIT license.
|
|
|
875
942
|
|
|
876
943
|
Check our [Changelog](CHANGELOG.md)
|
|
877
944
|
|
|
878
|
-
## Legal
|
|
945
|
+
## Legal Notices
|
|
879
946
|
|
|
880
947
|
Copyright, disclaimers, font licensing expectations (including WOFF/WOFF2 decompression), community attribution guidelines, and third-party open-source dependencies are documented in **[NOTICE.md](./NOTICE.md)**.
|
|
881
948
|
|