webfont 12.0.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.
Files changed (120) hide show
  1. package/NOTICE.md +14 -2
  2. package/README.md +199 -20
  3. package/dist/browser.js +4 -0
  4. package/dist/cli.mjs +850 -495
  5. package/dist/index.js +1 -1
  6. package/dist/index.mjs +513 -0
  7. package/dist/parseTemplateOption-BmH_pcQh.js +1 -0
  8. package/dist/parseTemplateOption-Bvbie1SQ.mjs +19 -0
  9. package/dist/parseTemplateOption-DLNu6PPx.mjs +38 -0
  10. package/dist/renderTemplates-Biyrk6t-.mjs +92 -0
  11. package/dist/renderTemplates-CXVKq3Op.mjs +102 -0
  12. package/dist/renderTemplates-zCYCzeOt.js +1 -0
  13. package/dist/src/browser.d.mts +2 -0
  14. package/dist/src/browser.d.ts +2 -0
  15. package/dist/src/index.d.mts +5 -0
  16. package/dist/src/index.d.ts +2 -0
  17. package/dist/src/lib/applyOptimizeSvgToGlyphs.d.mts +3 -0
  18. package/dist/src/lib/applyOptimizeSvgToGlyphs.d.ts +3 -0
  19. package/dist/src/lib/evenoddFillRule.d.mts +2 -0
  20. package/dist/src/lib/evenoddFillRule.d.ts +2 -0
  21. package/dist/src/lib/execCLI/index.d.mts +24 -0
  22. package/dist/src/lib/inputSource.d.mts +2 -0
  23. package/dist/src/lib/inputSource.d.ts +1 -4
  24. package/dist/src/lib/inputSourceUtils.d.mts +4 -0
  25. package/dist/src/lib/inputSourceUtils.d.ts +4 -0
  26. package/dist/src/lib/largeFontLigatures.d.mts +4 -0
  27. package/dist/src/lib/largeFontLigatures.d.ts +4 -0
  28. package/dist/src/lib/optimizeSvgGlyphs.d.mts +4 -0
  29. package/dist/src/lib/optimizeSvgGlyphs.d.ts +4 -0
  30. package/dist/src/lib/p-limit/index.d.mts +2 -0
  31. package/dist/src/lib/parseFormats.d.mts +4 -0
  32. package/dist/src/lib/parseFormats.d.ts +4 -0
  33. package/dist/src/lib/parseTemplateOption.d.mts +2 -0
  34. package/dist/src/lib/parseTemplateOption.d.ts +2 -0
  35. package/dist/src/lib/runtimeEnvironment.d.mts +4 -0
  36. package/dist/src/lib/runtimeEnvironment.d.ts +4 -0
  37. package/dist/src/lib/sfnt/flavor.d.mts +2 -0
  38. package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.mts +13 -0
  39. package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.ts +13 -0
  40. package/dist/src/lib/svgFontOutput/emptyGlyphPaths.d.mts +3 -0
  41. package/dist/src/lib/svgFontOutput/emptyGlyphPaths.d.ts +3 -0
  42. package/dist/src/lib/svgTools/applySvgDiagnostics.d.mts +13 -0
  43. package/dist/src/lib/svgTools/applySvgDiagnostics.d.ts +13 -0
  44. package/dist/src/lib/svgTools/applySvgTools.d.mts +14 -0
  45. package/dist/src/lib/svgTools/applySvgTools.d.ts +14 -0
  46. package/dist/src/lib/svgTools/normalizeSvgToolsOptions.d.mts +2 -0
  47. package/dist/src/lib/svgTools/normalizeSvgToolsOptions.d.ts +2 -0
  48. package/dist/src/lib/svgicons2svgfont/index.d.mts +14 -0
  49. package/dist/src/lib/svgicons2svgfont/index.d.ts +5 -0
  50. package/dist/src/lib/svgicons2svgfont/metadataFromSrcPath.d.mts +11 -0
  51. package/dist/src/lib/svgicons2svgfont/metadataFromSrcPath.d.ts +11 -0
  52. package/dist/src/lib/templateUnicodeRange.d.mts +4 -0
  53. package/dist/src/lib/templateUnicodeRange.d.ts +4 -0
  54. package/dist/src/lib/ttf2eot/index.d.mts +2 -0
  55. package/dist/src/lib/ttfEncode.d.mts +5 -0
  56. package/dist/src/lib/ttfEncode.d.ts +5 -0
  57. package/dist/src/standalone/convertTtfInput.d.mts +3 -0
  58. package/dist/src/standalone/convertTtfInput.d.ts +3 -0
  59. package/dist/src/standalone/convertWebfontInput.d.mts +3 -0
  60. package/dist/src/standalone/defaultOptions.d.mts +3 -0
  61. package/dist/src/standalone/defaultOptions.d.ts +3 -0
  62. package/dist/src/standalone/fetchWebfontUrl.d.mts +1 -0
  63. package/dist/src/standalone/generateSvgFont.d.mts +2 -0
  64. package/dist/src/standalone/generateSvgFont.d.ts +2 -0
  65. package/dist/src/standalone/getGlyphsDataFromInputs.d.mts +3 -0
  66. package/dist/src/standalone/getGlyphsDataFromInputs.d.ts +3 -0
  67. package/dist/src/standalone/glyphsData.d.mts +4 -0
  68. package/dist/src/standalone/glyphsData.d.ts +1 -1
  69. package/dist/src/standalone/index.d.mts +10 -0
  70. package/dist/src/standalone/index.d.ts +5 -0
  71. package/dist/src/standalone/inputMode.d.mts +9 -0
  72. package/dist/src/standalone/inputMode.d.ts +3 -1
  73. package/dist/src/standalone/options.d.mts +5 -0
  74. package/dist/src/standalone/optionsFromGlyphs.d.mts +3 -0
  75. package/dist/src/standalone/optionsFromGlyphs.d.ts +3 -0
  76. package/dist/src/standalone/renderTemplates.d.mts +10 -0
  77. package/dist/src/standalone/renderTemplates.d.ts +10 -0
  78. package/dist/src/standalone/runSvgPipeline.d.mts +3 -0
  79. package/dist/src/standalone/runSvgPipeline.d.ts +3 -0
  80. package/dist/src/standalone/templateFonts.d.mts +3 -0
  81. package/dist/src/standalone/toTtf.d.mts +4 -0
  82. package/dist/src/standalone/validateWebfontOptions.d.mts +6 -0
  83. package/dist/src/standalone/validateWebfontOptions.d.ts +6 -0
  84. package/dist/src/standalone/webfontFromGlyphs.d.mts +3 -0
  85. package/dist/src/standalone/webfontFromGlyphs.d.ts +3 -0
  86. package/dist/src/types/DecompressedFont.d.mts +5 -0
  87. package/dist/src/types/Format.d.mts +9 -0
  88. package/dist/src/types/GlyphContentTransformFn.d.mts +2 -0
  89. package/dist/src/types/GlyphContentTransformFn.d.ts +2 -0
  90. package/dist/src/types/GlyphData.d.mts +6 -0
  91. package/dist/src/types/GlyphInput.d.mts +6 -0
  92. package/dist/src/types/GlyphInput.d.ts +6 -0
  93. package/dist/src/types/GlyphMetadata.d.mts +10 -0
  94. package/dist/src/types/GlyphTransformFn.d.mts +2 -0
  95. package/dist/src/types/InitialOptions.d.mts +10 -0
  96. package/dist/src/types/InitialOptions.d.ts +2 -0
  97. package/dist/src/types/MetadataProvider.d.mts +5 -0
  98. package/dist/src/types/OptionsBase.d.mts +39 -0
  99. package/dist/src/types/OptionsBase.d.ts +9 -1
  100. package/dist/src/types/RenderedTemplate.d.mts +7 -0
  101. package/dist/src/types/RenderedTemplate.d.ts +7 -0
  102. package/dist/src/types/Result.d.mts +26 -0
  103. package/dist/src/types/Result.d.ts +8 -0
  104. package/dist/src/types/ResultConfig.d.mts +4 -0
  105. package/dist/src/types/SvgToolsOptions.d.mts +13 -0
  106. package/dist/src/types/SvgToolsOptions.d.ts +13 -0
  107. package/dist/src/types/TranscodedFont.d.mts +7 -0
  108. package/dist/src/types/TranscodedFont.d.ts +7 -0
  109. package/dist/src/types/WebfontFromGlyphsOptions.d.mts +11 -0
  110. package/dist/src/types/WebfontFromGlyphsOptions.d.ts +11 -0
  111. package/dist/src/types/WebfontOptions.d.mts +43 -0
  112. package/dist/src/types/WebfontOptions.d.ts +12 -2
  113. package/dist/src/types/index.d.mts +8 -0
  114. package/dist/src/types/index.d.ts +2 -1
  115. package/dist/templates/index.d.mts +19 -0
  116. package/package.json +42 -11
  117. package/templates/template.css.njk +6 -3
  118. package/templates/template.html.njk +15 -4
  119. package/templates/template.scss.njk +6 -3
  120. package/templates/template.styl.njk +6 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webfont",
3
- "version": "12.0.0",
3
+ "version": "12.1.1",
4
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",
@@ -15,13 +15,40 @@
15
15
  "README.md",
16
16
  "NOTICE.md"
17
17
  ],
18
+ "type": "commonjs",
19
+ "sideEffects": false,
18
20
  "main": "dist/index.js",
21
+ "module": "dist/index.mjs",
22
+ "browser": "dist/browser.js",
19
23
  "bin": "dist/cli.mjs",
20
24
  "source": "src/index.ts",
21
25
  "types": "dist/src/index.d.ts",
22
26
  "typings": "dist/src/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "browser": {
30
+ "types": "./dist/src/index.d.ts",
31
+ "default": "./dist/browser.js"
32
+ },
33
+ "node": {
34
+ "import": {
35
+ "types": "./dist/src/index.d.mts",
36
+ "default": "./dist/index.mjs"
37
+ },
38
+ "require": {
39
+ "types": "./dist/src/index.d.ts",
40
+ "default": "./dist/index.js"
41
+ }
42
+ },
43
+ "default": {
44
+ "types": "./dist/src/index.d.ts",
45
+ "default": "./dist/browser.js"
46
+ }
47
+ },
48
+ "./package.json": "./package.json"
49
+ },
23
50
  "scripts": {
24
- "build": "vite build --mode library && vite build --mode cli",
51
+ "build": "vite build --mode library && vite build --mode library-esm && vite build --mode browser && vite build --mode cli && node scripts/emit-mts-types.mjs",
25
52
  "clean": "rm -rf dist/ temp/",
26
53
  "demo": "node dist/cli.mjs './src/fixtures/svg-icons/*.svg' -d demo -t html --normalize --center-horizontally",
27
54
  "lint": "biome check .",
@@ -29,13 +56,18 @@
29
56
  "prebuild": "npm run clean && npm run lint",
30
57
  "prepare": "lefthook install",
31
58
  "predemo": "npm run build",
32
- "prepublishOnly": "npm run build",
59
+ "prepublishOnly": "npm run build && npm run test:package",
33
60
  "pretest": "npm run build",
34
61
  "prettify": "biome check --write .",
35
62
  "test": "vitest run src",
63
+ "test:attw": "attw --pack .",
64
+ "test:pack": "node scripts/pack-smoke-test.mjs",
65
+ "test:package": "npm run test:publint && npm run test:attw && npm run test:pack",
66
+ "test:publint": "publint --level=warning",
36
67
  "testc": "vitest run src --coverage",
37
68
  "test-debug": "vitest run src --no-file-parallelism",
38
- "testu": "vitest run src -u"
69
+ "testu": "vitest run src -u",
70
+ "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 24.14+, named import, unicode-range off, template fixes. See MIGRATION.md'"
39
71
  },
40
72
  "dependencies": {
41
73
  "cosmiconfig": "9.0.2",
@@ -48,23 +80,23 @@
48
80
  "resolve-from": "^5.0.0",
49
81
  "svg2ttf": "^6.1.0",
50
82
  "svgicons2svgfont": "^16.0.0",
83
+ "svgo": "4.0.1",
51
84
  "ttf2eot": "3.1.0",
52
85
  "ttf2woff": "^3.0.0",
53
- "wawoff2": "2.0.0",
86
+ "wawoff2": "2.0.1",
54
87
  "xml2js": "0.6.2"
55
88
  },
56
89
  "devDependencies": {
90
+ "@arethetypeswrong/cli": "0.18.4",
57
91
  "@biomejs/biome": "2.5.2",
58
- "@types/node": "^22.15.0",
92
+ "@types/node": "26.1.0",
59
93
  "@types/nunjucks": "3.2.6",
60
- "@types/rimraf": "latest",
61
94
  "@types/svg2ttf": "5.0.3",
62
95
  "@types/ttf2eot": "2.0.2",
63
96
  "@types/ttf2woff": "2.0.4",
64
97
  "@types/wawoff2": "1.0.2",
65
98
  "@types/xml2js": "0.4.14",
66
99
  "@vitest/coverage-v8": "4.1.9",
67
- "fast-glob": "3.2.12",
68
100
  "is-eot": "latest",
69
101
  "is-svg": "6.1.0",
70
102
  "is-ttf": "latest",
@@ -72,7 +104,7 @@
72
104
  "is-woff2": "latest",
73
105
  "knip": "6.24.0",
74
106
  "lefthook": "2.1.9",
75
- "rimraf": "latest",
107
+ "publint": "0.3.21",
76
108
  "typescript": "6.0.3",
77
109
  "vite": "8.1.3",
78
110
  "vite-plugin-checker": "0.14.4",
@@ -80,7 +112,6 @@
80
112
  "vitest": "4.1.9"
81
113
  },
82
114
  "overrides": {
83
- "fast-glob": "3.2.12",
84
115
  "minimatch": "10.2.5",
85
116
  "test-exclude": "7.0.2",
86
117
  "woff2sfnt-sfnt2woff": "1.0.0"
@@ -108,7 +139,7 @@
108
139
  },
109
140
  "homepage": "https://github.com/itgalaxy/webfont#readme",
110
141
  "engines": {
111
- "node": ">= 24.14.0"
142
+ "node": ">=24.14.0"
112
143
  },
113
144
  "keywords": [
114
145
  "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;