webfont 12.1.0 → 12.1.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/README.md +30 -12
- package/dist/cli.mjs +859 -769
- package/dist/index.js +1 -1
- package/dist/index.mjs +513 -0
- package/dist/{parseTemplateOption-5T7rSw5J.mjs → parseTemplateOption-Bvbie1SQ.mjs} +0 -1
- package/dist/parseTemplateOption-DLNu6PPx.mjs +38 -0
- package/dist/{renderTemplates-DvRlS58E.mjs → renderTemplates-Biyrk6t-.mjs} +16 -17
- package/dist/renderTemplates-CXVKq3Op.mjs +102 -0
- package/dist/src/browser.d.mts +2 -0
- package/dist/src/index.d.mts +5 -0
- package/dist/src/lib/applyOptimizeSvgToGlyphs.d.mts +3 -0
- package/dist/src/lib/evenoddFillRule.d.mts +2 -0
- package/dist/src/lib/execCLI/index.d.mts +24 -0
- package/dist/src/lib/inputSource.d.mts +2 -0
- package/dist/src/lib/inputSourceUtils.d.mts +4 -0
- package/dist/src/lib/largeFontLigatures.d.mts +4 -0
- package/dist/src/lib/optimizeSvgGlyphs.d.mts +4 -0
- package/dist/src/lib/p-limit/index.d.mts +2 -0
- package/dist/src/lib/parseFormats.d.mts +4 -0
- package/dist/src/lib/parseTemplateOption.d.mts +2 -0
- package/dist/src/lib/runtimeEnvironment.d.mts +4 -0
- package/dist/src/lib/sfnt/flavor.d.mts +2 -0
- package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.mts +13 -0
- package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.ts +1 -0
- package/dist/src/lib/svgFontOutput/emptyGlyphPaths.d.mts +3 -0
- package/dist/src/lib/svgTools/applySvgDiagnostics.d.mts +13 -0
- package/dist/src/lib/svgTools/applySvgTools.d.mts +14 -0
- package/dist/src/lib/svgTools/normalizeSvgToolsOptions.d.mts +2 -0
- package/dist/src/lib/svgicons2svgfont/index.d.mts +14 -0
- package/dist/src/lib/svgicons2svgfont/metadataFromSrcPath.d.mts +11 -0
- package/dist/src/lib/templateUnicodeRange.d.mts +4 -0
- package/dist/src/lib/ttf2eot/index.d.mts +2 -0
- package/dist/src/lib/ttfEncode.d.mts +5 -0
- package/dist/src/standalone/convertTtfInput.d.mts +3 -0
- package/dist/src/standalone/convertWebfontInput.d.mts +3 -0
- package/dist/src/standalone/defaultOptions.d.mts +3 -0
- package/dist/src/standalone/fetchWebfontUrl.d.mts +1 -0
- package/dist/src/standalone/generateSvgFont.d.mts +2 -0
- package/dist/src/standalone/getGlyphsDataFromInputs.d.mts +3 -0
- package/dist/src/standalone/glyphsData.d.mts +4 -0
- package/dist/src/standalone/index.d.mts +10 -0
- package/dist/src/standalone/inputMode.d.mts +9 -0
- package/dist/src/standalone/options.d.mts +5 -0
- package/dist/src/standalone/optionsFromGlyphs.d.mts +3 -0
- package/dist/src/standalone/renderTemplates.d.mts +10 -0
- package/dist/src/standalone/runSvgPipeline.d.mts +3 -0
- package/dist/src/standalone/templateFonts.d.mts +3 -0
- package/dist/src/standalone/toTtf.d.mts +4 -0
- package/dist/src/standalone/validateWebfontOptions.d.mts +6 -0
- package/dist/src/standalone/webfontFromGlyphs.d.mts +3 -0
- package/dist/src/types/DecompressedFont.d.mts +5 -0
- package/dist/src/types/Format.d.mts +9 -0
- package/dist/src/types/GlyphContentTransformFn.d.mts +2 -0
- package/dist/src/types/GlyphData.d.mts +6 -0
- package/dist/src/types/GlyphInput.d.mts +6 -0
- package/dist/src/types/GlyphMetadata.d.mts +10 -0
- package/dist/src/types/GlyphTransformFn.d.mts +2 -0
- package/dist/src/types/InitialOptions.d.mts +10 -0
- package/dist/src/types/MetadataProvider.d.mts +5 -0
- package/dist/src/types/OptionsBase.d.mts +39 -0
- package/dist/src/types/RenderedTemplate.d.mts +7 -0
- package/dist/src/types/Result.d.mts +26 -0
- package/dist/src/types/ResultConfig.d.mts +4 -0
- package/dist/src/types/SvgToolsOptions.d.mts +13 -0
- package/dist/src/types/SvgToolsOptions.d.ts +1 -1
- package/dist/src/types/TranscodedFont.d.mts +7 -0
- package/dist/src/types/WebfontFromGlyphsOptions.d.mts +11 -0
- package/dist/src/types/WebfontOptions.d.mts +43 -0
- package/dist/src/types/index.d.mts +8 -0
- package/dist/templates/index.d.mts +19 -0
- package/package.json +32 -14
package/README.md
CHANGED
|
@@ -75,7 +75,7 @@ Full details, disclaimers, community attribution guidelines, and third-party lib
|
|
|
75
75
|
|
|
76
76
|
## Installation
|
|
77
77
|
|
|
78
|
-
Requires **Node.js** >= 24.14.0. Install as a dev dependency and run at **build time** (CLI, npm script, or bundler plugin) — not from browser/React client bundles.
|
|
78
|
+
Requires **Node.js** >= 24.14.0 (aligned with `svgicons2svgfont@16`). CI tests on Node 24.x and 26.x. Install as a dev dependency and run at **build time** (CLI, npm script, or bundler plugin) — not from browser/React client bundles.
|
|
79
79
|
|
|
80
80
|
```shell
|
|
81
81
|
npm install --save-dev webfont
|
|
@@ -85,8 +85,26 @@ npm install --save-dev webfont
|
|
|
85
85
|
|
|
86
86
|
Node.js only — do not import from client-side app code ([#198](https://github.com/itgalaxy/webfont/issues/198)).
|
|
87
87
|
|
|
88
|
+
### Import (ESM and CommonJS)
|
|
89
|
+
|
|
90
|
+
Use the **named export** — required for native ESM and recommended since webfont **10+**:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import { webfont } from "webfont";
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
CommonJS:
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
const { webfont } = require("webfont");
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`import webfont from "webfont"` is callable in versions that ship the ESM build (**12.x+**), where the default export is the `webfont` function itself ([#618](https://github.com/itgalaxy/webfont/issues/618)). On older releases the default import resolved to the whole `module.exports` object and threw `TypeError: webfont is not a function` under `"type": "module"`. The named import remains the recommended form for new code. See the [migration notes](./docs/migration/issue-0618-esm-default-import.md).
|
|
103
|
+
|
|
104
|
+
### Basic example
|
|
105
|
+
|
|
88
106
|
```js
|
|
89
|
-
import webfont from "webfont";
|
|
107
|
+
import { webfont } from "webfont";
|
|
90
108
|
|
|
91
109
|
webfont({
|
|
92
110
|
files: "src/svg-icons/**/*.svg",
|
|
@@ -106,7 +124,7 @@ webfont({
|
|
|
106
124
|
or
|
|
107
125
|
|
|
108
126
|
```js
|
|
109
|
-
const webfont = require("webfont")
|
|
127
|
+
const { webfont } = require("webfont");
|
|
110
128
|
|
|
111
129
|
webfont({
|
|
112
130
|
files: "src/svg-icons/**/*.svg",
|
|
@@ -126,7 +144,7 @@ webfont({
|
|
|
126
144
|
### TTF encoding examples
|
|
127
145
|
|
|
128
146
|
```js
|
|
129
|
-
import webfont from "webfont";
|
|
147
|
+
import { webfont } from "webfont";
|
|
130
148
|
|
|
131
149
|
// Single local TTF → WOFF + WOFF2 (default when formats unset)
|
|
132
150
|
const encoded = await webfont({
|
|
@@ -150,7 +168,7 @@ const batch = await webfont({
|
|
|
150
168
|
### Webfont decompress examples
|
|
151
169
|
|
|
152
170
|
```js
|
|
153
|
-
import webfont from "webfont";
|
|
171
|
+
import { webfont } from "webfont";
|
|
154
172
|
|
|
155
173
|
// Single local file
|
|
156
174
|
const one = await webfont({
|
|
@@ -284,7 +302,7 @@ webfont "icons/*.svg" -d dist/icons -t scss --addHashInFontUrl
|
|
|
284
302
|
```
|
|
285
303
|
|
|
286
304
|
```js
|
|
287
|
-
import webfont from "webfont";
|
|
305
|
+
import { webfont } from "webfont";
|
|
288
306
|
|
|
289
307
|
await webfont({
|
|
290
308
|
files: "src/icons/**/*.svg",
|
|
@@ -332,7 +350,7 @@ Do **not** use `Math.random()` in `fontName` — that renames both font files an
|
|
|
332
350
|
- Example:
|
|
333
351
|
|
|
334
352
|
```js
|
|
335
|
-
import webfont from "webfont";
|
|
353
|
+
import { webfont } from "webfont";
|
|
336
354
|
|
|
337
355
|
webfont({
|
|
338
356
|
files: "src/svg-icons/**/*.svg",
|
|
@@ -363,7 +381,7 @@ Do **not** use `Math.random()` in `fontName` — that renames both font files an
|
|
|
363
381
|
|
|
364
382
|
```js
|
|
365
383
|
import outlineStroke from "svg-outline-stroke";
|
|
366
|
-
import webfont from "webfont";
|
|
384
|
+
import { webfont } from "webfont";
|
|
367
385
|
|
|
368
386
|
await webfont({
|
|
369
387
|
files: "src/svg-icons/**/*.svg",
|
|
@@ -382,7 +400,7 @@ Do **not** use `Math.random()` in `fontName` — that renames both font files an
|
|
|
382
400
|
- Optional: `svgoConfig` — SVGO `Config` object; when `plugins` is set, it replaces the built-in conservative plugin list.
|
|
383
401
|
|
|
384
402
|
```js
|
|
385
|
-
import webfont from "webfont";
|
|
403
|
+
import { webfont } from "webfont";
|
|
386
404
|
|
|
387
405
|
await webfont({
|
|
388
406
|
files: "src/icons/**/*.svg",
|
|
@@ -399,13 +417,13 @@ Do **not** use `Math.random()` in `fontName` — that renames both font files an
|
|
|
399
417
|
- Type: `{ diagnose?: boolean; onMessage?: (message: string) => void }`
|
|
400
418
|
- Default: `undefined` (disabled)
|
|
401
419
|
- Description: **Alpha.** Scan SVG sources for icon-font incompatibilities before font generation (SVG pipeline only). Does **not** modify SVGs — use [`glyphContentTransformFn`](#glyphcontenttransformfn) to preprocess (for example stroke-to-fill with [`svg-outline-stroke`](https://github.com/elrumordelaluz/outline-stroke), installed in your project). See [ADR 0011](docs/adr/0011-no-svg-outline-stroke-dependency.md).
|
|
402
|
-
- **`diagnose`:** log warnings for `fill-rule: evenodd`, stroke-only paths (`fill="none"` + `stroke`), and poorly supported elements (`<line>`, `<polyline>`, `<clipPath>`). Results are also returned on `result.svgDiagnostics` when enabled.
|
|
420
|
+
- **`diagnose`:** log warnings for `fill-rule: evenodd`, stroke-only paths (`fill="none"` + `stroke`), `<use>` symbol references ([#612](https://github.com/itgalaxy/webfont/issues/612)), and poorly supported elements (`<line>`, `<polyline>`, `<clipPath>`). Results are also returned on `result.svgDiagnostics` when enabled.
|
|
403
421
|
- **`onMessage`:** optional sink for diagnostic log lines (tests, custom UIs).
|
|
404
422
|
- CLI: `--svg-diagnose` (alpha).
|
|
405
423
|
- Example:
|
|
406
424
|
|
|
407
425
|
```js
|
|
408
|
-
import webfont from "webfont";
|
|
426
|
+
import { webfont } from "webfont";
|
|
409
427
|
|
|
410
428
|
const result = await webfont({
|
|
411
429
|
files: "src/icons/**/*.svg",
|
|
@@ -424,7 +442,7 @@ Do **not** use `Math.random()` in `fontName` — that renames both font files an
|
|
|
424
442
|
- 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.
|
|
425
443
|
|
|
426
444
|
```js
|
|
427
|
-
import webfont from "webfont";
|
|
445
|
+
import { webfont } from "webfont";
|
|
428
446
|
|
|
429
447
|
webfont({
|
|
430
448
|
files: "src/svg-icons/**/*.svg",
|