webfont 11.2.26 → 12.1.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.
Files changed (80) hide show
  1. package/NOTICE.md +165 -0
  2. package/README.md +302 -34
  3. package/dist/browser.js +4 -0
  4. package/dist/cli.mjs +893 -0
  5. package/dist/index.js +1 -507
  6. package/dist/parseTemplateOption-5T7rSw5J.mjs +20 -0
  7. package/dist/parseTemplateOption-BmH_pcQh.js +1 -0
  8. package/dist/renderTemplates-DvRlS58E.mjs +93 -0
  9. package/dist/renderTemplates-zCYCzeOt.js +1 -0
  10. package/dist/src/browser.d.ts +2 -0
  11. package/dist/src/index.d.ts +4 -2
  12. package/dist/src/lib/applyOptimizeSvgToGlyphs.d.ts +3 -0
  13. package/dist/src/lib/evenoddFillRule.d.ts +2 -0
  14. package/dist/src/lib/execCLI/index.d.ts +3 -4
  15. package/dist/src/lib/inputSource.d.ts +2 -0
  16. package/dist/src/lib/inputSourceUtils.d.ts +4 -0
  17. package/dist/src/lib/largeFontLigatures.d.ts +4 -0
  18. package/dist/src/lib/optimizeSvgGlyphs.d.ts +4 -0
  19. package/dist/src/lib/p-limit/index.d.ts +2 -0
  20. package/dist/src/lib/parseFormats.d.ts +4 -0
  21. package/dist/src/lib/parseTemplateOption.d.ts +2 -0
  22. package/dist/src/lib/runtimeEnvironment.d.ts +4 -0
  23. package/dist/src/lib/sfnt/flavor.d.ts +2 -0
  24. package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.ts +12 -0
  25. package/dist/src/lib/svgFontOutput/emptyGlyphPaths.d.ts +3 -0
  26. package/dist/src/lib/svgTools/applySvgDiagnostics.d.ts +13 -0
  27. package/dist/src/lib/svgTools/applySvgTools.d.ts +14 -0
  28. package/dist/src/lib/svgTools/normalizeSvgToolsOptions.d.ts +2 -0
  29. package/dist/src/lib/svgicons2svgfont/index.d.ts +14 -0
  30. package/dist/src/lib/svgicons2svgfont/metadataFromSrcPath.d.ts +11 -0
  31. package/dist/src/lib/templateUnicodeRange.d.ts +4 -0
  32. package/dist/src/lib/ttf2eot/index.d.ts +2 -0
  33. package/dist/src/lib/ttfEncode.d.ts +5 -0
  34. package/dist/src/standalone/convertTtfInput.d.ts +3 -0
  35. package/dist/src/standalone/convertWebfontInput.d.ts +3 -0
  36. package/dist/src/standalone/defaultOptions.d.ts +3 -0
  37. package/dist/src/standalone/fetchWebfontUrl.d.ts +1 -0
  38. package/dist/src/standalone/generateSvgFont.d.ts +2 -0
  39. package/dist/src/standalone/getGlyphsDataFromInputs.d.ts +3 -0
  40. package/dist/src/standalone/glyphsData.d.ts +2 -2
  41. package/dist/src/standalone/index.d.ts +8 -3
  42. package/dist/src/standalone/inputMode.d.ts +9 -0
  43. package/dist/src/standalone/options.d.ts +3 -3
  44. package/dist/src/standalone/optionsFromGlyphs.d.ts +3 -0
  45. package/dist/src/standalone/renderTemplates.d.ts +10 -0
  46. package/dist/src/standalone/runSvgPipeline.d.ts +3 -0
  47. package/dist/src/standalone/templateFonts.d.ts +3 -0
  48. package/dist/src/standalone/toTtf.d.ts +4 -0
  49. package/dist/src/standalone/validateWebfontOptions.d.ts +6 -0
  50. package/dist/src/standalone/webfontFromGlyphs.d.ts +3 -0
  51. package/dist/src/types/DecompressedFont.d.ts +5 -0
  52. package/dist/src/types/Format.d.ts +4 -4
  53. package/dist/src/types/GlyphContentTransformFn.d.ts +2 -0
  54. package/dist/src/types/GlyphData.d.ts +2 -2
  55. package/dist/src/types/GlyphInput.d.ts +6 -0
  56. package/dist/src/types/GlyphMetadata.d.ts +1 -1
  57. package/dist/src/types/GlyphTransformFn.d.ts +2 -2
  58. package/dist/src/types/InitialOptions.d.ts +7 -4
  59. package/dist/src/types/MetadataProvider.d.ts +5 -0
  60. package/dist/src/types/OptionsBase.d.ts +12 -3
  61. package/dist/src/types/RenderedTemplate.d.ts +7 -0
  62. package/dist/src/types/Result.d.ts +16 -5
  63. package/dist/src/types/ResultConfig.d.ts +4 -0
  64. package/dist/src/types/SvgToolsOptions.d.ts +13 -0
  65. package/dist/src/types/TranscodedFont.d.ts +7 -0
  66. package/dist/src/types/WebfontFromGlyphsOptions.d.ts +11 -0
  67. package/dist/src/types/WebfontOptions.d.ts +39 -3
  68. package/dist/src/types/index.d.ts +8 -6
  69. package/package.json +65 -57
  70. package/templates/template.css.njk +6 -3
  71. package/templates/template.html.njk +15 -4
  72. package/templates/template.scss.njk +6 -3
  73. package/templates/template.styl.njk +6 -3
  74. package/dist/cli.js +0 -801
  75. package/dist/jest.config.d.ts +0 -3
  76. package/dist/src/cli/index.d.ts +0 -1
  77. package/dist/src/cli/index.test.d.ts +0 -1
  78. package/dist/src/cli/meow/index.d.ts +0 -104
  79. package/dist/src/index.test.d.ts +0 -1
  80. package/dist/src/standalone/index.test.d.ts +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "webfont",
3
- "version": "11.2.26",
4
- "description": "Generator of fonts from svg icons, svg icons to svg font, svg font to ttf, ttf to eot, ttf to woff, ttf to woff2",
3
+ "version": "12.1.0",
4
+ "description": "Generator of fonts from SVG icons; decompress WOFF/WOFF2 to embedded TTF/OTF (not TTF↔OTF transcoding)",
5
5
  "directories": {
6
6
  "lib": "dist",
7
7
  "source": "src"
@@ -12,83 +12,91 @@
12
12
  "templates",
13
13
  "!**/__tests__",
14
14
  "!**/__mocks__",
15
- "README.md"
15
+ "README.md",
16
+ "NOTICE.md"
16
17
  ],
17
18
  "main": "dist/index.js",
18
- "bin": "dist/cli.js",
19
+ "browser": "dist/browser.js",
20
+ "bin": "dist/cli.mjs",
19
21
  "source": "src/index.ts",
20
22
  "types": "dist/src/index.d.ts",
21
23
  "typings": "dist/src/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "node": {
27
+ "import": "./dist/index.js",
28
+ "require": "./dist/index.js"
29
+ },
30
+ "default": "./dist/browser.js"
31
+ },
32
+ "./package.json": "./package.json"
33
+ },
22
34
  "scripts": {
23
- "build": "rollup -c",
35
+ "build": "vite build --mode library && vite build --mode browser && vite build --mode cli",
24
36
  "clean": "rm -rf dist/ temp/",
25
- "demo": "node dist/cli.js './src/fixtures/svg-icons/*.svg' -d demo -t html --normalize --center-horizontally",
26
- "lint": "eslint .",
27
- "postbuild": "tsc --declaration --declarationDir dist --emitDeclarationOnly",
37
+ "demo": "node dist/cli.mjs './src/fixtures/svg-icons/*.svg' -d demo -t html --normalize --center-horizontally",
38
+ "lint": "biome check .",
39
+ "depcheck": "knip",
28
40
  "prebuild": "npm run clean && npm run lint",
41
+ "prepare": "lefthook install",
29
42
  "predemo": "npm run build",
30
43
  "prepublishOnly": "npm run build",
31
- "prerelease": "npm run test",
32
44
  "pretest": "npm run build",
33
- "prettify": "npm run lint --fix",
34
- "preversion": "npm run test",
35
- "push-tags": "git push origin --tags",
36
- "release": "standard-version",
37
- "release-alpha": "npm run release -- --prerelease alpha",
38
- "test": "jest src",
39
- "testc": "npm test -- --coverage",
40
- "test-debug": "npm test --detectOpenHandles --runInBand",
41
- "testu": "npm test -- -u"
45
+ "prettify": "biome check --write .",
46
+ "test": "vitest run src",
47
+ "testc": "vitest run src --coverage",
48
+ "test-debug": "vitest run src --no-file-parallelism",
49
+ "testu": "vitest run src -u",
50
+ "deprecate-pre-12": "npm deprecate 'webfont@>=10.0.0 <12.0.0' 'Deprecated: upgrade to webfont@12. v10–11 enabled ligatures by default (browser hangs on large fonts, #558). 12.x: ligatures off, Node 12+, named import, unicode-range off, template fixes. See MIGRATION.md'"
42
51
  },
43
52
  "dependencies": {
44
- "cosmiconfig": "^5.2.0",
53
+ "cosmiconfig": "9.0.2",
45
54
  "deepmerge": "^4.2.2",
46
- "globby": "^11.0.0",
47
- "meow": "^9.0.0",
48
- "nunjucks": "^3.2.3",
49
- "p-limit": "^3.1.0",
50
- "parse-json": "^5.2.0",
55
+ "fontverter": "2.0.0",
56
+ "globby": "16.2.0",
57
+ "meow": "14.1.0",
58
+ "nunjucks": "3.2.4",
59
+ "p-limit": "7.3.0",
51
60
  "resolve-from": "^5.0.0",
52
- "svg2ttf": "^6.0.2",
53
- "svgicons2svgfont": "^10.0.3",
54
- "ttf2eot": "^2.0.0",
55
- "ttf2woff": "^2.0.2",
56
- "wawoff2": "^2.0.0",
57
- "xml2js": "^0.4.23"
61
+ "svg2ttf": "^6.1.0",
62
+ "svgicons2svgfont": "^16.0.0",
63
+ "svgo": "4.0.1",
64
+ "ttf2eot": "3.1.0",
65
+ "ttf2woff": "^3.0.0",
66
+ "wawoff2": "2.0.0",
67
+ "xml2js": "0.6.2"
58
68
  },
59
69
  "devDependencies": {
60
- "@babel/eslint-plugin": "latest",
61
- "@babel/preset-env": "latest",
62
- "@babel/preset-typescript": "latest",
63
- "@rollup/plugin-commonjs": "latest",
64
- "@rollup/plugin-typescript": "latest",
65
- "@types/jest": "26.0.24",
66
- "@types/node": "15.14.5",
67
- "@types/nunjucks": "latest",
70
+ "@biomejs/biome": "2.5.2",
71
+ "@types/node": "^22.15.0",
72
+ "@types/nunjucks": "3.2.6",
68
73
  "@types/rimraf": "latest",
69
- "@typescript-eslint/eslint-plugin": "latest",
70
- "@typescript-eslint/parser": "latest",
71
- "babel-jest": "27.0.6",
72
- "eslint": "latest",
73
- "eslint-plugin-import": "latest",
74
- "eslint-plugin-jest": "latest",
75
- "eslint-plugin-node": "latest",
76
- "eslint-plugin-promise": "latest",
77
- "eslint-plugin-unicorn": "latest",
78
- "husky": "latest",
74
+ "@types/svg2ttf": "5.0.3",
75
+ "@types/ttf2eot": "2.0.2",
76
+ "@types/ttf2woff": "2.0.4",
77
+ "@types/wawoff2": "1.0.2",
78
+ "@types/xml2js": "0.4.14",
79
+ "@vitest/coverage-v8": "4.1.9",
80
+ "fast-glob": "3.2.12",
79
81
  "is-eot": "latest",
80
- "is-svg": "latest",
82
+ "is-svg": "6.1.0",
81
83
  "is-ttf": "latest",
82
84
  "is-woff": "latest",
83
85
  "is-woff2": "latest",
84
- "jest": "27.0.6",
85
- "lint-staged": "11.1.1",
86
+ "knip": "6.24.0",
87
+ "lefthook": "2.1.9",
86
88
  "rimraf": "latest",
87
- "rollup": "2.55.1",
88
- "standard-version": "latest",
89
- "ts-node": "latest",
90
- "tslib": "latest",
91
- "typescript": "latest"
89
+ "typescript": "6.0.3",
90
+ "vite": "8.1.3",
91
+ "vite-plugin-checker": "0.14.4",
92
+ "vite-plugin-dts": "5.0.3",
93
+ "vitest": "4.1.9"
94
+ },
95
+ "overrides": {
96
+ "fast-glob": "3.2.12",
97
+ "minimatch": "10.2.5",
98
+ "test-exclude": "7.0.2",
99
+ "woff2sfnt-sfnt2woff": "1.0.0"
92
100
  },
93
101
  "repository": {
94
102
  "type": "git",
@@ -113,7 +121,7 @@
113
121
  },
114
122
  "homepage": "https://github.com/itgalaxy/webfont#readme",
115
123
  "engines": {
116
- "node": ">= 12.0.0"
124
+ "node": ">= 24.14.0"
117
125
  },
118
126
  "keywords": [
119
127
  "cli",
@@ -1,8 +1,11 @@
1
1
  @font-face {
2
2
  font-display: auto;
3
- font-family: "{{ fontName }}";
3
+ font-family: "{{ fontFamily }}";
4
4
  font-style: normal;
5
5
  font-weight: 400;
6
+ {% if unicodeRange %}
7
+ unicode-range: {{ unicodeRange }};
8
+ {% endif %}
6
9
  {% if formats.indexOf('eot')>-1 -%}
7
10
  src: url("{{ fontPath }}{{ fontName }}.eot?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}");
8
11
  {%- endif %}
@@ -32,13 +35,13 @@
32
35
  {%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
33
36
  {%- endif -%}
34
37
  {%- if svgIndex != -1 -%}
35
- url("{{ fontPath }}{{ fontName }}.svg?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}#{{ fontName }}") format("svg");
38
+ url("{{ fontPath }}{{ fontName }}.svg?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}#{{ svgFontId }}") format("svg");
36
39
  {%- endif %}
37
40
  }
38
41
 
39
42
  .{{ className }} {
40
43
  display: inline-block;
41
- font-family: "{{ fontName }}";
44
+ font-family: "{{ fontFamily }}";
42
45
  font-weight: 400;
43
46
  font-style: normal;
44
47
  font-variant: normal;
@@ -2,7 +2,7 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="utf-8">
5
- <title>{{ fontName }}</title>
5
+ <title>{{ fontFamily }}</title>
6
6
  <style type="text/css">
7
7
  body {
8
8
  margin: 0;
@@ -48,9 +48,13 @@
48
48
 
49
49
  @font-face {
50
50
  font-display: block;
51
- font-family: "{{ fontName }}";
51
+ font-family: "{{ fontFamily }}";
52
52
  font-style: normal;
53
53
  font-weight: 400;
54
+ {# Ligature preview types ASCII names; unicode-range limited to PUA blocks the font for those code points. #}
55
+ {% if unicodeRange and not (templateFontLigatures and ligatures) %}
56
+ unicode-range: {{ unicodeRange }};
57
+ {% endif %}
54
58
  {% if formats.indexOf('eot')>-1 -%}
55
59
  src: url("{{ fontPath }}{{ fontName }}.eot?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}");
56
60
  {%- endif %}
@@ -80,13 +84,13 @@
80
84
  {%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
81
85
  {%- endif -%}
82
86
  {%- if svgIndex != -1 -%}
83
- url("{{ fontPath }}{{ fontName }}.svg?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}#{{ fontName }}") format("svg");
87
+ url("{{ fontPath }}{{ fontName }}.svg?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}#{{ svgFontId }}") format("svg");
84
88
  {%- endif %}
85
89
  }
86
90
 
87
91
  .{{ className }} {
88
92
  display: inline-block;
89
- font-family: "{{ fontName }}";
93
+ font-family: "{{ fontFamily }}";
90
94
  font-weight: 400;
91
95
  font-style: normal;
92
96
  font-variant: normal;
@@ -177,6 +181,13 @@
177
181
  margin-left: 0.3em;
178
182
  }
179
183
 
184
+ {% if templateFontLigatures %}
185
+ #icon-ligatures .{{ className }} {
186
+ font-feature-settings: "liga" 1;
187
+ font-variant-ligatures: common-ligatures;
188
+ }
189
+ {% endif %}
190
+
180
191
  {% for glyph in glyphs %}
181
192
  .{{ className }}-{{ glyph.name }}::before {
182
193
  content: "\{{ glyph.unicode[0].charCodeAt(0).toString(16) }}";
@@ -4,9 +4,12 @@
4
4
 
5
5
  @font-face {
6
6
  font-display: block;
7
- font-family: "{{ fontName }}";
7
+ font-family: "{{ fontFamily }}";
8
8
  font-style: normal;
9
9
  font-weight: 400;
10
+ {% if unicodeRange %}
11
+ unicode-range: {{ unicodeRange }};
12
+ {% endif %}
10
13
  {% if formats.indexOf('eot')>-1 -%}
11
14
  src: url("{{ fontPath }}{{ fontName }}.eot?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}");
12
15
  {%- endif -%}
@@ -36,13 +39,13 @@
36
39
  {%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
37
40
  {%- endif -%}
38
41
  {%- if svgIndex != -1 -%}
39
- url("{{ fontPath }}{{ fontName }}.svg?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}#{{ fontName }}") format("svg");
42
+ url("{{ fontPath }}{{ fontName }}.svg?{{ cacheString }}{% if hash %}&v={{ hash }}{% endif %}#{{ svgFontId }}") format("svg");
40
43
  {%- endif %}
41
44
  }
42
45
 
43
46
  %{{ className }} {
44
47
  display: inline-block;
45
- font-family: "{{ fontName }}";
48
+ font-family: "{{ fontFamily }}";
46
49
  font-weight: 400;
47
50
  font-style: normal;
48
51
  font-variant: normal;
@@ -2,7 +2,10 @@
2
2
  %}${{ className }}-{{ glyph.name }} = "\{{ glyph.unicode[0].charCodeAt(0).toString(16) }}";
3
3
  {% endfor %}
4
4
  @font-face {
5
- font-family: {{ fontName }};
5
+ font-family: {{ fontFamily }};
6
+ {% if unicodeRange %}
7
+ unicode-range: {{ unicodeRange }};
8
+ {% endif %}
6
9
  {% if formats.indexOf('eot')>-1 -%}
7
10
  src: url("{{ fontPath }}{{ fontName }}.eot{% if hash %}?v={{ hash }}{% endif %}");
8
11
  {%- endif -%}
@@ -32,7 +35,7 @@
32
35
  {%- if formats.length != 0 -%}, {% else -%}; {% endif -%}
33
36
  {%- endif -%}
34
37
  {%- if svgIndex != -1 -%}
35
- url("{{ fontPath }}{{ fontName }}.svg{% if hash %}?v={{ hash }}{% endif %}#{{ fontName }}") format("svg");
38
+ url("{{ fontPath }}{{ fontName }}.svg{% if hash %}?v={{ hash }}{% endif %}#{{ svgFontId }}") format("svg");
36
39
  {%- endif %}
37
40
  font-display: block;
38
41
  font-style: normal;
@@ -43,7 +46,7 @@
43
46
  display: inline-block;
44
47
  transform: translate(0, 0);
45
48
  text-rendering: auto;
46
- font: normal normal 400 14px/1 {{ fontName }};
49
+ font: normal normal 400 14px/1 {{ fontFamily }};
47
50
  font-size: inherit;
48
51
  -moz-osx-font-smoothing: grayscale;
49
52
  -webkit-font-smoothing: antialiased;