fontmin-rs 0.1.0-beta.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.
@@ -0,0 +1,25 @@
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";
2
+ //#region src/compat.d.ts
3
+ declare class FontminCompat {
4
+ static glyph: typeof glyph;
5
+ static deliverySlices: typeof deliverySlices;
6
+ static ttf2eot: typeof ttf2eot;
7
+ static ttf2svg: typeof ttf2svg;
8
+ static ttf2woff: typeof ttf2woff;
9
+ static ttf2woff2: typeof ttf2woff2;
10
+ static otf2ttf: typeof otf2ttf;
11
+ static svg2ttf: typeof svg2ttf;
12
+ static svgs2ttf: typeof svgs2ttf;
13
+ static css: typeof css;
14
+ private input;
15
+ private outputDir?;
16
+ private plugins;
17
+ src(file: string | string[] | Uint8Array): this;
18
+ dest(dir: string): this;
19
+ use(plugin: FontminPlugin): this;
20
+ config(): FontminConfig;
21
+ runAsync(): Promise<FontAsset[]>;
22
+ run(callback: (error: Error | null, files?: FontAsset[]) => void): void;
23
+ }
24
+ //#endregion
25
+ export { FontminCompat as default };
@@ -0,0 +1,3 @@
1
+ import { t as FontminCompat } from "./compat-B1CHDyqO.mjs";
2
+ import "./plugins.mjs";
3
+ export { FontminCompat as default };
@@ -0,0 +1,28 @@
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";
2
+ import FontminCompat from "./compat.mjs";
3
+ import { fontminCompatPreset } from "./presets.mjs";
4
+ //#region src/config.d.ts
5
+ declare function defineConfig<T extends FontminConfig>(config: T): T;
6
+ declare function loadConfig(configPath?: string): Promise<FontminConfig>;
7
+ //#endregion
8
+ //#region src/native.d.ts
9
+ declare function subsetTtf(input: Uint8Array, options?: SubsetOptions): Buffer;
10
+ declare function inspect(input: Uint8Array): FontInfo;
11
+ declare function ttfToWoff(input: Uint8Array, options?: WoffOptions): Buffer;
12
+ declare function woffToTtf(input: Uint8Array): Buffer;
13
+ declare function woff2ToTtf(input: Uint8Array): Buffer;
14
+ declare function eotToTtf(input: Uint8Array): Buffer;
15
+ declare function otfToTtf(input: Uint8Array, options?: Otf2TtfOptions): Buffer;
16
+ declare function ttfToWoff2(input: Uint8Array, options?: Ttf2Woff2Options): Buffer;
17
+ declare function ttfToWoff2Async(input: Uint8Array, options?: Ttf2Woff2Options): Promise<Buffer>;
18
+ declare function validateWoff2(input: Uint8Array): void;
19
+ declare function ttfToEot(input: Uint8Array, options?: Ttf2EotOptions): Buffer;
20
+ declare function ttfToSvg(input: Uint8Array, options?: Ttf2SvgOptions): string;
21
+ declare function svgFontToTtf(input: string, options?: Svg2TtfOptions): Buffer;
22
+ declare function svgsToTtf(inputs: SvgIcon[], options?: Svgs2TtfOptions): Buffer;
23
+ declare function generateFontFaceCss(sources: CssFontSource[], options?: CssOptions): string;
24
+ //#endregion
25
+ //#region src/optimize.d.ts
26
+ declare function optimize(config: FontminConfig): Promise<FontAsset[]>;
27
+ //#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 };
package/dist/index.mjs ADDED
@@ -0,0 +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";
2
+ import { css, definePlugin, deliverySlices, glyph, modernWeb, otf2ttf, svg2ttf, svgs2ttf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2 } from "./plugins.mjs";
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 };
@@ -0,0 +1,221 @@
1
+ //#region ../../wasm/fontmin/types.d.ts
2
+ type FontFormat = 'ttf' | 'otf' | 'woff' | 'woff2' | 'eot' | 'svg' | 'css' | 'unknown';
3
+ type OutputFormat = 'ttf' | 'woff' | 'woff2' | 'eot' | 'svg' | 'css';
4
+ type LayoutSubsetMode = 'drop' | 'conservative' | 'preserve';
5
+ interface FontMetadata {
6
+ ascender: number;
7
+ descender: number;
8
+ familyName?: string;
9
+ fullName?: string;
10
+ glyphCount: number;
11
+ postScriptName?: string;
12
+ subfamilyName?: string;
13
+ tables: string[];
14
+ unitsPerEm: number;
15
+ }
16
+ interface FontInfo {
17
+ format: FontFormat;
18
+ metadata: FontMetadata;
19
+ size: number;
20
+ }
21
+ interface SubsetOptions$1 {
22
+ basicText?: boolean;
23
+ keepNotdef?: boolean;
24
+ layout?: LayoutSubsetMode;
25
+ preserveHinting?: boolean;
26
+ text?: string;
27
+ trim?: boolean;
28
+ unicodeRanges?: string[];
29
+ unicodes?: number[];
30
+ }
31
+ interface WoffOptions {
32
+ compressionLevel?: number;
33
+ deflate?: boolean;
34
+ metadata?: string;
35
+ privateData?: Uint8Array;
36
+ }
37
+ interface Ttf2Woff2Options$1 {
38
+ quality?: number;
39
+ }
40
+ interface Ttf2EotOptions$1 {
41
+ version?: number;
42
+ }
43
+ interface Ttf2SvgOptions$1 {
44
+ fontFamily?: string;
45
+ }
46
+ interface Otf2TtfOptions$1 {
47
+ preserveHinting?: boolean;
48
+ variationCoordinates?: Record<string, number>;
49
+ }
50
+ interface Svg2TtfOptions$1 {
51
+ hinting?: boolean;
52
+ normalize?: boolean;
53
+ }
54
+ interface SvgIcon {
55
+ contents: string;
56
+ name: string;
57
+ unicode?: number;
58
+ }
59
+ interface Svgs2TtfOptions$1 {
60
+ ascent?: number;
61
+ descent?: number;
62
+ fontName?: string;
63
+ normalize?: boolean;
64
+ startUnicode?: number;
65
+ }
66
+ interface CssGlyph {
67
+ name?: string;
68
+ unicode: number;
69
+ }
70
+ interface CssFontSource {
71
+ contents?: Uint8Array;
72
+ fileName: string;
73
+ format: Exclude<OutputFormat, 'css'>;
74
+ glyphs?: CssGlyph[];
75
+ unicodeRanges?: string[];
76
+ }
77
+ interface CssOptions$1 {
78
+ asFileName?: boolean;
79
+ base64?: boolean;
80
+ fontDisplay?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
81
+ fontFamily?: string;
82
+ fontPath?: string;
83
+ glyph?: boolean;
84
+ iconPrefix?: string;
85
+ local?: boolean;
86
+ target?: 'css' | 'scss' | 'less';
87
+ unicodeRanges?: string[];
88
+ }
89
+ //#endregion
90
+ //#region src/types.d.ts
91
+ type AssetFormat = FontFormat | OutputFormat;
92
+ type RuntimeMode = 'native' | 'wasm' | 'auto';
93
+ type CssFontFamily = string | ((info: FontInfo) => string);
94
+ interface SubsetOptions extends Omit<SubsetOptions$1, 'layout'> {
95
+ textFile?: string;
96
+ keepLayout?: LayoutSubsetMode;
97
+ hinting?: boolean;
98
+ clone?: boolean;
99
+ }
100
+ interface DeliverySlice {
101
+ name: string;
102
+ unicodeRanges: string[];
103
+ }
104
+ interface FontAsset {
105
+ path: string;
106
+ contents: Uint8Array;
107
+ format: AssetFormat;
108
+ sourceFormat: FontFormat;
109
+ meta: Record<string, unknown>;
110
+ }
111
+ interface PluginDiagnostic {
112
+ level: 'warn';
113
+ message: string;
114
+ }
115
+ interface PluginContext {
116
+ cwd: string;
117
+ diagnostics: PluginDiagnostic[];
118
+ emitFile(asset: FontAsset): void;
119
+ readFile(path: string): Promise<Buffer>;
120
+ resolve(path: string): string;
121
+ warn(message: string | Error): void;
122
+ writeFile(path: string, contents: string | Uint8Array): Promise<void>;
123
+ }
124
+ type MaybePromise<T> = T | Promise<T>;
125
+ interface FontminPlugin {
126
+ name: string;
127
+ enforce?: 'pre' | 'post';
128
+ native?: {
129
+ kind: 'builtin';
130
+ name: string;
131
+ options: Record<string, unknown>;
132
+ };
133
+ buildStart?(ctx: PluginContext): MaybePromise<void>;
134
+ transform?(asset: FontAsset, ctx: PluginContext): MaybePromise<FontAsset | FontAsset[] | null | undefined>;
135
+ generateBundle?(assets: FontAsset[], ctx: PluginContext): MaybePromise<void>;
136
+ buildEnd?(ctx: PluginContext): MaybePromise<void>;
137
+ }
138
+ interface Ttf2WoffOptions extends Pick<WoffOptions, 'compressionLevel' | 'deflate'> {
139
+ clone?: boolean;
140
+ }
141
+ interface Ttf2Woff2Options extends Ttf2Woff2Options$1 {
142
+ clone?: boolean;
143
+ fallback?: 'native' | 'wasm' | 'js' | 'auto';
144
+ }
145
+ interface Ttf2EotOptions extends Ttf2EotOptions$1 {
146
+ clone?: boolean;
147
+ }
148
+ interface Otf2TtfOptions extends Otf2TtfOptions$1 {
149
+ clone?: boolean;
150
+ }
151
+ interface Ttf2SvgOptions extends Ttf2SvgOptions$1 {
152
+ clone?: boolean;
153
+ }
154
+ interface Svg2TtfOptions extends Svg2TtfOptions$1 {
155
+ clone?: boolean;
156
+ }
157
+ interface Svgs2TtfOptions extends Svgs2TtfOptions$1 {
158
+ clone?: boolean;
159
+ }
160
+ interface CssOptions extends Omit<CssOptions$1, 'fontFamily'> {
161
+ fontFamily?: CssFontFamily;
162
+ }
163
+ interface OutputConfig {
164
+ clone?: boolean;
165
+ ext?: string;
166
+ fileName?: string;
167
+ format: OutputFormat;
168
+ }
169
+ type ConfigOutput = OutputFormat | OutputConfig;
170
+ interface ModernWebOptions extends SubsetOptions, Otf2TtfOptions, Ttf2WoffOptions, Ttf2Woff2Options {
171
+ fontFamily?: CssOptions['fontFamily'];
172
+ fontPath?: string;
173
+ local?: boolean;
174
+ fontDisplay?: CssOptions['fontDisplay'];
175
+ }
176
+ interface FontminCompatPresetOptions extends SubsetOptions, Ttf2WoffOptions, Ttf2Woff2Options, Otf2TtfOptions, Ttf2EotOptions, Ttf2SvgOptions {
177
+ asFileName?: boolean;
178
+ base64?: boolean;
179
+ cssGlyph?: boolean;
180
+ deflateWoff?: boolean;
181
+ fontDisplay?: CssOptions['fontDisplay'];
182
+ fontPath?: string;
183
+ glyph?: boolean;
184
+ glyphCss?: boolean;
185
+ iconPrefix?: string;
186
+ local?: boolean;
187
+ target?: CssOptions['target'];
188
+ }
189
+ interface FontminConfig {
190
+ cwd?: string;
191
+ input?: (string | Uint8Array)[];
192
+ outDir?: string;
193
+ clean?: boolean;
194
+ preserveOriginal?: boolean;
195
+ cache?: boolean | CacheOptions;
196
+ subset?: SubsetOptions;
197
+ outputs?: ConfigOutput[];
198
+ css?: CssOptions;
199
+ plugins?: FontminPlugin[];
200
+ runtime?: RuntimeMode;
201
+ }
202
+ interface CacheOptions {
203
+ enabled?: boolean;
204
+ dir?: string;
205
+ }
206
+ //#endregion
207
+ //#region src/plugins.d.ts
208
+ declare function definePlugin<T extends FontminPlugin>(plugin: T): T;
209
+ declare function glyph(options?: SubsetOptions): FontminPlugin;
210
+ declare function deliverySlices(slices: DeliverySlice[]): FontminPlugin;
211
+ declare function ttf2woff(options?: Ttf2WoffOptions): FontminPlugin;
212
+ declare function ttf2woff2(options?: Ttf2Woff2Options): FontminPlugin;
213
+ declare function ttf2eot(options?: Ttf2EotOptions): FontminPlugin;
214
+ declare function otf2ttf(options?: Otf2TtfOptions): FontminPlugin;
215
+ declare function ttf2svg(options?: Ttf2SvgOptions): FontminPlugin;
216
+ declare function svg2ttf(options?: Svg2TtfOptions): FontminPlugin;
217
+ declare function svgs2ttf(options?: Svgs2TtfOptions): FontminPlugin;
218
+ declare function css(options?: CssOptions): FontminPlugin;
219
+ declare function modernWeb(options?: ModernWebOptions): FontminPlugin[];
220
+ //#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 };
@@ -0,0 +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";
2
+ export { css, definePlugin, deliverySlices, glyph, modernWeb, otf2ttf, svg2ttf, svgs2ttf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2 };
@@ -0,0 +1,149 @@
1
+ //#region src/plugins.ts
2
+ function definePlugin(plugin) {
3
+ return plugin;
4
+ }
5
+ function glyph(options = {}) {
6
+ const preserveHinting = options.preserveHinting ?? options.hinting ?? false;
7
+ return {
8
+ name: "fontmin:glyph",
9
+ native: {
10
+ kind: "builtin",
11
+ name: "glyph",
12
+ options: {
13
+ text: options.text,
14
+ textFile: options.textFile,
15
+ unicodes: options.unicodes,
16
+ unicodeRanges: options.unicodeRanges,
17
+ basicText: options.basicText,
18
+ hinting: options.hinting,
19
+ trim: options.trim,
20
+ keepNotdef: options.keepNotdef,
21
+ keepLayout: options.keepLayout,
22
+ clone: options.clone,
23
+ preserveHinting
24
+ }
25
+ }
26
+ };
27
+ }
28
+ function deliverySlices(slices) {
29
+ return {
30
+ name: "fontmin:unicode-slices",
31
+ native: {
32
+ kind: "builtin",
33
+ name: "unicodeSlices",
34
+ options: { slices: slices.map((slice) => ({
35
+ name: slice.name,
36
+ unicodeRanges: [...slice.unicodeRanges]
37
+ })) }
38
+ }
39
+ };
40
+ }
41
+ function ttf2woff(options = {}) {
42
+ return {
43
+ name: "fontmin:ttf2woff",
44
+ native: {
45
+ kind: "builtin",
46
+ name: "ttf2woff",
47
+ options: { ...options }
48
+ }
49
+ };
50
+ }
51
+ function ttf2woff2(options = {}) {
52
+ return {
53
+ name: "fontmin:ttf2woff2",
54
+ native: {
55
+ kind: "builtin",
56
+ name: "ttf2woff2",
57
+ options: { ...options }
58
+ }
59
+ };
60
+ }
61
+ function ttf2eot(options = {}) {
62
+ return {
63
+ name: "fontmin:ttf2eot",
64
+ native: {
65
+ kind: "builtin",
66
+ name: "ttf2eot",
67
+ options: { ...options }
68
+ }
69
+ };
70
+ }
71
+ function otf2ttf(options = {}) {
72
+ return {
73
+ name: "fontmin:otf2ttf",
74
+ native: {
75
+ kind: "builtin",
76
+ name: "otf2ttf",
77
+ options: { ...options }
78
+ }
79
+ };
80
+ }
81
+ function ttf2svg(options = {}) {
82
+ return {
83
+ name: "fontmin:ttf2svg",
84
+ native: {
85
+ kind: "builtin",
86
+ name: "ttf2svg",
87
+ options: { ...options }
88
+ }
89
+ };
90
+ }
91
+ function svg2ttf(options = {}) {
92
+ return {
93
+ name: "fontmin:svg2ttf",
94
+ native: {
95
+ kind: "builtin",
96
+ name: "svg2ttf",
97
+ options: { ...options }
98
+ }
99
+ };
100
+ }
101
+ function svgs2ttf(options = {}) {
102
+ return {
103
+ name: "fontmin:svgs2ttf",
104
+ native: {
105
+ kind: "builtin",
106
+ name: "svgs2ttf",
107
+ options: { ...options }
108
+ }
109
+ };
110
+ }
111
+ function css(options = {}) {
112
+ return {
113
+ name: "fontmin:css",
114
+ native: {
115
+ kind: "builtin",
116
+ name: "css",
117
+ options: { ...options }
118
+ }
119
+ };
120
+ }
121
+ function modernWeb(options = {}) {
122
+ const cssOptions = {};
123
+ if (options.fontFamily !== void 0) cssOptions.fontFamily = options.fontFamily;
124
+ if (options.fontPath !== void 0) cssOptions.fontPath = options.fontPath;
125
+ if (options.local !== void 0) cssOptions.local = options.local;
126
+ if (options.fontDisplay !== void 0) cssOptions.fontDisplay = options.fontDisplay;
127
+ const otfOptions = { clone: false };
128
+ const woffOptions = {};
129
+ const woff2Options = {};
130
+ if (options.preserveHinting !== void 0) otfOptions.preserveHinting = options.preserveHinting;
131
+ if (options.variationCoordinates !== void 0) otfOptions.variationCoordinates = options.variationCoordinates;
132
+ if (options.clone !== void 0) {
133
+ woffOptions.clone = options.clone;
134
+ woff2Options.clone = options.clone;
135
+ }
136
+ if (options.deflate !== void 0) woffOptions.deflate = options.deflate;
137
+ if (options.compressionLevel !== void 0) woffOptions.compressionLevel = options.compressionLevel;
138
+ if (options.quality !== void 0) woff2Options.quality = options.quality;
139
+ if (options.fallback !== void 0) woff2Options.fallback = options.fallback;
140
+ return [
141
+ otf2ttf(otfOptions),
142
+ glyph(options),
143
+ ttf2woff(woffOptions),
144
+ ttf2woff2(woff2Options),
145
+ css(cssOptions)
146
+ ];
147
+ }
148
+ //#endregion
149
+ export { css, definePlugin, deliverySlices, glyph, modernWeb, otf2ttf, svg2ttf, svgs2ttf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2 };
@@ -0,0 +1,5 @@
1
+ import { S as FontminPlugin, a as modernWeb, b as FontminCompatPresetOptions } from "./plugins-BeueRRP6.mjs";
2
+ //#region src/presets.d.ts
3
+ declare function fontminCompatPreset(options?: FontminCompatPresetOptions): FontminPlugin[];
4
+ //#endregion
5
+ export { fontminCompatPreset, modernWeb };
@@ -0,0 +1,70 @@
1
+ import { css, glyph, modernWeb, otf2ttf, ttf2eot, ttf2svg, ttf2woff, ttf2woff2 } from "./plugins.mjs";
2
+ //#region src/presets.ts
3
+ function fontminCompatPreset(options = {}) {
4
+ const cssOptions = cssOptionsFromPreset(options);
5
+ const eotOptions = eotOptionsFromPreset(options);
6
+ const otfOptions = otfOptionsFromPreset(options);
7
+ const svgOptions = svgOptionsFromPreset(options);
8
+ const woffOptions = woffOptionsFromPreset(options);
9
+ const woff2Options = woff2OptionsFromPreset(options);
10
+ return [
11
+ otf2ttf(otfOptions),
12
+ glyph(options),
13
+ ttf2eot(eotOptions),
14
+ ttf2svg(svgOptions),
15
+ ttf2woff(woffOptions),
16
+ ttf2woff2(woff2Options),
17
+ css(cssOptions)
18
+ ];
19
+ }
20
+ function cssOptionsFromPreset(options) {
21
+ const cssOptions = {};
22
+ if (options.asFileName !== void 0) cssOptions.asFileName = options.asFileName;
23
+ if (options.base64 !== void 0) cssOptions.base64 = options.base64;
24
+ if (options.cssGlyph !== void 0) cssOptions.glyph = options.cssGlyph;
25
+ else if (options.glyphCss !== void 0) cssOptions.glyph = options.glyphCss;
26
+ else if (typeof options.glyph === "boolean") cssOptions.glyph = options.glyph;
27
+ if (options.fontDisplay !== void 0) cssOptions.fontDisplay = options.fontDisplay;
28
+ if (options.fontFamily !== void 0) cssOptions.fontFamily = options.fontFamily;
29
+ if (options.fontPath !== void 0) cssOptions.fontPath = options.fontPath;
30
+ if (options.iconPrefix !== void 0) cssOptions.iconPrefix = options.iconPrefix;
31
+ if (options.local !== void 0) cssOptions.local = options.local;
32
+ if (options.target !== void 0) cssOptions.target = options.target;
33
+ return cssOptions;
34
+ }
35
+ function eotOptionsFromPreset(options) {
36
+ const eotOptions = {};
37
+ if (options.clone !== void 0) eotOptions.clone = options.clone;
38
+ if (options.version !== void 0) eotOptions.version = options.version;
39
+ return eotOptions;
40
+ }
41
+ function otfOptionsFromPreset(options) {
42
+ const otfOptions = {};
43
+ if (options.clone !== void 0) otfOptions.clone = options.clone;
44
+ if (options.preserveHinting !== void 0) otfOptions.preserveHinting = options.preserveHinting;
45
+ if (options.variationCoordinates !== void 0) otfOptions.variationCoordinates = options.variationCoordinates;
46
+ return otfOptions;
47
+ }
48
+ function svgOptionsFromPreset(options) {
49
+ const svgOptions = {};
50
+ if (options.clone !== void 0) svgOptions.clone = options.clone;
51
+ if (options.fontFamily !== void 0) svgOptions.fontFamily = options.fontFamily;
52
+ return svgOptions;
53
+ }
54
+ function woffOptionsFromPreset(options) {
55
+ const woffOptions = {};
56
+ if (options.clone !== void 0) woffOptions.clone = options.clone;
57
+ if (options.compressionLevel !== void 0) woffOptions.compressionLevel = options.compressionLevel;
58
+ if (options.deflate !== void 0) woffOptions.deflate = options.deflate;
59
+ else if (options.deflateWoff !== void 0) woffOptions.deflate = options.deflateWoff;
60
+ return woffOptions;
61
+ }
62
+ function woff2OptionsFromPreset(options) {
63
+ const woff2Options = {};
64
+ if (options.clone !== void 0) woff2Options.clone = options.clone;
65
+ if (options.fallback !== void 0) woff2Options.fallback = options.fallback;
66
+ if (options.quality !== void 0) woff2Options.quality = options.quality;
67
+ return woff2Options;
68
+ }
69
+ //#endregion
70
+ export { fontminCompatPreset, modernWeb };
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "fontmin-rs",
3
+ "version": "0.1.0-beta.1",
4
+ "description": "Fast font subsetter and converter written in Rust with Node.js bindings.",
5
+ "keywords": [
6
+ "font",
7
+ "fontmin",
8
+ "napi",
9
+ "subset",
10
+ "ttf"
11
+ ],
12
+ "homepage": "https://github.com/fontmin-rs/fontmin-rs#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/fontmin-rs/fontmin-rs/issues"
15
+ },
16
+ "license": "MIT",
17
+ "author": {
18
+ "name": "ntnyq",
19
+ "email": "ntnyq13@gmail.com"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/fontmin-rs/fontmin-rs.git"
24
+ },
25
+ "bin": {
26
+ "fontmin-rs": "./bin/fontmin-rs.mjs"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "bin"
31
+ ],
32
+ "type": "module",
33
+ "sideEffects": false,
34
+ "main": "./dist/index.mjs",
35
+ "types": "./dist/index.d.mts",
36
+ "exports": {
37
+ "./package.json": "./package.json",
38
+ ".": {
39
+ "types": "./dist/index.d.mts",
40
+ "default": "./dist/index.mjs"
41
+ },
42
+ "./plugins": {
43
+ "types": "./dist/plugins.d.mts",
44
+ "default": "./dist/plugins.mjs"
45
+ },
46
+ "./presets": {
47
+ "types": "./dist/presets.d.mts",
48
+ "default": "./dist/presets.mjs"
49
+ },
50
+ "./compat": {
51
+ "types": "./dist/compat.d.mts",
52
+ "default": "./dist/compat.mjs"
53
+ }
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "dependencies": {
59
+ "jsonc-parser": "^3.3.1",
60
+ "tinyglobby": "^0.2.17",
61
+ "@fontmin-rs/wasm": "0.1.0-beta.1"
62
+ },
63
+ "devDependencies": {
64
+ "@ntnyq/tsconfig": "^3.1.0",
65
+ "@types/node": "^26.1.1",
66
+ "fontmin": "^1.1.1",
67
+ "playwright": "^1.61.1",
68
+ "tinybench": "^6.0.2",
69
+ "tsdown": "^0.22.8",
70
+ "vitest": "^4.1.10"
71
+ },
72
+ "optionalDependencies": {
73
+ "@fontmin-rs/binding": "0.1.0-beta.1"
74
+ },
75
+ "scripts": {
76
+ "bench": "vitest bench --run bench",
77
+ "build": "tsdown",
78
+ "dev": "tsdown --watch",
79
+ "format": "oxfmt",
80
+ "format:check": "oxfmt --check",
81
+ "lint": "oxlint",
82
+ "pretest": "node ../../scripts/ensure-wasm.mjs",
83
+ "test": "vitest --run",
84
+ "test:browser": "pnpm run build && node tests/browser-load.mjs",
85
+ "typecheck": "tsgo --noEmit"
86
+ }
87
+ }