webfont 11.2.26 → 12.0.0
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 +153 -0
- package/README.md +135 -28
- package/dist/cli.mjs +628 -0
- package/dist/index.js +1 -507
- package/dist/src/index.d.ts +2 -2
- package/dist/src/lib/execCLI/index.d.ts +3 -4
- package/dist/src/lib/inputSource.d.ts +5 -0
- package/dist/src/lib/p-limit/index.d.ts +2 -0
- package/dist/src/lib/sfnt/flavor.d.ts +2 -0
- package/dist/src/lib/svgicons2svgfont/index.d.ts +9 -0
- package/dist/src/lib/ttf2eot/index.d.ts +2 -0
- package/dist/src/standalone/convertWebfontInput.d.ts +3 -0
- package/dist/src/standalone/fetchWebfontUrl.d.ts +1 -0
- package/dist/src/standalone/glyphsData.d.ts +2 -2
- package/dist/src/standalone/index.d.ts +3 -3
- package/dist/src/standalone/inputMode.d.ts +7 -0
- package/dist/src/standalone/options.d.ts +3 -3
- package/dist/src/standalone/templateFonts.d.ts +3 -0
- package/dist/src/standalone/toTtf.d.ts +4 -0
- package/dist/src/types/DecompressedFont.d.ts +5 -0
- package/dist/src/types/Format.d.ts +4 -4
- package/dist/src/types/GlyphData.d.ts +2 -2
- package/dist/src/types/GlyphMetadata.d.ts +1 -1
- package/dist/src/types/GlyphTransformFn.d.ts +2 -2
- package/dist/src/types/InitialOptions.d.ts +5 -4
- package/dist/src/types/MetadataProvider.d.ts +5 -0
- package/dist/src/types/OptionsBase.d.ts +3 -2
- package/dist/src/types/Result.d.ts +8 -5
- package/dist/src/types/ResultConfig.d.ts +4 -0
- package/dist/src/types/WebfontOptions.d.ts +29 -3
- package/dist/src/types/index.d.ts +7 -6
- package/package.json +52 -57
- package/dist/cli.js +0 -801
- package/dist/jest.config.d.ts +0 -3
- package/dist/src/cli/index.d.ts +0 -1
- package/dist/src/cli/index.test.d.ts +0 -1
- package/dist/src/cli/meow/index.d.ts +0 -104
- package/dist/src/index.test.d.ts +0 -1
- package/dist/src/standalone/index.test.d.ts +0 -1
package/NOTICE.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# webfont — Legal notice
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
It does **not** replace the [MIT License](./LICENSE) for the webfont source code. If anything here conflicts with `LICENSE`, `LICENSE` governs the software itself.
|
|
6
|
+
|
|
7
|
+
**This is not legal advice.** When in doubt about a font or icon license, consult the rights holder or qualified counsel.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. webfont software license
|
|
12
|
+
|
|
13
|
+
The **webfont** program (source code, CLI, and npm package) is licensed under the **[MIT License](./LICENSE)**.
|
|
14
|
+
|
|
15
|
+
Copyright (c) 2016–present [itgalaxy](https://github.com/itgalaxy).
|
|
16
|
+
|
|
17
|
+
You may use, copy, modify, and distribute the **software** under the terms of `LICENSE`, provided the copyright and permission notice are preserved in copies or substantial portions.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 2. Disclaimer of warranties and limitation of liability
|
|
22
|
+
|
|
23
|
+
THE WEBFONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
24
|
+
|
|
25
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
+
|
|
27
|
+
**You are solely responsible** for how you use webfont, what files you pass into it, and what you do with the output.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 3. Fonts and icons you provide (user content)
|
|
32
|
+
|
|
33
|
+
webfont is a **technical tool**. It does **not**:
|
|
34
|
+
|
|
35
|
+
- grant any copyright, trademark, or distribution rights in fonts or icons;
|
|
36
|
+
- change the license terms of input or output files;
|
|
37
|
+
- verify that you have permission to use, modify, decompress, convert, or redistribute any font or SVG;
|
|
38
|
+
- remove or replace copyright or license metadata embedded in font files (name tables, etc.).
|
|
39
|
+
|
|
40
|
+
### 3.1 SVG icon input
|
|
41
|
+
|
|
42
|
+
If you build a font from **`.svg` icons**, you must have the right to use those artworks (your own work, licensed stock, client assets with permission, open-source icons under compatible terms, etc.).
|
|
43
|
+
|
|
44
|
+
Generated font files may be subject to the same restrictions as the source icons and to any third-party notices you embed via options such as `metadata` / `copyright`.
|
|
45
|
+
|
|
46
|
+
### 3.2 WOFF / WOFF2 decompression
|
|
47
|
+
|
|
48
|
+
If you **decompress** one or more `.woff` or `.woff2` files (from disk or from an `http(s)` URL) to `.ttf` or `.otf`, you are extracting the **SFNT payload** inside each container. That operation:
|
|
49
|
+
|
|
50
|
+
- does **not** make a restricted or commercial font free to use or share;
|
|
51
|
+
- does **not** bypass foundry EULAs, app terms of service, CDN hotlinking policies, or site download terms;
|
|
52
|
+
- may produce files that are **easier to reuse** than the original webfonts — compliance with the **original font license** remains your obligation;
|
|
53
|
+
- does **not** merge multiple weights into one font file — each input yields a separate output.
|
|
54
|
+
|
|
55
|
+
**Only process fonts you are authorized to use and download** under their license. For remote URLs, you must also have permission to fetch and store those bytes.
|
|
56
|
+
|
|
57
|
+
### 3.3 Redistribution of output
|
|
58
|
+
|
|
59
|
+
Publishing, shipping, or sublicensing fonts produced or extracted with webfont (in apps, websites, PDFs, design assets, npm packages, etc.) is **your responsibility**. The MIT license on webfont does **not** apply to those font files.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 4. Community attribution guidelines
|
|
64
|
+
|
|
65
|
+
These guidelines help the community use and reference webfont fairly. They are **social expectations**, not additional legal terms beyond `LICENSE`.
|
|
66
|
+
|
|
67
|
+
### 4.1 Using webfont in your project
|
|
68
|
+
|
|
69
|
+
- **No attribution required** for normal use (install via npm, run in CI, internal tooling) under the MIT License.
|
|
70
|
+
- **Appreciated** when webfont is a visible part of a product, tutorial, or open-source repo: mention [webfont](https://github.com/itgalaxy/webfont) and link to the repository or [npm package](https://www.npmjs.com/package/webfont).
|
|
71
|
+
|
|
72
|
+
### 4.2 Tutorials, posts, and courses
|
|
73
|
+
|
|
74
|
+
When documenting a workflow that centers on webfont, please:
|
|
75
|
+
|
|
76
|
+
- name the tool (**webfont**) and link to the official repo or npm page;
|
|
77
|
+
- distinguish **webfont the software** (MIT) from **fonts you demonstrate** (which may be proprietary);
|
|
78
|
+
- avoid implying **endorsement** by itgalaxy unless you have written permission.
|
|
79
|
+
|
|
80
|
+
### 4.3 Forks, wrappers, and hosted services
|
|
81
|
+
|
|
82
|
+
If you redistribute webfont code, ship a fork, or offer a hosted “font converter” built on webfont:
|
|
83
|
+
|
|
84
|
+
- comply with the **MIT License** (retain copyright and permission notice);
|
|
85
|
+
- do **not** use the itgalaxy name, logo, or webfont branding to suggest official affiliation without permission;
|
|
86
|
+
- provide **your own** terms and privacy policy for user-uploaded fonts; make clear that **users** must have rights to their files.
|
|
87
|
+
|
|
88
|
+
### 4.4 Citing underlying libraries
|
|
89
|
+
|
|
90
|
+
webfont builds on several open-source font libraries (see [Section 5](#5-third-party-open-source-dependencies)). If you publish academic work, a detailed case study, or compliance documentation that discusses **how** conversion is implemented, consider citing those libraries alongside webfont.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 5. Third-party open-source dependencies
|
|
95
|
+
|
|
96
|
+
webfont depends on the following **runtime** npm packages (direct dependencies). Versions follow `package.json` / `package-lock.json` at release time.
|
|
97
|
+
|
|
98
|
+
| Package | Typical license | Role in webfont |
|
|
99
|
+
|---------|-----------------|-----------------|
|
|
100
|
+
| [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig) | MIT | Configuration file discovery |
|
|
101
|
+
| [deepmerge](https://github.com/TehShrike/deepmerge) | MIT | Option merging |
|
|
102
|
+
| [fontverter](https://github.com/papandreou/fontverter) | BSD-3-Clause | WOFF/WOFF2 → SFNT decompression |
|
|
103
|
+
| [globby](https://github.com/sindresorhus/globby) | MIT | Input file globbing |
|
|
104
|
+
| [meow](https://github.com/sindresorhus/meow) | MIT | CLI argument parsing |
|
|
105
|
+
| [nunjucks](https://github.com/mozilla/nunjucks) | BSD-2-Clause | CSS / SCSS / Styl templates |
|
|
106
|
+
| [p-limit](https://github.com/sindresorhus/p-limit) | MIT | Concurrency limiting |
|
|
107
|
+
| [resolve-from](https://github.com/sindresorhus/resolve-from) | MIT | Module resolution |
|
|
108
|
+
| [svg2ttf](https://github.com/fontello/svg2ttf) | MIT | SVG font → TTF |
|
|
109
|
+
| [svgicons2svgfont](https://github.com/nfroidure/svgicons2svgfont) | MIT | SVG icons → SVG font |
|
|
110
|
+
| [ttf2eot](https://github.com/fontello/ttf2eot) | MIT | TTF → EOT |
|
|
111
|
+
| [ttf2woff](https://github.com/fontello/ttf2woff) | MIT | TTF → WOFF |
|
|
112
|
+
| [wawoff2](https://github.com/fontello/wawoff2) | MIT | TTF ↔ WOFF2 compression |
|
|
113
|
+
| [xml2js](https://github.com/Leonidas-from-XIV/node-xml2js) | MIT | SVG XML parsing |
|
|
114
|
+
|
|
115
|
+
Transitive dependencies (and their licenses) are recorded in `package-lock.json`. For a full license report after install, you can run:
|
|
116
|
+
|
|
117
|
+
```shell
|
|
118
|
+
npx license-checker --production --direct
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
(Third-party tool; not maintained by this project.)
|
|
122
|
+
|
|
123
|
+
### BSD-licensed components
|
|
124
|
+
|
|
125
|
+
**fontverter** (BSD-3-Clause) and **nunjucks** (BSD-2-Clause) are subject to their own copyright notices and license terms. Redistributions of webfont that include source or substantial portions of those dependencies should preserve their respective notices as required by those licenses.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 6. Test fixtures and examples
|
|
130
|
+
|
|
131
|
+
Font and SVG files under `src/fixtures/` are intended **for automated tests and documentation examples** only. They are not a grant of rights to use those assets outside this repository. Do not assume fixture fonts or icons are redistributable for your own products.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 7. Keeping this document current
|
|
136
|
+
|
|
137
|
+
Update **NOTICE.md** in the same pull request when you:
|
|
138
|
+
|
|
139
|
+
- add or remove **runtime dependencies** that affect licensing or attribution;
|
|
140
|
+
- change **user-facing behavior** around font decompression or output formats in ways that affect legal expectations;
|
|
141
|
+
- publish new **community guidelines** for attribution or acceptable use.
|
|
142
|
+
|
|
143
|
+
See also [FEATURES.md](./FEATURES.md) (product capabilities) and [CONTRIBUTING.md](./CONTRIBUTING.md) (documentation expectations).
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 8. Questions and reports
|
|
148
|
+
|
|
149
|
+
- **Software bugs and features:** [GitHub Issues](https://github.com/itgalaxy/webfont/issues)
|
|
150
|
+
- **Code of conduct:** [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md)
|
|
151
|
+
- **License of the webfont source:** [LICENSE](./LICENSE)
|
|
152
|
+
|
|
153
|
+
For font licensing questions about **your** input files, contact the font foundry, vendor, or rights holder — maintainers cannot advise on third-party font EULAs.
|
package/README.md
CHANGED
|
@@ -4,25 +4,55 @@
|
|
|
4
4
|
[](https://travis-ci.org/itgalaxy/webfont)
|
|
5
5
|
[](https://ci.appveyor.com/project/evilebottnawi/webfont)
|
|
6
6
|
|
|
7
|
-
Generator of fonts from SVG icons.
|
|
7
|
+
Generator of fonts from SVG icons, with a separate mode to **decompress** WOFF/WOFF2 containers to the TTF or OTF inside.
|
|
8
|
+
|
|
9
|
+
See **[FEATURES.md](./FEATURES.md)** for the canonical capability list (what is stable, in progress, or planned).
|
|
10
|
+
|
|
11
|
+
**Legal / licensing:** [NOTICE.md](./NOTICE.md) — font copyright, disclaimers, attribution guidelines, and third-party library notices.
|
|
8
12
|
|
|
9
13
|
## Features
|
|
10
14
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
- Tested on all platforms (`linux`, `windows` and `osx`);
|
|
17
|
-
- CLI;
|
|
15
|
+
- **SVG icon pipeline** (default): `.svg` icons → `svg`, `ttf`, `eot`, `woff`, `woff2` (not `otf`);
|
|
16
|
+
- **Webfont decompression**: one `.woff` or `.woff2` file → `ttf` and/or `otf` matching the **embedded SFNT flavor** (decompress only — not TTF ↔ OTF transcoding);
|
|
17
|
+
- Config files: `JavaScript`, `JSON`, or `YAML` via [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig);
|
|
18
|
+
- Built-in and custom CSS templates (`css`, `scss`, [`styl`](https://github.com/itgalaxy/webfont/pull/164/));
|
|
19
|
+
- CLI and programmatic API;
|
|
18
20
|
- [Webpack plugin](https://github.com/itgalaxy/webfont-webpack-plugin).
|
|
19
21
|
|
|
22
|
+
## Input modes
|
|
23
|
+
|
|
24
|
+
webfont runs one of two pipelines depending on matched input files. They cannot be mixed in a single run.
|
|
25
|
+
|
|
26
|
+
| Mode | Input | Outputs | Notes |
|
|
27
|
+
|------|--------|---------|--------|
|
|
28
|
+
| **SVG icons** | One or more `.svg` files | `svg`, `ttf`, `eot`, `woff`, `woff2` | Default. Builds TrueType via `svg2ttf`. **`otf` is rejected** — use `ttf`. |
|
|
29
|
+
| **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. |
|
|
30
|
+
|
|
31
|
+
**Not supported today**
|
|
32
|
+
|
|
33
|
+
- Renaming or re-wrapping without matching the real outline format (e.g. requesting `otf` when the WOFF2 holds TrueType).
|
|
34
|
+
- Converting TTF to OTF (or OTF to TTF) — use [FontForge](https://fontforge.org/) or similar.
|
|
35
|
+
- Templates, `glyphTransformFn`, or merged multi-weight SFNT output in webfont decompress mode.
|
|
36
|
+
- Globs that match extension-less or unsupported files together with fonts (the run fails instead of silently ignoring extras).
|
|
37
|
+
|
|
38
|
+
Every matched path must end in `.svg`, `.woff`, or `.woff2`. See [FEATURES.md](./FEATURES.md) for test-backed criteria.
|
|
39
|
+
|
|
40
|
+
### Font licensing
|
|
41
|
+
|
|
42
|
+
webfont is a technical tool. **Decompressing or generating fonts does not grant you any rights to those fonts.** You must have permission to use, convert, and redistribute every input file and every output file under the applicable license (commercial fonts, app-bundled webfonts, client icons, etc.). The MIT license applies to **this software only**, not to fonts you pass through it.
|
|
43
|
+
|
|
44
|
+
Full details, disclaimers, community attribution guidelines, and third-party library notices: **[NOTICE.md](./NOTICE.md)**.
|
|
45
|
+
|
|
20
46
|
## Table Of Contents
|
|
21
47
|
|
|
22
48
|
- [Webfont](#webfont)
|
|
49
|
+
- [Features](#features)
|
|
50
|
+
- [Input modes](#input-modes)
|
|
51
|
+
- [Font licensing](#font-licensing)
|
|
23
52
|
- [Installation](#installation)
|
|
24
53
|
- [Usage](#usage)
|
|
25
54
|
- [Options](#options)
|
|
55
|
+
- [Result](#result)
|
|
26
56
|
- [svgicons2svgfont](#svgicons2svgfont)
|
|
27
57
|
- [Command Line Interface (CLI)](#command-line-interface)
|
|
28
58
|
- [Installation](#cli-installation)
|
|
@@ -32,6 +62,7 @@ Generator of fonts from SVG icons.
|
|
|
32
62
|
- [Roadmap](#roadmap)
|
|
33
63
|
- [Contribution](#contribution)
|
|
34
64
|
- [Changelog](#changelog)
|
|
65
|
+
- [Legal notice](#legal-notice)
|
|
35
66
|
- [License](#license)
|
|
36
67
|
|
|
37
68
|
---
|
|
@@ -82,13 +113,42 @@ webfont({
|
|
|
82
113
|
});
|
|
83
114
|
```
|
|
84
115
|
|
|
116
|
+
### Webfont decompress examples
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
import webfont from "webfont";
|
|
120
|
+
|
|
121
|
+
// Single local file
|
|
122
|
+
const one = await webfont({
|
|
123
|
+
files: "path/to/font.woff2",
|
|
124
|
+
formats: ["ttf"],
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Batch: multiple files in one run (one TTF/OTF output per input)
|
|
128
|
+
const batch = await webfont({
|
|
129
|
+
files: ["fonts/Inter-Regular.woff2", "fonts/Inter-Bold.woff2"],
|
|
130
|
+
formats: ["ttf"],
|
|
131
|
+
});
|
|
132
|
+
// batch.decompressedFonts → [{ source, ttf }, …]
|
|
133
|
+
|
|
134
|
+
// Remote URL (http or https)
|
|
135
|
+
const remote = await webfont({
|
|
136
|
+
files: "https://cdn.example.com/fonts/Inter-Medium.woff2",
|
|
137
|
+
formats: ["ttf"],
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
85
141
|
### Options
|
|
86
142
|
|
|
87
143
|
#### `files`
|
|
88
144
|
|
|
89
145
|
- Type: `string` | `array`
|
|
90
146
|
- Description: A file glob, or array of file globs. Ultimately passed to [fast-glob](https://github.com/mrmlnc/fast-glob) to figure out what files you want to get.
|
|
91
|
-
-
|
|
147
|
+
- **SVG mode**: one or more `.svg` icon paths or globs (default pipeline).
|
|
148
|
+
- **Webfont decompress mode**: one or more `.woff` / `.woff2` paths, globs, or `https://…` URLs (see [`formats`](#formats) and [Input modes](#input-modes)).
|
|
149
|
+
- Do not mix `.svg` with `.woff` / `.woff2` in the same run.
|
|
150
|
+
- Every matched file must have a supported extension (`.svg`, `.woff`, `.woff2`); extension-less files such as `LICENSE` are not ignored when matched by a broad glob.
|
|
151
|
+
- `node_modules` and `bower_components` are always ignored.
|
|
92
152
|
|
|
93
153
|
#### `configFile`
|
|
94
154
|
|
|
@@ -99,6 +159,7 @@ webfont({
|
|
|
99
159
|
2. a `.webfontrc` file (with or without filename extension: `.json`, `.yaml`, and `.js` are available)
|
|
100
160
|
3. a `webfont.config.js` file exporting a JS `object`.
|
|
101
161
|
The search will begin in the working directory and move up the directory tree until it finds a configuration file.
|
|
162
|
+
- Note: When a configuration file is discovered or loaded, the resolved absolute path is available on `result.config.filePath` (see [Result](#result)).
|
|
102
163
|
|
|
103
164
|
#### `fontName`
|
|
104
165
|
|
|
@@ -108,10 +169,13 @@ webfont({
|
|
|
108
169
|
|
|
109
170
|
#### `formats`
|
|
110
171
|
|
|
111
|
-
- Type: `array
|
|
112
|
-
- Default: `['svg', 'ttf', 'eot', 'woff', 'woff2']
|
|
113
|
-
- Possible values: `svg
|
|
172
|
+
- Type: `array`
|
|
173
|
+
- Default: `['svg', 'ttf', 'eot', 'woff', 'woff2']` (SVG input). For WOFF/WOFF2 input, defaults to `['ttf']` when SVG-pipeline formats are still configured.
|
|
174
|
+
- Possible values: `svg`, `ttf`, `otf`, `eot`, `woff`, `woff2`
|
|
114
175
|
- Description: Font file types to generate.
|
|
176
|
+
- **SVG input**: `svg`, `ttf`, `eot`, `woff`, `woff2` only. **`otf` is not supported** (pipeline uses TrueType outlines).
|
|
177
|
+
- **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.
|
|
178
|
+
- 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.
|
|
115
179
|
|
|
116
180
|
#### `template`
|
|
117
181
|
|
|
@@ -160,6 +224,12 @@ webfont({
|
|
|
160
224
|
- Default: Gets is from `fontName` if not set, but you can specify any value.
|
|
161
225
|
- Description: Template font family name you want.
|
|
162
226
|
|
|
227
|
+
#### `ligatures`
|
|
228
|
+
|
|
229
|
+
- Type: `boolean`
|
|
230
|
+
- Default: `true`
|
|
231
|
+
- Description: Turn on/off adding ligature unicode
|
|
232
|
+
|
|
163
233
|
#### `glyphTransformFn`
|
|
164
234
|
|
|
165
235
|
- Type: `function`
|
|
@@ -190,12 +260,50 @@ webfont({
|
|
|
190
260
|
});
|
|
191
261
|
```
|
|
192
262
|
|
|
263
|
+
#### `metadataProvider`
|
|
264
|
+
|
|
265
|
+
- Type: `function`
|
|
266
|
+
- Default: built-in metadata service (reads icon names and unicode from SVG files)
|
|
267
|
+
- Description: Custom callback to resolve glyph metadata for each source file. Receives the file path and a Node-style callback `(error, metadata)` where `metadata` is `{ name: string, unicode?: string | string[] }`. When omitted, webfont uses its default metadata reader.
|
|
268
|
+
|
|
269
|
+
```js
|
|
270
|
+
import webfont from "webfont";
|
|
271
|
+
|
|
272
|
+
webfont({
|
|
273
|
+
files: "src/svg-icons/**/*.svg",
|
|
274
|
+
metadataProvider: (srcPath, callback) => {
|
|
275
|
+
callback(null, { name: "custom-icon-name" });
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
```
|
|
279
|
+
|
|
193
280
|
#### `sort`
|
|
194
281
|
|
|
195
282
|
- Type: `bool`
|
|
196
283
|
- Default: `true`
|
|
197
284
|
- Description: Whether you want to sort the icons sorted by name.
|
|
198
285
|
|
|
286
|
+
### Result
|
|
287
|
+
|
|
288
|
+
`webfont()` resolves to an object with generated font buffers (and optional `template` output). The `config` property contains the **effective options** used for the run (defaults, discovered config, and any options you passed in), plus optional **output metadata** when a configuration file was found or loaded.
|
|
289
|
+
|
|
290
|
+
#### `result.config.filePath`
|
|
291
|
+
|
|
292
|
+
- Type: `string` | `undefined`
|
|
293
|
+
- Description: Absolute path to the configuration file that was discovered (`search`) or loaded (`configFile` / CLI `--config`). Omitted when no configuration file was found and defaults were used.
|
|
294
|
+
- Note: Output-only metadata — not an input option. Do not set `filePath` in `.webfontrc`, `package.json`, or the `webfont()` call; values passed that way are ignored.
|
|
295
|
+
- Example:
|
|
296
|
+
|
|
297
|
+
```js
|
|
298
|
+
const result = await webfont({
|
|
299
|
+
files: "src/svg-icons/**/*.svg",
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
if (result.config?.filePath) {
|
|
303
|
+
console.log(`Loaded config from ${result.config.filePath}`);
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
199
307
|
---
|
|
200
308
|
|
|
201
309
|
## svgicons2svgfont
|
|
@@ -277,12 +385,6 @@ These can be appended to [webfont options](#options). These are passed directly
|
|
|
277
385
|
- Description: The font [metadata](http://www.w3.org/TR/SVG/metadata.html).
|
|
278
386
|
You can set any character data in, but this is the recommended place for a copyright mention.
|
|
279
387
|
|
|
280
|
-
#### `svgicons2svgfont.log`
|
|
281
|
-
|
|
282
|
-
- Type: `function`
|
|
283
|
-
- Default: `console.log`
|
|
284
|
-
- Description: Allows you to provide your own logging function. Set to `function(){}` to disable logging.
|
|
285
|
-
|
|
286
388
|
---
|
|
287
389
|
|
|
288
390
|
## Command Line Interface
|
|
@@ -296,7 +398,7 @@ Add the `cli` script to your `package.json` file's `scripts` object:
|
|
|
296
398
|
```json
|
|
297
399
|
{
|
|
298
400
|
"scripts": {
|
|
299
|
-
"webfont": "node node_modules/webfont/dist/cli.
|
|
401
|
+
"webfont": "node node_modules/webfont/dist/cli.mjs"
|
|
300
402
|
}
|
|
301
403
|
}
|
|
302
404
|
```
|
|
@@ -306,7 +408,7 @@ If you're using cross-env:
|
|
|
306
408
|
```json
|
|
307
409
|
{
|
|
308
410
|
"scripts": {
|
|
309
|
-
"webfont": "cross-env node_modules/webfont/dist/cli.
|
|
411
|
+
"webfont": "cross-env node_modules/webfont/dist/cli.mjs"
|
|
310
412
|
}
|
|
311
413
|
}
|
|
312
414
|
```
|
|
@@ -336,7 +438,7 @@ If you're using cross-env:
|
|
|
336
438
|
The search will begin in the working directory and move up the
|
|
337
439
|
directory tree until a configuration file is found.
|
|
338
440
|
|
|
339
|
-
-
|
|
441
|
+
-u, --fontName
|
|
340
442
|
|
|
341
443
|
The font family name you want, default: "webfont".
|
|
342
444
|
|
|
@@ -348,9 +450,12 @@ If you're using cross-env:
|
|
|
348
450
|
|
|
349
451
|
Output the version number.
|
|
350
452
|
|
|
351
|
-
-
|
|
453
|
+
-f, --formats
|
|
352
454
|
|
|
353
|
-
|
|
455
|
+
Font formats to generate. Pass a JSON array (e.g. '["woff2"]') or a
|
|
456
|
+
comma-separated list (e.g. woff2 or svg, ttf, woff2).
|
|
457
|
+
SVG input: svg, ttf, eot, woff, woff2 (not otf).
|
|
458
|
+
WOFF/WOFF2 input: ttf and/or otf matching the embedded SFNT flavor.
|
|
354
459
|
|
|
355
460
|
-d, --dest
|
|
356
461
|
|
|
@@ -468,10 +573,8 @@ The CLI can exit the process with the following exit codes:
|
|
|
468
573
|
|
|
469
574
|
## Roadmap
|
|
470
575
|
|
|
471
|
-
-
|
|
472
|
-
-
|
|
473
|
-
- Improved docs;
|
|
474
|
-
- Reduce package size (maybe implement `ttf2woff2` with native js library);
|
|
576
|
+
- Arbitrary format transcoding (e.g. TTF ↔ OTF outline conversion) — see [FEATURES.md](./FEATURES.md) (“Arbitrary format transcoding”, planned);
|
|
577
|
+
- Reduce package size (maybe implement `ttf2woff2` with a native JS library);
|
|
475
578
|
- Improve performance (maybe use cache for this).
|
|
476
579
|
|
|
477
580
|
## Contribution
|
|
@@ -482,6 +585,10 @@ Feel free to push your code if you agree with publishing under the MIT license.
|
|
|
482
585
|
|
|
483
586
|
Check our [Changelog](CHANGELOG.md)
|
|
484
587
|
|
|
588
|
+
## Legal notice
|
|
589
|
+
|
|
590
|
+
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)**.
|
|
591
|
+
|
|
485
592
|
## License
|
|
486
593
|
|
|
487
|
-
|
|
594
|
+
The **webfont software** is licensed under the [MIT License](./LICENSE). That license does **not** apply to fonts or icons you process with the tool — see [NOTICE.md](./NOTICE.md).
|