fontmin-rs 0.1.0-beta.1 → 0.1.0-beta.2

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.
@@ -5,6 +5,7 @@ import { mkdir, readFile, rm, stat, writeFile } from 'node:fs/promises'
5
5
  import { basename, dirname, extname, join, resolve } from 'node:path'
6
6
  import { pathToFileURL } from 'node:url'
7
7
  import {
8
+ analyzeCoverage,
8
9
  eotToTtf,
9
10
  generateFontFaceCss,
10
11
  inspectFont,
@@ -31,8 +32,9 @@ const DEFAULT_CONFIG_FILES = [
31
32
  const MODULE_CONFIG_EXTENSIONS = new Set(['.ts', '.mts', '.mjs', '.cjs'])
32
33
  const INIT_CONFIG_FILE = 'fontmin.config.jsonc'
33
34
  const CACHE_SCHEMA_VERSION = 'v1'
34
- const FONTMIN_VERSION = '0.1.0-beta.1'
35
+ const FONTMIN_VERSION = '0.1.0-beta.2'
35
36
  const DEFAULT_CACHE_DIR = 'node_modules/.cache/fontmin-rs'
37
+ let emitWarnings = true
36
38
  const DEFAULT_INIT_CONFIG = `{
37
39
  // Generated by fontmin-rs init.
38
40
  "input": ["fonts/*.ttf"],
@@ -64,6 +66,8 @@ const commandArgs = argv.slice(1)
64
66
  try {
65
67
  if (command === 'subset') {
66
68
  await subsetCommand(commandArgs)
69
+ } else if (command === 'coverage') {
70
+ await coverageCommand(commandArgs)
67
71
  } else if (command === 'convert') {
68
72
  await convertCommand(commandArgs)
69
73
  } else if (command === 'build') {
@@ -102,8 +106,9 @@ async function subsetCommand(args) {
102
106
  }
103
107
 
104
108
  const contents = await readFile(input)
105
- const subset = subsetTtf(contents, {
109
+ const subset = subsetWithCoverage(contents, {
106
110
  basicText,
111
+ missingGlyphs: subsetOptions.missingGlyphs,
107
112
  text: subsetOptions.text,
108
113
  unicodes: subsetOptions.unicodes,
109
114
  })
@@ -111,6 +116,43 @@ async function subsetCommand(args) {
111
116
  await writeOutput(output, subset)
112
117
  }
113
118
 
119
+ async function coverageCommand(args) {
120
+ const json = readFlag(args, ['--json'])
121
+ const basicText = readFlag(args, ['-b', '--basic-text'])
122
+ const options = await subsetOptionsFromArgs(args)
123
+ const [input] = args
124
+
125
+ requireValue(input, 'coverage requires an input font')
126
+ if (
127
+ options.text === undefined &&
128
+ options.unicodes.length === 0 &&
129
+ !basicText
130
+ ) {
131
+ throw new Error(
132
+ 'coverage requires --text, --text-file, --unicodes, or --basic-text',
133
+ )
134
+ }
135
+
136
+ const report = analyzeCoverage(await readFile(input), {
137
+ basicText,
138
+ text: options.text,
139
+ unicodes: options.unicodes,
140
+ })
141
+
142
+ if (json) {
143
+ process.stdout.write(`${JSON.stringify(report, undefined, 2)}\n`)
144
+ return
145
+ }
146
+
147
+ process.stdout.write(
148
+ `coverage: ${report.coveragePercent.toFixed(2)}% (${report.supported.length}/${report.requested.length})\nrequested: ${report.requested.length}\nsupported: ${report.supported.length}\nmissing: ${report.missing.length}\n`,
149
+ )
150
+ const warning = missingGlyphMessage(report)
151
+ if (warning !== undefined) {
152
+ process.stdout.write(`${warning}\n`)
153
+ }
154
+ }
155
+
114
156
  async function convertCommand(args) {
115
157
  const output = readOption(args, ['-o', '--output'])
116
158
  const format = readOption(args, ['-f', '--format'])
@@ -145,8 +187,9 @@ async function benchCommand(args) {
145
187
 
146
188
  const contents = await readFile(input)
147
189
  const startedAt = process.hrtime.bigint()
148
- const subset = subsetTtf(contents, {
190
+ const subset = subsetWithCoverage(contents, {
149
191
  basicText,
192
+ missingGlyphs: subsetOptions.missingGlyphs,
150
193
  text: subsetOptions.text,
151
194
  unicodes: subsetOptions.unicodes,
152
195
  })
@@ -174,8 +217,13 @@ async function buildCommand(args) {
174
217
  const silent = readFlag(args, ['--silent'])
175
218
  const startedAt = showTime && !silent ? process.hrtime.bigint() : undefined
176
219
 
177
- await runBuildCommand(args)
178
- reportShowTime(startedAt)
220
+ emitWarnings = !silent
221
+ try {
222
+ await runBuildCommand(args)
223
+ reportShowTime(startedAt)
224
+ } finally {
225
+ emitWarnings = true
226
+ }
179
227
  }
180
228
 
181
229
  async function runBuildCommand(args) {
@@ -361,8 +409,9 @@ async function buildDirectInput(
361
409
  subsetOptions.unicodes.length === 0 &&
362
410
  !basicText
363
411
  ? contents
364
- : subsetTtf(contents, {
412
+ : subsetWithCoverage(contents, {
365
413
  basicText,
414
+ missingGlyphs: subsetOptions.missingGlyphs,
366
415
  text: subsetOptions.text,
367
416
  unicodes: subsetOptions.unicodes,
368
417
  })
@@ -668,7 +717,8 @@ function applySubsetOverrides(config, { basicText, subsetOptions } = {}) {
668
717
  subsetOptions === undefined ||
669
718
  (subsetOptions.text === undefined &&
670
719
  subsetOptions.unicodes.length === 0 &&
671
- basicText !== true)
720
+ basicText !== true &&
721
+ subsetOptions.missingGlyphs === undefined)
672
722
  ) {
673
723
  return
674
724
  }
@@ -680,6 +730,9 @@ function applySubsetOverrides(config, { basicText, subsetOptions } = {}) {
680
730
  unicodes: subsetOptions.unicodes,
681
731
  }),
682
732
  ...(basicText === true && { basicText }),
733
+ ...(subsetOptions.missingGlyphs !== undefined && {
734
+ missingGlyphs: subsetOptions.missingGlyphs,
735
+ }),
683
736
  }
684
737
  }
685
738
 
@@ -722,8 +775,9 @@ async function buildConfigInput(
722
775
  unicodes.length === 0 &&
723
776
  subset.basicText !== true
724
777
  ? contents
725
- : subsetTtf(contents, {
778
+ : subsetWithCoverage(contents, {
726
779
  basicText: subset.basicText,
780
+ missingGlyphs: subset.missingGlyphs,
727
781
  text: subset.text,
728
782
  unicodes,
729
783
  })
@@ -1066,10 +1120,63 @@ async function subsetOptionsFromArgs(args) {
1066
1120
 
1067
1121
  return {
1068
1122
  ...subset,
1123
+ missingGlyphs: parseMissingGlyphPolicy(
1124
+ readOption(args, ['--missing-glyphs']),
1125
+ ),
1069
1126
  unicodes: subset.unicodes ?? [],
1070
1127
  }
1071
1128
  }
1072
1129
 
1130
+ function subsetWithCoverage(contents, options) {
1131
+ const policy = options.missingGlyphs ?? 'warn'
1132
+
1133
+ if (policy === 'warn') {
1134
+ const report = analyzeCoverage(contents, options)
1135
+ const warning = missingGlyphMessage(report)
1136
+
1137
+ if (warning !== undefined && emitWarnings) {
1138
+ process.stderr.write(`warning: ${warning}\n`)
1139
+ }
1140
+ }
1141
+
1142
+ return subsetTtf(contents, {
1143
+ ...options,
1144
+ missingGlyphs: policy === 'warn' ? 'ignore' : policy,
1145
+ })
1146
+ }
1147
+
1148
+ function missingGlyphMessage(report) {
1149
+ if (report.missing.length === 0) {
1150
+ return
1151
+ }
1152
+
1153
+ const visible = report.missing
1154
+ .slice(0, 16)
1155
+ .map(
1156
+ codePoint => `U+${codePoint.toString(16).toUpperCase().padStart(4, '0')}`,
1157
+ )
1158
+ .join(', ')
1159
+ const remaining = report.missing.length - 16
1160
+
1161
+ return `missing glyphs for requested Unicode code points: ${visible}${remaining > 0 ? `, and ${remaining} more` : ''}`
1162
+ }
1163
+
1164
+ function parseMissingGlyphPolicy(value) {
1165
+ if (value === undefined) {
1166
+ return
1167
+ }
1168
+
1169
+ const policy = value.trim().toLowerCase()
1170
+
1171
+ if (policy === 'ignore' || policy === 'warn' || policy === 'error') {
1172
+ return policy
1173
+ }
1174
+
1175
+ throw new Error(
1176
+ `missing glyph policy must be \`ignore\`, \`warn\`, or \`error\`: ${value}`,
1177
+ )
1178
+ }
1179
+
1073
1180
  async function resolveSubsetTextFile(subset, cwd) {
1074
1181
  if (subset.textFile === undefined) {
1075
1182
  return subset
@@ -1415,7 +1522,8 @@ async function writeOutput(output, contents) {
1415
1522
 
1416
1523
  function usage() {
1417
1524
  console.error(`Usage:
1418
- fontmin-rs subset <input.ttf> -o <output.ttf> (-t|--text <text> | --text-file <file> | --unicodes <list> | -b|--basic-text)
1525
+ fontmin-rs subset <input.ttf> -o <output.ttf> (-t|--text <text> | --text-file <file> | --unicodes <list> | -b|--basic-text) [--missing-glyphs <ignore|warn|error>]
1526
+ fontmin-rs coverage <input> (-t|--text <text> | --text-file <file> | --unicodes <list> | -b|--basic-text) [--json]
1419
1527
  fontmin-rs convert <input.ttf> -f <ttf|woff|woff2|eot|svg> -o <output>
1420
1528
  fontmin-rs build <input.ttf> -o <out-dir> --formats <ttf,woff,woff2,eot,svg,css> [-t|--text <text>] [--text-file <file>] [--unicodes <list>] [-b|--basic-text] [-d|--deflate-woff] [-T|--show-time] [--silent] [--no-original] [--cache|--no-cache]
1421
1529
  fontmin-rs build <input.ttf> -o <out-dir> --preset <compat|modern-web|iconfont> [-t|--text <text>] [--text-file <file>] [--unicodes <list>] [-b|--basic-text] [-d|--deflate-woff] [-T|--show-time] [--silent] [--no-original] [--cache|--no-cache]
@@ -147,20 +147,47 @@ function subsetTtf(input, options = {}) {
147
147
  if (options.trim !== void 0) nativeOptions.trim = options.trim;
148
148
  if (options.keepNotdef !== void 0) nativeOptions.keepNotdef = options.keepNotdef;
149
149
  if (options.keepLayout !== void 0) nativeOptions.keepLayout = options.keepLayout;
150
+ if (options.missingGlyphs !== void 0) nativeOptions.missingGlyphs = options.missingGlyphs;
150
151
  const preserveHinting = options.preserveHinting ?? options.hinting;
151
152
  if (preserveHinting !== void 0) nativeOptions.preserveHinting = preserveHinting;
152
153
  const inputBuffer = Buffer.isBuffer(input) ? input : Buffer.from(input);
153
- return loadNativeBinding().subsetTtf(inputBuffer, nativeOptions);
154
+ const binding = loadNativeBinding();
155
+ if ((options.missingGlyphs ?? "warn") === "warn") {
156
+ const warning = missingGlyphWarning(binding.analyzeCoverage(inputBuffer, coverageOptionsFromSubset(nativeOptions)));
157
+ if (warning !== void 0) process.emitWarning(warning, { code: "FONTMIN_MISSING_GLYPHS" });
158
+ }
159
+ return binding.subsetTtf(inputBuffer, nativeOptions);
154
160
  }
155
161
  function resolveSubsetText(options) {
156
162
  if (options.textFile === void 0) return options.text;
157
163
  const fileText = readFileSync(options.textFile, "utf8");
158
164
  return options.text === void 0 ? fileText : `${options.text}${fileText}`;
159
165
  }
166
+ function analyzeCoverage(input, options = {}) {
167
+ const inputBuffer = Buffer.isBuffer(input) ? input : Buffer.from(input);
168
+ return loadNativeBinding().analyzeCoverage(inputBuffer, toNativeCoverageOptions(options));
169
+ }
160
170
  function inspect(input) {
161
171
  const inputBuffer = Buffer.isBuffer(input) ? input : Buffer.from(input);
162
172
  return loadNativeBinding().inspectFont(inputBuffer);
163
173
  }
174
+ function toNativeCoverageOptions(options) {
175
+ const nativeOptions = {};
176
+ assignDefined(nativeOptions, "basicText", options.basicText);
177
+ assignDefined(nativeOptions, "text", options.text);
178
+ assignDefined(nativeOptions, "unicodeRanges", options.unicodeRanges);
179
+ assignDefined(nativeOptions, "unicodes", options.unicodes);
180
+ return nativeOptions;
181
+ }
182
+ function coverageOptionsFromSubset(options) {
183
+ return toNativeCoverageOptions(options);
184
+ }
185
+ function missingGlyphWarning(report) {
186
+ if (report.missing.length === 0) return;
187
+ const visible = report.missing.slice(0, 16).map((codepoint) => `U+${codepoint.toString(16).toUpperCase().padStart(4, "0")}`).join(", ");
188
+ const remaining = report.missing.length - 16;
189
+ return `missing glyphs for requested Unicode code points: ${visible}${remaining > 0 ? `, and ${remaining} more` : ""}`;
190
+ }
164
191
  function ttfToWoff(input, options = {}) {
165
192
  const inputBuffer = Buffer.isBuffer(input) ? input : Buffer.from(input);
166
193
  return loadNativeBinding().ttfToWoff(inputBuffer, toNativeWoffOptions(options));
@@ -385,7 +412,7 @@ const defaultRuntimeLoaders = {
385
412
  //#endregion
386
413
  //#region src/optimize.ts
387
414
  const CACHE_SCHEMA_VERSION = "v1";
388
- const FONTMIN_VERSION = "0.1.0-beta.1";
415
+ const FONTMIN_VERSION = "0.1.0-beta.2";
389
416
  const DEFAULT_CACHE_DIR = "node_modules/.cache/fontmin-rs";
390
417
  const DEFAULT_SVG_ICON_START_UNICODE = 57345;
391
418
  const CSS_GLYPHS_META_KEY = "cssGlyphs";
@@ -757,7 +784,10 @@ async function runUnicodeSlices(asset, options, runtime) {
757
784
  if (asset.format !== "ttf") return [asset];
758
785
  return Promise.all(deliverySlicesFromOptions(options).map(async (slice) => ({
759
786
  path: appendAssetSuffix(asset.path, slice.name),
760
- contents: Buffer.from(await runtime.subsetTtf(asset.contents, { unicodeRanges: slice.unicodeRanges })),
787
+ contents: Buffer.from(await runtime.subsetTtf(asset.contents, {
788
+ missingGlyphs: "ignore",
789
+ unicodeRanges: slice.unicodeRanges
790
+ })),
761
791
  format: "ttf",
762
792
  sourceFormat: asset.sourceFormat,
763
793
  meta: {
@@ -1254,4 +1284,4 @@ var FontminCompat = class {
1254
1284
  }
1255
1285
  };
1256
1286
  //#endregion
1257
- export { woffToTtf as _, inspect as a, svgFontToTtf as c, ttfToSvg as d, ttfToWoff as f, woff2ToTtf as g, validateWoff2 as h, generateFontFaceCss as i, svgsToTtf as l, ttfToWoff2Async as m, optimize as n, otfToTtf as o, ttfToWoff2 as p, eotToTtf as r, subsetTtf as s, FontminCompat as t, ttfToEot as u, defineConfig as v, loadConfig as y };
1287
+ export { woff2ToTtf as _, generateFontFaceCss as a, loadConfig as b, subsetTtf as c, ttfToEot as d, ttfToSvg as f, validateWoff2 as g, ttfToWoff2Async as h, eotToTtf as i, svgFontToTtf as l, ttfToWoff2 as m, optimize as n, inspect as o, ttfToWoff as p, analyzeCoverage as r, otfToTtf as s, FontminCompat as t, svgsToTtf as u, woffToTtf as v, defineConfig as y };
package/dist/compat.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { S as FontminPlugin, c as svgs2ttf, d as ttf2woff, f as ttf2woff2, i as glyph, l as ttf2eot, o as otf2ttf, r as deliverySlices, s as svg2ttf, t as css, u as ttf2svg, x as FontminConfig, y as FontAsset } from "./plugins-BeueRRP6.mjs";
1
+ import { S as FontminPlugin, c as svgs2ttf, d as ttf2woff, f as ttf2woff2, i as glyph, l as ttf2eot, o as otf2ttf, r as deliverySlices, s as svg2ttf, t as css, u as ttf2svg, x as FontminConfig, y as FontAsset } from "./plugins-CKuT_b0n.mjs";
2
2
  //#region src/compat.d.ts
3
3
  declare class FontminCompat {
4
4
  static glyph: typeof glyph;
package/dist/compat.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as FontminCompat } from "./compat-B1CHDyqO.mjs";
1
+ import { t as FontminCompat } from "./compat-B5e9im94.mjs";
2
2
  import "./plugins.mjs";
3
3
  export { FontminCompat as default };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as SubsetOptions, B as FontInfo, C as MaybePromise, D as PluginContext, E as OutputConfig, F as Ttf2Woff2Options, G as WoffOptions, H as LayoutSubsetMode, I as Ttf2WoffOptions, L as CssFontSource, M as Svgs2TtfOptions, N as Ttf2EotOptions, O as PluginDiagnostic, P as Ttf2SvgOptions, R as CssGlyph, S as FontminPlugin, T as Otf2TtfOptions, U as OutputFormat, V as FontMetadata, W as SvgIcon, _ as CssOptions, a as modernWeb, b as FontminCompatPresetOptions, c as svgs2ttf, d as ttf2woff, f as ttf2woff2, g as CssFontFamily, h as ConfigOutput, i as glyph, j as Svg2TtfOptions, k as RuntimeMode, l as ttf2eot, m as CacheOptions, n as definePlugin, o as otf2ttf, p as AssetFormat, r as deliverySlices, s as svg2ttf, t as css, u as ttf2svg, v as DeliverySlice, w as ModernWebOptions, x as FontminConfig, y as FontAsset, z as FontFormat } from "./plugins-BeueRRP6.mjs";
1
+ import { A as SubsetOptions, B as CssGlyph, C as MaybePromise, D as PluginContext, E as OutputConfig, F as Ttf2Woff2Options, G as MissingGlyphPolicy, H as FontInfo, I as Ttf2WoffOptions, J as WoffOptions, K as OutputFormat, L as CoverageOptions, M as Svgs2TtfOptions, N as Ttf2EotOptions, O as PluginDiagnostic, P as Ttf2SvgOptions, R as CoverageReport, S as FontminPlugin, T as Otf2TtfOptions, U as FontMetadata, V as FontFormat, W as LayoutSubsetMode, _ as CssOptions, a as modernWeb, b as FontminCompatPresetOptions, c as svgs2ttf, d as ttf2woff, f as ttf2woff2, g as CssFontFamily, h as ConfigOutput, i as glyph, j as Svg2TtfOptions, k as RuntimeMode, l as ttf2eot, m as CacheOptions, n as definePlugin, o as otf2ttf, p as AssetFormat, q as SvgIcon, r as deliverySlices, s as svg2ttf, t as css, u as ttf2svg, v as DeliverySlice, w as ModernWebOptions, x as FontminConfig, y as FontAsset, z as CssFontSource } from "./plugins-CKuT_b0n.mjs";
2
2
  import FontminCompat from "./compat.mjs";
3
3
  import { fontminCompatPreset } from "./presets.mjs";
4
4
  //#region src/config.d.ts
@@ -7,6 +7,7 @@ declare function loadConfig(configPath?: string): Promise<FontminConfig>;
7
7
  //#endregion
8
8
  //#region src/native.d.ts
9
9
  declare function subsetTtf(input: Uint8Array, options?: SubsetOptions): Buffer;
10
+ declare function analyzeCoverage(input: Uint8Array, options?: CoverageOptions): CoverageReport;
10
11
  declare function inspect(input: Uint8Array): FontInfo;
11
12
  declare function ttfToWoff(input: Uint8Array, options?: WoffOptions): Buffer;
12
13
  declare function woffToTtf(input: Uint8Array): Buffer;
@@ -25,4 +26,4 @@ declare function generateFontFaceCss(sources: CssFontSource[], options?: CssOpti
25
26
  //#region src/optimize.d.ts
26
27
  declare function optimize(config: FontminConfig): Promise<FontAsset[]>;
27
28
  //#endregion
28
- export { type AssetFormat, type CacheOptions, type ConfigOutput, type CssFontFamily, type CssFontSource, type CssGlyph, type CssOptions, type DeliverySlice, type FontAsset, type FontFormat, type FontInfo, type FontMetadata, type FontminCompatPresetOptions, type FontminConfig, type FontminPlugin, type LayoutSubsetMode, type MaybePromise, type ModernWebOptions, type Otf2TtfOptions, type OutputConfig, type OutputFormat, type PluginContext, type PluginDiagnostic, type RuntimeMode, type SubsetOptions, type Svg2TtfOptions, type SvgIcon, type Svgs2TtfOptions, type Ttf2EotOptions, type Ttf2SvgOptions, type Ttf2Woff2Options, type Ttf2WoffOptions, type WoffOptions, css, FontminCompat as default, defineConfig, definePlugin, deliverySlices, eotToTtf, fontminCompatPreset, generateFontFaceCss, glyph, inspect, loadConfig, modernWeb, optimize, otf2ttf, otfToTtf, subsetTtf, svg2ttf, svgFontToTtf, svgs2ttf, svgsToTtf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2, ttfToEot, ttfToSvg, ttfToWoff, ttfToWoff2, ttfToWoff2Async, validateWoff2, woff2ToTtf, woffToTtf };
29
+ export { type AssetFormat, type CacheOptions, type ConfigOutput, type CoverageOptions, type CoverageReport, type CssFontFamily, type CssFontSource, type CssGlyph, type CssOptions, type DeliverySlice, type FontAsset, type FontFormat, type FontInfo, type FontMetadata, type FontminCompatPresetOptions, type FontminConfig, type FontminPlugin, type LayoutSubsetMode, type MaybePromise, type MissingGlyphPolicy, type ModernWebOptions, type Otf2TtfOptions, type OutputConfig, type OutputFormat, type PluginContext, type PluginDiagnostic, type RuntimeMode, type SubsetOptions, type Svg2TtfOptions, type SvgIcon, type Svgs2TtfOptions, type Ttf2EotOptions, type Ttf2SvgOptions, type Ttf2Woff2Options, type Ttf2WoffOptions, type WoffOptions, analyzeCoverage, css, FontminCompat as default, defineConfig, definePlugin, deliverySlices, eotToTtf, fontminCompatPreset, generateFontFaceCss, glyph, inspect, loadConfig, modernWeb, optimize, otf2ttf, otfToTtf, subsetTtf, svg2ttf, svgFontToTtf, svgs2ttf, svgsToTtf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2, ttfToEot, ttfToSvg, ttfToWoff, ttfToWoff2, ttfToWoff2Async, validateWoff2, woff2ToTtf, woffToTtf };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as woffToTtf, a as inspect, c as svgFontToTtf, d as ttfToSvg, f as ttfToWoff, g as woff2ToTtf, h as validateWoff2, i as generateFontFaceCss, l as svgsToTtf, m as ttfToWoff2Async, n as optimize, o as otfToTtf, p as ttfToWoff2, r as eotToTtf, s as subsetTtf, t as FontminCompat, u as ttfToEot, v as defineConfig, y as loadConfig } from "./compat-B1CHDyqO.mjs";
1
+ import { _ as woff2ToTtf, a as generateFontFaceCss, b as loadConfig, c as subsetTtf, d as ttfToEot, f as ttfToSvg, g as validateWoff2, h as ttfToWoff2Async, i as eotToTtf, l as svgFontToTtf, m as ttfToWoff2, n as optimize, o as inspect, p as ttfToWoff, r as analyzeCoverage, s as otfToTtf, t as FontminCompat, u as svgsToTtf, v as woffToTtf, y as defineConfig } from "./compat-B5e9im94.mjs";
2
2
  import { css, definePlugin, deliverySlices, glyph, modernWeb, otf2ttf, svg2ttf, svgs2ttf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2 } from "./plugins.mjs";
3
3
  import { fontminCompatPreset } from "./presets.mjs";
4
- export { css, FontminCompat as default, defineConfig, definePlugin, deliverySlices, eotToTtf, fontminCompatPreset, generateFontFaceCss, glyph, inspect, loadConfig, modernWeb, optimize, otf2ttf, otfToTtf, subsetTtf, svg2ttf, svgFontToTtf, svgs2ttf, svgsToTtf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2, ttfToEot, ttfToSvg, ttfToWoff, ttfToWoff2, ttfToWoff2Async, validateWoff2, woff2ToTtf, woffToTtf };
4
+ export { analyzeCoverage, css, FontminCompat as default, defineConfig, definePlugin, deliverySlices, eotToTtf, fontminCompatPreset, generateFontFaceCss, glyph, inspect, loadConfig, modernWeb, optimize, otf2ttf, otfToTtf, subsetTtf, svg2ttf, svgFontToTtf, svgs2ttf, svgsToTtf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2, ttfToEot, ttfToSvg, ttfToWoff, ttfToWoff2, ttfToWoff2Async, validateWoff2, woff2ToTtf, woffToTtf };
@@ -2,6 +2,19 @@
2
2
  type FontFormat = 'ttf' | 'otf' | 'woff' | 'woff2' | 'eot' | 'svg' | 'css' | 'unknown';
3
3
  type OutputFormat = 'ttf' | 'woff' | 'woff2' | 'eot' | 'svg' | 'css';
4
4
  type LayoutSubsetMode = 'drop' | 'conservative' | 'preserve';
5
+ type MissingGlyphPolicy = 'ignore' | 'warn' | 'error';
6
+ interface CoverageOptions {
7
+ basicText?: boolean;
8
+ text?: string;
9
+ unicodeRanges?: string[];
10
+ unicodes?: number[];
11
+ }
12
+ interface CoverageReport {
13
+ coveragePercent: number;
14
+ missing: number[];
15
+ requested: number[];
16
+ supported: number[];
17
+ }
5
18
  interface FontMetadata {
6
19
  ascender: number;
7
20
  descender: number;
@@ -18,15 +31,12 @@ interface FontInfo {
18
31
  metadata: FontMetadata;
19
32
  size: number;
20
33
  }
21
- interface SubsetOptions$1 {
22
- basicText?: boolean;
34
+ interface SubsetOptions$1 extends CoverageOptions {
23
35
  keepNotdef?: boolean;
24
36
  layout?: LayoutSubsetMode;
37
+ missingGlyphs?: MissingGlyphPolicy;
25
38
  preserveHinting?: boolean;
26
- text?: string;
27
39
  trim?: boolean;
28
- unicodeRanges?: string[];
29
- unicodes?: number[];
30
40
  }
31
41
  interface WoffOptions {
32
42
  compressionLevel?: number;
@@ -218,4 +228,4 @@ declare function svgs2ttf(options?: Svgs2TtfOptions): FontminPlugin;
218
228
  declare function css(options?: CssOptions): FontminPlugin;
219
229
  declare function modernWeb(options?: ModernWebOptions): FontminPlugin[];
220
230
  //#endregion
221
- export { SubsetOptions as A, FontInfo as B, MaybePromise as C, PluginContext as D, OutputConfig as E, Ttf2Woff2Options as F, WoffOptions as G, LayoutSubsetMode as H, Ttf2WoffOptions as I, CssFontSource as L, Svgs2TtfOptions as M, Ttf2EotOptions as N, PluginDiagnostic as O, Ttf2SvgOptions as P, CssGlyph as R, FontminPlugin as S, Otf2TtfOptions as T, OutputFormat as U, FontMetadata as V, SvgIcon as W, CssOptions as _, modernWeb as a, FontminCompatPresetOptions as b, svgs2ttf as c, ttf2woff as d, ttf2woff2 as f, CssFontFamily as g, ConfigOutput as h, glyph as i, Svg2TtfOptions as j, RuntimeMode as k, ttf2eot as l, CacheOptions as m, definePlugin as n, otf2ttf as o, AssetFormat as p, deliverySlices as r, svg2ttf as s, css as t, ttf2svg as u, DeliverySlice as v, ModernWebOptions as w, FontminConfig as x, FontAsset as y, FontFormat as z };
231
+ export { SubsetOptions as A, CssGlyph as B, MaybePromise as C, PluginContext as D, OutputConfig as E, Ttf2Woff2Options as F, MissingGlyphPolicy as G, FontInfo as H, Ttf2WoffOptions as I, WoffOptions as J, OutputFormat as K, CoverageOptions as L, Svgs2TtfOptions as M, Ttf2EotOptions as N, PluginDiagnostic as O, Ttf2SvgOptions as P, CoverageReport as R, FontminPlugin as S, Otf2TtfOptions as T, FontMetadata as U, FontFormat as V, LayoutSubsetMode as W, CssOptions as _, modernWeb as a, FontminCompatPresetOptions as b, svgs2ttf as c, ttf2woff as d, ttf2woff2 as f, CssFontFamily as g, ConfigOutput as h, glyph as i, Svg2TtfOptions as j, RuntimeMode as k, ttf2eot as l, CacheOptions as m, definePlugin as n, otf2ttf as o, AssetFormat as p, SvgIcon as q, deliverySlices as r, svg2ttf as s, css as t, ttf2svg as u, DeliverySlice as v, ModernWebOptions as w, FontminConfig as x, FontAsset as y, CssFontSource as z };
@@ -1,2 +1,2 @@
1
- import { a as modernWeb, c as svgs2ttf, d as ttf2woff, f as ttf2woff2, i as glyph, l as ttf2eot, n as definePlugin, o as otf2ttf, r as deliverySlices, s as svg2ttf, t as css, u as ttf2svg } from "./plugins-BeueRRP6.mjs";
1
+ import { a as modernWeb, c as svgs2ttf, d as ttf2woff, f as ttf2woff2, i as glyph, l as ttf2eot, n as definePlugin, o as otf2ttf, r as deliverySlices, s as svg2ttf, t as css, u as ttf2svg } from "./plugins-CKuT_b0n.mjs";
2
2
  export { css, definePlugin, deliverySlices, glyph, modernWeb, otf2ttf, svg2ttf, svgs2ttf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2 };
package/dist/plugins.mjs CHANGED
@@ -19,6 +19,7 @@ function glyph(options = {}) {
19
19
  trim: options.trim,
20
20
  keepNotdef: options.keepNotdef,
21
21
  keepLayout: options.keepLayout,
22
+ missingGlyphs: options.missingGlyphs,
22
23
  clone: options.clone,
23
24
  preserveHinting
24
25
  }
@@ -1,4 +1,4 @@
1
- import { S as FontminPlugin, a as modernWeb, b as FontminCompatPresetOptions } from "./plugins-BeueRRP6.mjs";
1
+ import { S as FontminPlugin, a as modernWeb, b as FontminCompatPresetOptions } from "./plugins-CKuT_b0n.mjs";
2
2
  //#region src/presets.d.ts
3
3
  declare function fontminCompatPreset(options?: FontminCompatPresetOptions): FontminPlugin[];
4
4
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fontmin-rs",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.2",
4
4
  "description": "Fast font subsetter and converter written in Rust with Node.js bindings.",
5
5
  "keywords": [
6
6
  "font",
@@ -58,7 +58,7 @@
58
58
  "dependencies": {
59
59
  "jsonc-parser": "^3.3.1",
60
60
  "tinyglobby": "^0.2.17",
61
- "@fontmin-rs/wasm": "0.1.0-beta.1"
61
+ "@fontmin-rs/wasm": "0.1.0-beta.2"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@ntnyq/tsconfig": "^3.1.0",
@@ -66,11 +66,11 @@
66
66
  "fontmin": "^1.1.1",
67
67
  "playwright": "^1.61.1",
68
68
  "tinybench": "^6.0.2",
69
- "tsdown": "^0.22.8",
69
+ "tsdown": "^0.22.12",
70
70
  "vitest": "^4.1.10"
71
71
  },
72
72
  "optionalDependencies": {
73
- "@fontmin-rs/binding": "0.1.0-beta.1"
73
+ "@fontmin-rs/binding": "0.1.0-beta.2"
74
74
  },
75
75
  "scripts": {
76
76
  "bench": "vitest bench --run bench",