webfont 12.1.0 → 12.2.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.
- package/README.md +58 -12
- package/dist/cli.mjs +875 -772
- package/dist/index.js +1 -1
- package/dist/index.mjs +523 -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 +11 -0
- package/dist/src/types/Format.d.ts +5 -3
- 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 +12 -0
- package/dist/src/types/InitialOptions.d.ts +2 -0
- package/dist/src/types/MetadataProvider.d.mts +5 -0
- package/dist/src/types/OptionsBase.d.mts +41 -0
- package/dist/src/types/OptionsBase.d.ts +3 -1
- 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/TtfPostProcessFn.d.mts +12 -0
- package/dist/src/types/TtfPostProcessFn.d.ts +12 -0
- package/dist/src/types/WebfontFromGlyphsOptions.d.mts +11 -0
- package/dist/src/types/WebfontOptions.d.mts +44 -0
- package/dist/src/types/WebfontOptions.d.ts +1 -0
- package/dist/src/types/index.d.mts +9 -0
- package/dist/src/types/index.d.ts +1 -0
- package/package.json +38 -18
- package/dist/templates/index.d.ts +0 -19
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
import { fileURLToPath as e } from "node:url";
|
|
3
2
|
e(import.meta.url);
|
|
4
3
|
const t = e(new URL(".", import.meta.url));
|
|
5
|
-
import { t as n } from "./parseTemplateOption-
|
|
6
|
-
import r from "
|
|
7
|
-
import i from "
|
|
4
|
+
import { t as n } from "./parseTemplateOption-Bvbie1SQ.mjs";
|
|
5
|
+
import r from "deepmerge";
|
|
6
|
+
import i from "path";
|
|
8
7
|
import a from "nunjucks";
|
|
9
8
|
//#region templates/index.ts
|
|
10
|
-
var o = () =>
|
|
9
|
+
var o = () => i.resolve(t, "../templates"), s = (e) => `${o()}/template.${e}.njk`, c = () => {
|
|
11
10
|
let e = o();
|
|
12
11
|
return {
|
|
13
|
-
css: { path:
|
|
14
|
-
html: { path:
|
|
15
|
-
json: { path:
|
|
16
|
-
scss: { path:
|
|
17
|
-
styl: { path:
|
|
12
|
+
css: { path: i.join(e, "template.css.njk") },
|
|
13
|
+
html: { path: i.join(e, "template.html.njk") },
|
|
14
|
+
json: { path: i.join(e, "template.json.njk") },
|
|
15
|
+
scss: { path: i.join(e, "template.scss.njk") },
|
|
16
|
+
styl: { path: i.join(e, "template.styl.njk") }
|
|
18
17
|
};
|
|
19
18
|
}, l = (e) => {
|
|
20
19
|
let t = 4;
|
|
@@ -53,7 +52,7 @@ var o = () => r.resolve(t, "../templates"), s = (e) => `${o()}/template.${e}.njk
|
|
|
53
52
|
};
|
|
54
53
|
let d = c(), f = [], h = !1, g = {};
|
|
55
54
|
e.addHashInFontUrl && (g = { hash: o.hash });
|
|
56
|
-
let _ = o.glyphsData?.map((e) => e.metadata).filter((e) => e !== void 0) ?? [], v =
|
|
55
|
+
let _ = o.glyphsData?.map((e) => e.metadata).filter((e) => e !== void 0) ?? [], v = r.all([
|
|
57
56
|
{ glyphs: _ },
|
|
58
57
|
e,
|
|
59
58
|
{
|
|
@@ -69,19 +68,19 @@ var o = () => r.resolve(t, "../templates"), s = (e) => `${o()}/template.${e}.njk
|
|
|
69
68
|
{ templateFontLigatures: e.templateFontLigatures !== !1 }
|
|
70
69
|
]);
|
|
71
70
|
for (let e of u) {
|
|
72
|
-
let n,
|
|
71
|
+
let n, r;
|
|
73
72
|
if (Object.keys(d).includes(e)) {
|
|
74
|
-
h = !0,
|
|
75
|
-
let o =
|
|
73
|
+
h = !0, r = e;
|
|
74
|
+
let o = i.resolve(t, "../..");
|
|
76
75
|
a.configure(o), n = s(e);
|
|
77
76
|
} else {
|
|
78
|
-
let t =
|
|
79
|
-
a.configure(
|
|
77
|
+
let t = i.resolve(e);
|
|
78
|
+
a.configure(i.dirname(t)), n = i.resolve(t);
|
|
80
79
|
}
|
|
81
80
|
f.push({
|
|
82
81
|
template: e,
|
|
83
82
|
content: a.render(n, v),
|
|
84
|
-
builtIn:
|
|
83
|
+
builtIn: r
|
|
85
84
|
});
|
|
86
85
|
}
|
|
87
86
|
return {
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath as e } from "node:url";
|
|
3
|
+
e(import.meta.url);
|
|
4
|
+
const t = e(new URL(".", import.meta.url));
|
|
5
|
+
import { i as n, n as r, t as i } from "./parseTemplateOption-DLNu6PPx.mjs";
|
|
6
|
+
import a from "path";
|
|
7
|
+
import o from "deepmerge";
|
|
8
|
+
import s from "nunjucks";
|
|
9
|
+
//#region templates/index.ts
|
|
10
|
+
var c, l, u, d = n((() => {
|
|
11
|
+
c = () => a.resolve(t, "../templates"), l = (e) => `${c()}/template.${e}.njk`, u = () => {
|
|
12
|
+
let e = c();
|
|
13
|
+
return {
|
|
14
|
+
css: { path: a.join(e, "template.css.njk") },
|
|
15
|
+
html: { path: a.join(e, "template.html.njk") },
|
|
16
|
+
json: { path: a.join(e, "template.json.njk") },
|
|
17
|
+
scss: { path: a.join(e, "template.scss.njk") },
|
|
18
|
+
styl: { path: a.join(e, "template.styl.njk") }
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
})), f, p, m, h, g, _ = n((() => {
|
|
22
|
+
f = (e) => {
|
|
23
|
+
let t = 4;
|
|
24
|
+
return e > 65535 && (t = 6), e.toString(16).toUpperCase().padStart(t, "0");
|
|
25
|
+
}, p = (e) => {
|
|
26
|
+
if (e.length === 0 || e.length > 2) return;
|
|
27
|
+
let t = e.codePointAt(0);
|
|
28
|
+
if (t !== void 0 && !(e.length > 1 && t < 128)) return t;
|
|
29
|
+
}, m = (e) => {
|
|
30
|
+
let t = [];
|
|
31
|
+
for (let n of e) for (let e of n.unicode ?? []) {
|
|
32
|
+
let n = p(e);
|
|
33
|
+
n !== void 0 && t.push(n);
|
|
34
|
+
}
|
|
35
|
+
return t;
|
|
36
|
+
}, h = (e) => {
|
|
37
|
+
let t = m(e);
|
|
38
|
+
if (t.length === 0) return;
|
|
39
|
+
let n = Math.min(...t), r = Math.max(...t);
|
|
40
|
+
return n === r ? `U+${f(n)}` : `U+${f(n)}-${f(r)}`;
|
|
41
|
+
}, g = (e, t) => {
|
|
42
|
+
if (!(e === !1 || e === void 0)) return typeof e == "string" ? e : h(t);
|
|
43
|
+
};
|
|
44
|
+
})), v, y = n((() => {
|
|
45
|
+
v = (e, t) => {
|
|
46
|
+
if (e === "woff2") {
|
|
47
|
+
if (!t.woff2) throw Error("Missing woff2 buffer for template rendering");
|
|
48
|
+
return Buffer.from(t.woff2).toString("base64");
|
|
49
|
+
}
|
|
50
|
+
let n = t[e];
|
|
51
|
+
if (!n) throw Error(`Missing ${e} buffer for template rendering`);
|
|
52
|
+
return n.toString("base64");
|
|
53
|
+
};
|
|
54
|
+
})), b;
|
|
55
|
+
//#endregion
|
|
56
|
+
n((() => {
|
|
57
|
+
d(), i(), _(), y(), b = (e, n, i) => {
|
|
58
|
+
let c = r(e.template);
|
|
59
|
+
if (c.length === 0) return {
|
|
60
|
+
templates: [],
|
|
61
|
+
usedBuildInTemplate: !1
|
|
62
|
+
};
|
|
63
|
+
let d = u(), f = [], p = !1, m = {};
|
|
64
|
+
e.addHashInFontUrl && (m = { hash: n.hash });
|
|
65
|
+
let h = n.glyphsData?.map((e) => e.metadata).filter((e) => e !== void 0) ?? [], _ = o.all([
|
|
66
|
+
{ glyphs: h },
|
|
67
|
+
e,
|
|
68
|
+
{
|
|
69
|
+
cacheString: e.templateCacheString || Date.now(),
|
|
70
|
+
className: e.templateClassName || e.fontName,
|
|
71
|
+
fontFamily: e.templateFontName || e.fontName,
|
|
72
|
+
fontPath: e.templateFontPath.replace(/\/?$/u, "/"),
|
|
73
|
+
svgFontId: e.fontId || e.fontName
|
|
74
|
+
},
|
|
75
|
+
m,
|
|
76
|
+
{ fonts: Object.fromEntries(new Map(i.map((e) => [e, () => v(e, n)]))) },
|
|
77
|
+
{ unicodeRange: g(e.unicodeRange, h) },
|
|
78
|
+
{ templateFontLigatures: e.templateFontLigatures !== !1 }
|
|
79
|
+
]);
|
|
80
|
+
for (let e of c) {
|
|
81
|
+
let n, r;
|
|
82
|
+
if (Object.keys(d).includes(e)) {
|
|
83
|
+
p = !0, r = e;
|
|
84
|
+
let i = a.resolve(t, "../..");
|
|
85
|
+
s.configure(i), n = l(e);
|
|
86
|
+
} else {
|
|
87
|
+
let t = a.resolve(e);
|
|
88
|
+
s.configure(a.dirname(t)), n = a.resolve(t);
|
|
89
|
+
}
|
|
90
|
+
f.push({
|
|
91
|
+
template: e,
|
|
92
|
+
content: s.render(n, _),
|
|
93
|
+
builtIn: r
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
templates: f,
|
|
98
|
+
usedBuildInTemplate: p
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
}))();
|
|
102
|
+
export { b as renderTemplates };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { webfont } from './standalone/index.mjs';
|
|
2
|
+
export { diagnoseGlyphsData, diagnoseSvgContents } from './lib/svgDiagnostics/diagnoseSvgContents.mjs';
|
|
3
|
+
export { webfont } from './standalone/index.mjs';
|
|
4
|
+
export type { SvgDiagnosticCode, SvgGlyphDiagnostic, SvgToolsOptions } from './types/SvgToolsOptions.mjs';
|
|
5
|
+
export default webfont;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ExecException } from 'child_process';
|
|
2
|
+
export type Output = {
|
|
3
|
+
code?: number;
|
|
4
|
+
error: ExecException | null;
|
|
5
|
+
files: string[];
|
|
6
|
+
stderr?: string;
|
|
7
|
+
stdout?: string;
|
|
8
|
+
};
|
|
9
|
+
export type ExecCLI = (_args?: string, _destination?: string) => Promise<Output>;
|
|
10
|
+
/**
|
|
11
|
+
* @name execCLI
|
|
12
|
+
* @description Execute webfont CLI commands using child_process.
|
|
13
|
+
*
|
|
14
|
+
* @param {String} args - Arguments to pass to the CLI.
|
|
15
|
+
* @param {String} destination - Path to read/write files
|
|
16
|
+
* @return {Promise.<Object>} - Contains CLI error, stdout, stderr data.
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* execCLI("--help").then((output) => {
|
|
20
|
+
* console.log(output.stdout) // => Outputs usage information.
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
export declare const execCLI: ExecCLI;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const isHttpUrl: (value: string) => boolean;
|
|
2
|
+
export declare const getInputExtension: (source: string) => string;
|
|
3
|
+
export declare const getWebfontSourceBasename: (source: string) => string;
|
|
4
|
+
export declare const resolveDecompressedFontBasenames: (sources: readonly string[]) => string[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Glyph count above which OpenType ligatures often hurt browser layout (Firefox / DirectWrite). */
|
|
2
|
+
export declare const LARGE_FONT_LIGATURE_GLYPH_THRESHOLD = 2000;
|
|
3
|
+
export declare const shouldWarnLargeFontLigatures: (glyphCount: number, ligaturesEnabled: boolean) => boolean;
|
|
4
|
+
export declare const formatLargeFontLigatureWarning: (glyphCount: number) => string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Config } from 'svgo';
|
|
2
|
+
/** Conservative SVGO preset: cleanup cruft without rewriting paths or removing viewBox. */
|
|
3
|
+
export declare const defaultWebfontSvgoConfig: () => Config;
|
|
4
|
+
export declare const optimizeSvgContents: (contents: string, srcPath: string, config?: Config) => string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Format, Formats } from '../types/Format.mjs';
|
|
2
|
+
export declare const assertValidFormat: (value: unknown) => Format;
|
|
3
|
+
export declare const parseFormatsList: (values: readonly unknown[]) => Formats;
|
|
4
|
+
export declare const assertFormatsOption: (formats: unknown) => Formats;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SvgGlyphDiagnostic } from '../../types/SvgToolsOptions.mjs';
|
|
2
|
+
export declare const hasStrokeOnlySvg: (svgContents: string) => boolean;
|
|
3
|
+
export declare const hasUnsupportedSvgElements: (svgContents: string) => boolean;
|
|
4
|
+
export declare const hasUseReference: (svgContents: string) => boolean;
|
|
5
|
+
export declare const diagnoseSvgContents: (srcPath: string, svgContents: string) => SvgGlyphDiagnostic[];
|
|
6
|
+
export declare const diagnoseGlyphsData: (glyphs: ReadonlyArray<{
|
|
7
|
+
contents: string;
|
|
8
|
+
srcPath: string;
|
|
9
|
+
}>) => SvgGlyphDiagnostic[];
|
|
10
|
+
export declare const shouldLogDiagnostic: (diagnostic: SvgGlyphDiagnostic, options: {
|
|
11
|
+
diagnose?: boolean;
|
|
12
|
+
verbose?: boolean;
|
|
13
|
+
}) => boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SvgGlyphDiagnostic } from '../../types/SvgToolsOptions';
|
|
2
2
|
export declare const hasStrokeOnlySvg: (svgContents: string) => boolean;
|
|
3
3
|
export declare const hasUnsupportedSvgElements: (svgContents: string) => boolean;
|
|
4
|
+
export declare const hasUseReference: (svgContents: string) => boolean;
|
|
4
5
|
export declare const diagnoseSvgContents: (srcPath: string, svgContents: string) => SvgGlyphDiagnostic[];
|
|
5
6
|
export declare const diagnoseGlyphsData: (glyphs: ReadonlyArray<{
|
|
6
7
|
contents: string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GlyphData } from '../../types/GlyphData.mjs';
|
|
2
|
+
export declare const findEmptySvgFontGlyphNames: (svgFont: string) => string[];
|
|
3
|
+
export declare const assertNonEmptySvgFontGlyphs: (svgFont: string, glyphsData: ReadonlyArray<Pick<GlyphData, "metadata" | "srcPath">>) => void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GlyphData } from '../../types/GlyphData.mjs';
|
|
2
|
+
import { SvgGlyphDiagnostic } from '../../types/SvgToolsOptions.mjs';
|
|
3
|
+
export type SvgToolsReporter = (message: string) => void;
|
|
4
|
+
export type ApplySvgDiagnosticsResult = {
|
|
5
|
+
diagnostics: SvgGlyphDiagnostic[];
|
|
6
|
+
glyphs: GlyphData[];
|
|
7
|
+
};
|
|
8
|
+
export declare const applySvgDiagnosticsToGlyphs: (glyphsData: GlyphData[], svgToolsInput: {
|
|
9
|
+
diagnose?: boolean;
|
|
10
|
+
} | undefined, runtime?: {
|
|
11
|
+
reporter?: SvgToolsReporter;
|
|
12
|
+
verbose?: boolean;
|
|
13
|
+
}) => ApplySvgDiagnosticsResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GlyphData } from '../../types/GlyphData.mjs';
|
|
2
|
+
import { SvgGlyphDiagnostic, SvgToolsOptions } from '../../types/SvgToolsOptions.mjs';
|
|
3
|
+
import { SvgToolsReporter } from './applySvgDiagnostics.mjs';
|
|
4
|
+
export type { SvgToolsReporter } from './applySvgDiagnostics.mjs';
|
|
5
|
+
export type ApplySvgToolsResult = {
|
|
6
|
+
diagnostics: SvgGlyphDiagnostic[];
|
|
7
|
+
glyphs: GlyphData[];
|
|
8
|
+
};
|
|
9
|
+
export type ApplySvgToolsRuntime = {
|
|
10
|
+
reporter?: SvgToolsReporter;
|
|
11
|
+
/** When true, logs evenodd diagnostics even if svgTools.diagnose is off (backward compatible with --verbose). */
|
|
12
|
+
verbose?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const applySvgToolsToGlyphs: (glyphsData: GlyphData[], svgToolsInput: SvgToolsOptions | undefined, runtime?: ApplySvgToolsRuntime) => ApplySvgToolsResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SVGIcons2SVGFontStreamOptions, fileSorter, getMetadataService, SVGIcons2SVGFontStream } from 'svgicons2svgfont';
|
|
2
|
+
import { WebfontOptions } from '../../types/index.mjs';
|
|
3
|
+
export { fileSorter, getMetadataService, SVGIcons2SVGFontStream };
|
|
4
|
+
type MetadataServiceOptions = {
|
|
5
|
+
prependUnicode: boolean;
|
|
6
|
+
startUnicode: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const getMetadataServiceOptions: (options: WebfontOptions) => MetadataServiceOptions;
|
|
9
|
+
/**
|
|
10
|
+
* Coerce `round` for svgicons2svgfont; accepts number or numeric string (CLI/config).
|
|
11
|
+
* Returns undefined for undefined/null/empty/non-numeric/non-finite inputs.
|
|
12
|
+
*/
|
|
13
|
+
export declare const normalizeRoundOption: (round: string | number | null | undefined) => number | undefined;
|
|
14
|
+
export declare const getFontStreamOptions: (options: WebfontOptions) => Partial<SVGIcons2SVGFontStreamOptions>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MetadataProvider } from '../../types/MetadataProvider.mjs';
|
|
2
|
+
type MetadataServiceOptions = {
|
|
3
|
+
prependUnicode: boolean;
|
|
4
|
+
startUnicode: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Browser-safe metadata lookup from a virtual `srcPath` (no `fs`, no file rename).
|
|
8
|
+
* Mirrors {@link https://github.com/nfroidure/svgicons2svgfont | svgicons2svgfont} filename rules.
|
|
9
|
+
*/
|
|
10
|
+
export declare const createMetadataFromSrcPathService: (options?: Partial<MetadataServiceOptions>) => MetadataProvider;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GlyphMetadata } from '../types/GlyphMetadata.mjs';
|
|
2
|
+
export declare const collectCodePointsFromGlyphs: (glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => number[];
|
|
3
|
+
export declare const computeUnicodeRangeFromGlyphs: (glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => string | undefined;
|
|
4
|
+
export declare const resolveTemplateUnicodeRange: (unicodeRange: boolean | string | undefined, glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fetchWebfontFromUrl: (url: string) => Promise<Buffer>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { cosmiconfig } from 'cosmiconfig';
|
|
2
|
+
import { InitialOptions } from '../types/index.mjs';
|
|
3
|
+
import { Result } from '../types/Result.mjs';
|
|
4
|
+
type CosmiconfigLoaded = NonNullable<Awaited<ReturnType<ReturnType<typeof cosmiconfig>["search"]>>>;
|
|
5
|
+
export declare const loadWebfontConfig: (options: {
|
|
6
|
+
configFile?: string;
|
|
7
|
+
}) => Promise<CosmiconfigLoaded | Record<string, never>>;
|
|
8
|
+
type Webfont = (_initialOptions?: InitialOptions) => Promise<Result>;
|
|
9
|
+
export declare const webfont: Webfont;
|
|
10
|
+
export default webfont;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Format } from '../types/Format.mjs';
|
|
2
|
+
export type InputMode = "empty" | "mixed" | "svg" | "ttf" | "webfont";
|
|
3
|
+
export declare const classifyInputFiles: (filePaths: readonly string[]) => InputMode;
|
|
4
|
+
export declare const assertSvgPipelineFormats: (formats: readonly Format[]) => void;
|
|
5
|
+
export declare const filterInputFilesByMode: (filePaths: readonly string[], mode: InputMode) => string[];
|
|
6
|
+
export type ConversionFormat = "otf" | "ttf";
|
|
7
|
+
export type TtfEncodeFormat = "eot" | "ttf" | "woff" | "woff2";
|
|
8
|
+
export declare const resolveTtfConversionFormats: (formats: readonly Format[]) => TtfEncodeFormat[];
|
|
9
|
+
export declare const resolveWebfontConversionFormats: (formats: readonly Format[]) => ConversionFormat[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Format } from '../types/Format.mjs';
|
|
2
|
+
import { RenderedTemplate } from '../types/RenderedTemplate.mjs';
|
|
3
|
+
import { Result } from '../types/Result.mjs';
|
|
4
|
+
import { WebfontOptions } from '../types/WebfontOptions.mjs';
|
|
5
|
+
type RenderTemplatesResult = {
|
|
6
|
+
templates: RenderedTemplate[];
|
|
7
|
+
usedBuildInTemplate: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const renderTemplates: (options: WebfontOptions, result: Pick<Result, "glyphsData" | "hash"> & Partial<Result>, formats: readonly Format[]) => RenderTemplatesResult;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WebfontOptions } from '../types/WebfontOptions.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Runtime validation for merged webfont options (API, cosmiconfig, CLI).
|
|
4
|
+
* Rejects mis-typed or unknown format names before running a pipeline (#133).
|
|
5
|
+
*/
|
|
6
|
+
export declare const validateWebfontOptions: (options: WebfontOptions) => WebfontOptions;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Format = "eot" | "otf" | "woff" | "woff2" | "svg" | "ttf";
|
|
2
|
+
export type Formats = Array<Format>;
|
|
3
|
+
type FormatOption = {
|
|
4
|
+
copyright?: string | null;
|
|
5
|
+
description?: string | null;
|
|
6
|
+
ts?: number | null;
|
|
7
|
+
url?: string | null;
|
|
8
|
+
version?: string | null;
|
|
9
|
+
};
|
|
10
|
+
export type FormatsOptions = Partial<Record<Format, FormatOption>>;
|
|
11
|
+
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export type Format = "eot" | "otf" | "woff" | "woff2" | "svg" | "ttf";
|
|
2
2
|
export type Formats = Array<Format>;
|
|
3
3
|
type FormatOption = {
|
|
4
|
-
copyright
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
copyright?: string | null;
|
|
5
|
+
description?: string | null;
|
|
6
|
+
ts?: number | null;
|
|
7
|
+
url?: string | null;
|
|
8
|
+
version?: string | null;
|
|
7
9
|
};
|
|
8
10
|
export type FormatsOptions = Partial<Record<Format, FormatOption>>;
|
|
9
11
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GlyphContentTransformFn } from './GlyphContentTransformFn.mjs';
|
|
2
|
+
import { GlyphTransformFn } from './GlyphTransformFn.mjs';
|
|
3
|
+
import { MetadataProvider } from './MetadataProvider.mjs';
|
|
4
|
+
import { OptionsBase } from './OptionsBase.mjs';
|
|
5
|
+
import { TtfPostProcessFn } from './TtfPostProcessFn.mjs';
|
|
6
|
+
export type InitialOptions = OptionsBase & {
|
|
7
|
+
files: string | Array<string>;
|
|
8
|
+
glyphContentTransformFn?: GlyphContentTransformFn;
|
|
9
|
+
glyphTransformFn?: GlyphTransformFn;
|
|
10
|
+
metadataProvider?: MetadataProvider;
|
|
11
|
+
ttfPostProcess?: TtfPostProcessFn;
|
|
12
|
+
};
|
|
@@ -2,9 +2,11 @@ import { GlyphContentTransformFn } from './GlyphContentTransformFn';
|
|
|
2
2
|
import { GlyphTransformFn } from './GlyphTransformFn';
|
|
3
3
|
import { MetadataProvider } from './MetadataProvider';
|
|
4
4
|
import { OptionsBase } from './OptionsBase';
|
|
5
|
+
import { TtfPostProcessFn } from './TtfPostProcessFn';
|
|
5
6
|
export type InitialOptions = OptionsBase & {
|
|
6
7
|
files: string | Array<string>;
|
|
7
8
|
glyphContentTransformFn?: GlyphContentTransformFn;
|
|
8
9
|
glyphTransformFn?: GlyphTransformFn;
|
|
9
10
|
metadataProvider?: MetadataProvider;
|
|
11
|
+
ttfPostProcess?: TtfPostProcessFn;
|
|
10
12
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TemplateOption } from '../lib/parseTemplateOption.mjs';
|
|
2
|
+
import { Formats, FormatsOptions } from './Format.mjs';
|
|
3
|
+
import { SvgToolsOptions } from './SvgToolsOptions.mjs';
|
|
4
|
+
export type OptionsBase = {
|
|
5
|
+
configFile?: string;
|
|
6
|
+
dest?: string;
|
|
7
|
+
destCreate?: boolean;
|
|
8
|
+
fontName?: string | unknown;
|
|
9
|
+
formats?: Formats;
|
|
10
|
+
formatsOptions?: FormatsOptions;
|
|
11
|
+
template?: TemplateOption;
|
|
12
|
+
templateClassName?: string | unknown;
|
|
13
|
+
templateFontPath?: string;
|
|
14
|
+
templateFontName?: string | unknown;
|
|
15
|
+
templateCacheString?: string | unknown;
|
|
16
|
+
destTemplate?: string | unknown;
|
|
17
|
+
verbose?: boolean;
|
|
18
|
+
fontId?: string | unknown;
|
|
19
|
+
fontStyle?: string | unknown;
|
|
20
|
+
fontWeight?: string | unknown;
|
|
21
|
+
fixedWidth?: string | unknown;
|
|
22
|
+
centerHorizontally?: boolean | unknown;
|
|
23
|
+
centerVertically?: boolean | unknown;
|
|
24
|
+
normalize?: boolean;
|
|
25
|
+
fontHeight?: string | unknown;
|
|
26
|
+
round?: string | number;
|
|
27
|
+
descent?: string | number;
|
|
28
|
+
ascent?: string;
|
|
29
|
+
startUnicode?: string | unknown;
|
|
30
|
+
prependUnicode?: boolean | unknown;
|
|
31
|
+
metadata?: unknown;
|
|
32
|
+
sort?: boolean;
|
|
33
|
+
ligatures?: boolean;
|
|
34
|
+
addHashInFontUrl?: boolean | unknown;
|
|
35
|
+
unicodeRange?: boolean | string | unknown;
|
|
36
|
+
optimizeSvg?: boolean | unknown;
|
|
37
|
+
svgoConfig?: unknown;
|
|
38
|
+
templateFontLigatures?: boolean | unknown;
|
|
39
|
+
/** Alpha. SVG diagnostics and optional pre-conversion fixes. */
|
|
40
|
+
svgTools?: SvgToolsOptions;
|
|
41
|
+
};
|