@hibi_10000/grunt-webfont 2.0.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 @@
1
+ {"version":3,"file":"fontforge.js","names":["wf.consolaLogger","err: unknown","wf.generatedFontFiles","warn: string[]","result: { file: string }"],"sources":["../../tasks/engines/fontforge.ts"],"sourcesContent":["/**\n * grunt-webfont: fontforge engine\n *\n * @requires fontforge, ttfautohint 1.00+ (optional), eotlitetool.py\n * @author Artem Sapegin (http://sapegin.me), Hibi_10000\n */\n\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport util from 'node:util';\nimport { exec, type ExecException } from 'node:child_process';\nimport temp from 'temp';\nimport chalk from 'chalk';\n\nimport * as wf from '../util/util.ts';\nimport type { OptionsInternal } from '../types.ts';\n\nexport default async (o: OptionsInternal): Promise<false | { fontName: string }> => {\n\tconst logger = o.logger || wf.consolaLogger;\n\n\t// Copy source files to temporary directory\n\ttemp.track();\n\tconst tempDir = temp.mkdirSync();\n\to.files.forEach((file) => {\n\t\tfs.writeFileSync(path.join(tempDir, o.rename(file)), fs.readFileSync(file));\n\t});\n\n\t// Run Fontforge\n\tconst args = [\n\t\t'fontforge',\n\t\t'-script',\n\t\t`\"${path.join(import.meta.dirname, '../../bin/fontforge/generate.py')}\"`,\n\t].join(' ');\n\n\tconst execPromise = util.promisify(exec);\n\tconst promise = execPromise(args, { maxBuffer: o.execMaxBuffer });\n\tconst proc = promise.child;\n\n\t// Send JSON with params\n\tif (!proc) throw new TypeError('process is null');\n\n\tproc.stderr.on('data', (data) => {\n\t\tlogger.log.verbose(data);\n\t});\n\tproc.stdout.on('data', (data) => {\n\t\tlogger.log.verbose(data);\n\t});\n\tproc.on('exit', (code, signal) => {\n\t\tif (code !== 0) {\n\t\t\tlogger.log.info( // cannot use error() because it will stop execution of callback of exec (which shows error message)\n\t\t\t\t\"fontforge process has unexpectedly closed.\\n\" +\n\t\t\t\t`1. Try to run grunt in verbose mode to see fontforge output: ${chalk.bold('grunt --verbose webfont')}.\\n` +\n\t\t\t\t`2. If stderr maxBuffer exceeded try to increase ${chalk.bold('execMaxBuffer')}, ` +\n\t\t\t\t`see ${chalk.underline('https://github.com/sapegin/grunt-webfont#execMaxBuffer')}. `\n\t\t\t);\n\t\t}\n\t});\n\n\tconst params = Object.assign(o, {\n\t\tinputDir: tempDir,\n\t});\n\tproc.stdin.write(JSON.stringify(params));\n\tproc.stdin.end();\n\n\tlet out;\n\ttry {\n\t\tout = (await promise).stdout;\n\t} catch (err: unknown) {\n\t\tif (err instanceof Error && (err as ExecException).code === 127) {\n\t\t\tlogger.log.error(`fontforge not found. Please install fontforge and all other requirements: ${chalk.underline('https://github.com/sapegin/grunt-webfont#installation')}`);\n\t\t\treturn false;\n\t\t}\n\t\tif (err instanceof Error) {\n\t\t\tlogger.log.error(err.message);\n\t\t\treturn false;\n\t\t}\n\t\tlogger.log.error(`probably an impossible error`);\n\n\t\t// Skip some fontforge output such as copyrights. Show warnings only when no font files was created\n\t\t// or in verbose mode.\n\t\tconst success = !!wf.generatedFontFiles(o);\n\t\tconst notError = /(Copyright|License |with many parts BSD |Executable based on sources from|Library based on sources from|Based on source from git)/;\n\t\t//const version = /(Executable based on sources from|Library based on sources from)/;\n\t\tconst lines = (err as string).split('\\n');\n\n\t\tconst warn: string[] = [];\n\t\tlines.forEach((line) => {\n\t\t\tif (!line.match(notError) && !success) {\n\t\t\t\twarn.push(line);\n\t\t\t} else {\n\t\t\t\tlogger.log.verbose(chalk.grey('fontforge: ') + line);\n\t\t\t}\n\t\t});\n\n\t\tif (warn.length) {\n\t\t\tlogger.log.error(warn.join('\\n'));\n\t\t\treturn false;\n\t\t}\n\t\tlogger.log.error(`impossible error: ${err}`);\n\t\treturn false;\n\t}\n\n\t// Trim fontforge result\n\tconst json = out.replace(/^[^{]+/, '').replace(/[^}]+$/, '');\n\n\t// Parse json\n\tlet result: { file: string };\n\ttry {\n\t\tresult = JSON.parse(json);\n\t} catch (e) {\n\t\tlogger.log.verbose(`Webfont did not receive a proper JSON result from Python script: ${e}`);\n\t\tlogger.log.error(\n\t\t\t'Something went wrong when running fontforge. Probably fontforge wasn’t installed correctly or one of your SVGs is too complicated for fontforge.\\n\\n' +\n\t\t\t`1. Try to run Grunt in verbose mode: ${chalk.bold('grunt --verbose webfont')} and see what fontforge says. Then search GitHub issues for the solution: ${chalk.underline('https://github.com/sapegin/grunt-webfont/issues')}.\\n\\n` +\n\t\t\t`2. Try to use “node” engine instead of “fontforge”: ${chalk.underline('https://github.com/sapegin/grunt-webfont#engine')}\\n\\n` +\n\t\t\t'3. To find “bad” icon try to remove SVGs one by one until error disappears. Then try to simplify this SVG in Sketch, Illustrator, etc.\\n\\n'\n\t\t);\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tfontName: path.basename(result.file)\n\t};\n};\n"],"mappings":";;;;;;;;;AAiBA,wBAAe,OAAO,MAA8D;CACnF,MAAM,SAAS,EAAE,UAAUA;AAG3B,MAAK,OAAO;CACZ,MAAM,UAAU,KAAK,WAAW;AAChC,GAAE,MAAM,SAAS,SAAS;AACzB,KAAG,cAAc,KAAK,KAAK,SAAS,EAAE,OAAO,KAAK,CAAC,EAAE,GAAG,aAAa,KAAK,CAAC;GAC1E;CAGF,MAAM,OAAO;EACZ;EACA;EACA,IAAI,KAAK,KAAK,OAAO,KAAK,SAAS,kCAAkC,CAAC;EACtE,CAAC,KAAK,IAAI;CAGX,MAAM,UADc,KAAK,UAAU,KAAK,CACZ,MAAM,EAAE,WAAW,EAAE,eAAe,CAAC;CACjE,MAAM,OAAO,QAAQ;AAGrB,KAAI,CAAC,KAAM,OAAM,IAAI,UAAU,kBAAkB;AAEjD,MAAK,OAAO,GAAG,SAAS,SAAS;AAChC,SAAO,IAAI,QAAQ,KAAK;GACvB;AACF,MAAK,OAAO,GAAG,SAAS,SAAS;AAChC,SAAO,IAAI,QAAQ,KAAK;GACvB;AACF,MAAK,GAAG,SAAS,MAAM,WAAW;AACjC,MAAI,SAAS,EACZ,QAAO,IAAI,KACV;+DACgE,MAAM,KAAK,0BAA0B,CAAC,qDACnD,MAAM,KAAK,gBAAgB,CAAC,QACxE,MAAM,UAAU,yDAAyD,CAAC,IACjF;GAED;CAEF,MAAM,SAAS,OAAO,OAAO,GAAG,EAC/B,UAAU,SACV,CAAC;AACF,MAAK,MAAM,MAAM,KAAK,UAAU,OAAO,CAAC;AACxC,MAAK,MAAM,KAAK;CAEhB,IAAI;AACJ,KAAI;AACH,SAAO,MAAM,SAAS;UACdC,KAAc;AACtB,MAAI,eAAe,SAAU,IAAsB,SAAS,KAAK;AAChE,UAAO,IAAI,MAAM,6EAA6E,MAAM,UAAU,wDAAwD,GAAG;AACzK,UAAO;;AAER,MAAI,eAAe,OAAO;AACzB,UAAO,IAAI,MAAM,IAAI,QAAQ;AAC7B,UAAO;;AAER,SAAO,IAAI,MAAM,+BAA+B;EAIhD,MAAM,UAAU,CAAC,CAACC,mBAAsB,EAAE;EAC1C,MAAM,WAAW;EAEjB,MAAM,QAAS,IAAe,MAAM,KAAK;EAEzC,MAAMC,OAAiB,EAAE;AACzB,QAAM,SAAS,SAAS;AACvB,OAAI,CAAC,KAAK,MAAM,SAAS,IAAI,CAAC,QAC7B,MAAK,KAAK,KAAK;OAEf,QAAO,IAAI,QAAQ,MAAM,KAAK,cAAc,GAAG,KAAK;IAEpD;AAEF,MAAI,KAAK,QAAQ;AAChB,UAAO,IAAI,MAAM,KAAK,KAAK,KAAK,CAAC;AACjC,UAAO;;AAER,SAAO,IAAI,MAAM,qBAAqB,MAAM;AAC5C,SAAO;;CAIR,MAAM,OAAO,IAAI,QAAQ,UAAU,GAAG,CAAC,QAAQ,UAAU,GAAG;CAG5D,IAAIC;AACJ,KAAI;AACH,WAAS,KAAK,MAAM,KAAK;UACjB,GAAG;AACX,SAAO,IAAI,QAAQ,oEAAoE,IAAI;AAC3F,SAAO,IAAI,MACV;;uCACwC,MAAM,KAAK,0BAA0B,CAAC,4EAA4E,MAAM,UAAU,kDAAkD,CAAC,2DACtK,MAAM,UAAU,kDAAkD,CAAC;;EAE1H;AACD,SAAO;;AAGR,QAAO,EACN,UAAU,KAAK,SAAS,OAAO,KAAK,EACpC"}
@@ -0,0 +1,164 @@
1
+ import { consolaLogger, getFontPath } from "../util/util.js";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import util from "node:util";
5
+ import { exec } from "node:child_process";
6
+ import temp from "temp";
7
+ import stream from "node:stream";
8
+ import { StringDecoder } from "node:string_decoder";
9
+ import { SVGIcons2SVGFontStream } from "svgicons2svgfont";
10
+ import svg2ttf from "svg2ttf";
11
+ import ttf2woff from "ttf2woff";
12
+ import ttf2eot from "ttf2eot";
13
+ import * as svgo from "svgo";
14
+ import which from "which";
15
+
16
+ //#region tasks/engines/node.ts
17
+ var node_default = async (o) => {
18
+ const logger = o.logger || consolaLogger;
19
+ const fonts = {};
20
+ const generators = {
21
+ svg: async () => {
22
+ let font = "";
23
+ const decoder = new StringDecoder("utf8");
24
+ const streams = svgFilesToStreams(o.files);
25
+ const fontStream = new SVGIcons2SVGFontStream({
26
+ fontName: o.fontFamilyName,
27
+ fontHeight: o.fontHeight,
28
+ descent: o.descent,
29
+ normalize: o.normalize,
30
+ round: o.round
31
+ });
32
+ fontStream.on("data", (chunk) => {
33
+ font += decoder.write(chunk);
34
+ });
35
+ await new Promise((resolve) => {
36
+ fontStream.on("end", () => {
37
+ fonts.svg = font;
38
+ resolve();
39
+ });
40
+ for (const s of streams) {
41
+ const svgStream = s.stream;
42
+ svgStream.metadata = {
43
+ unicode: [String.fromCodePoint(s.codepoint)],
44
+ name: s.name
45
+ };
46
+ fontStream.write(svgStream);
47
+ }
48
+ fontStream.end();
49
+ });
50
+ return font;
51
+ },
52
+ ttf: async () => {
53
+ const svgFont = await getFont("svg");
54
+ let font = svg2ttf(svgFont, {}).buffer;
55
+ const hintedFont = await autohintTtfFont(font);
56
+ if (hintedFont) font = hintedFont;
57
+ fonts.ttf = font;
58
+ return font;
59
+ },
60
+ woff: async () => {
61
+ const ttfFont = await getFont("ttf");
62
+ const font = ttf2woff(ttfFont, {});
63
+ fonts.woff = font;
64
+ return font;
65
+ },
66
+ woff2: async () => {},
67
+ eot: async () => {
68
+ const ttfFont = await getFont("ttf");
69
+ const font = ttf2eot(ttfFont);
70
+ fonts.eot = font;
71
+ return font;
72
+ }
73
+ };
74
+ const typesToGenerate = o.types.slice();
75
+ if (o.types.indexOf("woff2") !== -1 && o.types.indexOf("ttf") === -1) typesToGenerate.push("ttf");
76
+ try {
77
+ for (const type of typesToGenerate) {
78
+ if (type === "woff2") continue;
79
+ await createFontWriter(type);
80
+ }
81
+ } catch (e) {
82
+ return false;
83
+ }
84
+ async function getFont(type) {
85
+ if (fonts[type]) return fonts[type];
86
+ else return await generators[type]();
87
+ }
88
+ async function createFontWriter(type) {
89
+ const font = await getFont(type);
90
+ fs.writeFileSync(getFontPath(o, type), font);
91
+ }
92
+ function svgFilesToStreams(files) {
93
+ try {
94
+ return files.map((file) => {
95
+ function fileStreamed(name$1, stream$1) {
96
+ return {
97
+ codepoint: o.codepoints[name$1],
98
+ name: name$1,
99
+ stream: stream$1
100
+ };
101
+ }
102
+ function streamSVG(name$1, file$1) {
103
+ const stream$1 = fs.createReadStream(file$1);
104
+ return fileStreamed(name$1, stream$1);
105
+ }
106
+ function streamSVGO(name$1, file$1) {
107
+ const svg = fs.readFileSync(file$1, "utf8");
108
+ try {
109
+ const optimized = svgo.optimize(svg).data;
110
+ const strStream = stream.Readable.from(optimized);
111
+ return fileStreamed(name$1, strStream);
112
+ } catch (err) {
113
+ logger.log.error("Can’t simplify SVG file with SVGO.\n\n" + err);
114
+ throw err;
115
+ }
116
+ }
117
+ const idx = files.indexOf(file);
118
+ const name = o.glyphs[idx];
119
+ if (o.optimize === true) return streamSVGO(name, file);
120
+ else return streamSVG(name, file);
121
+ });
122
+ } catch (err) {
123
+ logger.log.error("Can’t stream SVG file.\n\n" + err);
124
+ throw err;
125
+ }
126
+ }
127
+ async function autohintTtfFont(font) {
128
+ if (!which.sync("ttfautohint", { nothrow: true })) {
129
+ logger.log.verbose("Hinting skipped, ttfautohint not found.");
130
+ return false;
131
+ }
132
+ temp.track();
133
+ const tempDir = temp.mkdirSync();
134
+ const originalFilepath = path.join(tempDir, "font.ttf");
135
+ const hintedFilepath = path.join(tempDir, "hinted.ttf");
136
+ if (!o.autoHint) return false;
137
+ fs.writeFileSync(originalFilepath, font);
138
+ const args = [
139
+ "ttfautohint",
140
+ "--symbol",
141
+ "--fallback-script=latn",
142
+ "--windows-compatibility",
143
+ "--no-info",
144
+ originalFilepath,
145
+ hintedFilepath
146
+ ].join(" ");
147
+ const execPromise = util.promisify(exec);
148
+ try {
149
+ await execPromise(args, { maxBuffer: o.execMaxBuffer });
150
+ } catch (err) {
151
+ if (err.code === 127) {
152
+ logger.log.verbose("Hinting skipped, ttfautohint not found.");
153
+ return false;
154
+ }
155
+ logger.log.error("Can’t run ttfautohint.\n\n" + err.message);
156
+ return false;
157
+ }
158
+ return fs.readFileSync(hintedFilepath);
159
+ }
160
+ };
161
+
162
+ //#endregion
163
+ export { node_default as default };
164
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","names":["wf.consolaLogger","fonts: { svg?: string, ttf?: Uint8Array, woff?: Uint8Array, eot?: Uint8Array }","wf.getFontPath","name","stream","file"],"sources":["../../tasks/engines/node.ts"],"sourcesContent":["/**\n * grunt-webfont: Node.js engine\n *\n * @requires ttfautohint 1.00+ (optional)\n * @author Artem Sapegin (http://sapegin.me), Hibi_10000\n */\n\nimport fs from 'node:fs';\nimport stream from 'node:stream';\nimport path from 'node:path';\nimport util from 'node:util';\nimport { exec } from 'node:child_process';\nimport { StringDecoder } from 'node:string_decoder';\nimport temp from 'temp';\nimport { SVGIcons2SVGFontStream } from 'svgicons2svgfont';\nimport svg2ttf from 'svg2ttf';\nimport ttf2woff from 'ttf2woff';\nimport ttf2eot from 'ttf2eot';\nimport * as svgo from 'svgo';\nimport which from 'which';\n\nimport * as wf from '../util/util.ts';\nimport type { OptionsInternal, ReadableStreamWithMetadata } from '../types.ts';\n\nexport default async (o: OptionsInternal): Promise<false> => {\n\tconst logger = o.logger || wf.consolaLogger;\n\n\t// @todo Ligatures\n\n\tconst fonts: { svg?: string, ttf?: Uint8Array, woff?: Uint8Array, eot?: Uint8Array } = {};\n\n\tconst generators = {\n\t\tsvg: async () => {\n\t\t\tlet font = '';\n\t\t\tconst decoder = new StringDecoder('utf8');\n\t\t\tconst streams = svgFilesToStreams(o.files);\n\t\t\tconst fontStream = new SVGIcons2SVGFontStream({\n\t\t\t\tfontName: o.fontFamilyName,\n\t\t\t\tfontHeight: o.fontHeight,\n\t\t\t\tdescent: o.descent,\n\t\t\t\tnormalize: o.normalize,\n\t\t\t\tround: o.round,\n\t\t\t});\n\t\t\tfontStream.on('data', (chunk) => {\n\t\t\t\tfont += decoder.write(chunk);\n\t\t\t});\n\t\t\tawait new Promise<void>((resolve) => {\n\t\t\t\tfontStream.on('end', () => {\n\t\t\t\t\tfonts.svg = font;\n\t\t\t\t\tresolve();\n\t\t\t\t});\n\t\t\t\tfor (const s of streams) {\n\t\t\t\t\tconst svgStream = s.stream as ReadableStreamWithMetadata;\n\t\t\t\t\tsvgStream.metadata = {\n\t\t\t\t\t\tunicode: [String.fromCodePoint(s.codepoint)],\n\t\t\t\t\t\tname: s.name,\n\t\t\t\t\t}\n\t\t\t\t\tfontStream.write(svgStream);\n\t\t\t\t}\n\t\t\t\tfontStream.end();\n\t\t\t});\n\t\t\treturn font;\n\t\t},\n\n\t\tttf: async () => {\n\t\t\tconst svgFont = await getFont('svg')\n\t\t\tlet font = svg2ttf(svgFont, {}).buffer;\n\t\t\tconst hintedFont = await autohintTtfFont(font)\n\t\t\t// ttfautohint is optional\n\t\t\tif (hintedFont) {\n\t\t\t\tfont = hintedFont;\n\t\t\t}\n\t\t\tfonts.ttf = font;\n\t\t\treturn font;\n\t\t},\n\n\t\twoff: async () => {\n\t\t\tconst ttfFont = await getFont('ttf')\n\t\t\tconst font = ttf2woff(ttfFont, {});\n\t\t\tfonts.woff = font;\n\t\t\treturn font;\n\t\t},\n\n\t\twoff2: async () => {\n\t\t\t// Will be converted from TTF later\n\t\t},\n\n\t\teot: async () => {\n\t\t\tconst ttfFont = await getFont('ttf')\n\t\t\tconst font = ttf2eot(ttfFont);\n\t\t\tfonts.eot = font;\n\t\t\treturn font;\n\t\t}\n\t};\n\n\t// Font types\n\tconst typesToGenerate = o.types.slice();\n\tif ((o.types.indexOf('woff2') !== -1) && (o.types.indexOf('ttf') === -1)) typesToGenerate.push('ttf');\n\ttry {\n\t\tfor (const type of typesToGenerate) {\n\t\t\tif (type === 'woff2') continue;\n\t\t\t//@ts-ignore\n\t\t\tawait createFontWriter(type);\n\t\t}\n\t} catch (e) {\n\t\treturn false;\n\t}\n\n\tasync function getFont(type: 'svg'): Promise<string>;\n\tasync function getFont(type: 'eot' | 'woff' | 'ttf'): Promise<Uint8Array>;\n\tasync function getFont(type: 'eot' | 'woff' | 'ttf' | 'svg'): Promise<string | Uint8Array>;\n\tasync function getFont(type: 'eot' | 'woff' | 'ttf' | 'svg') {\n\t\tif (fonts[type]) {\n\t\t\treturn fonts[type];\n\t\t} else {\n\t\t\treturn await generators[type]();\n\t\t}\n\t}\n\n\tasync function createFontWriter(type: 'eot' | 'woff' | 'ttf' | 'svg') {\n\t\tconst font = await getFont(type)\n\t\tfs.writeFileSync(wf.getFontPath(o, type), font);\n\t}\n\n\ttype Stream = { codepoint: number, name?: string, stream: NodeJS.ReadableStream };\n\tfunction svgFilesToStreams(files: string[]) {\n\t\ttry {\n\t\t\treturn files.map((file) => {\n\n\t\t\t\tfunction fileStreamed(name: string, stream: NodeJS.ReadableStream): Stream {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcodepoint: o.codepoints[name],\n\t\t\t\t\t\tname: name,\n\t\t\t\t\t\tstream: stream,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tfunction streamSVG(name: string, file: string) {\n\t\t\t\t\tconst stream = fs.createReadStream(file);\n\t\t\t\t\treturn fileStreamed(name, stream);\n\t\t\t\t}\n\n\t\t\t\tfunction streamSVGO(name: string, file: string) {\n\t\t\t\t\tconst svg = fs.readFileSync(file, 'utf8');\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst optimized = svgo.optimize(svg).data;\n\t\t\t\t\t\tconst strStream = stream.Readable.from(optimized);\n\t\t\t\t\t\treturn fileStreamed(name, strStream);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tlogger.log.error('Can’t simplify SVG file with SVGO.\\n\\n' + err);\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst idx = files.indexOf(file);\n\t\t\t\tconst name = o.glyphs[idx];\n\n\t\t\t\tif (o.optimize === true) {\n\t\t\t\t\treturn streamSVGO(name, file)\n\t\t\t\t} else {\n\t\t\t\t\treturn streamSVG(name, file);\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (err) {\n\t\t\tlogger.log.error('Can’t stream SVG file.\\n\\n' + err);\n\t\t\tthrow err;\n\t\t}\n\t}\n\n\tasync function autohintTtfFont(font: Uint8Array) {\n\t\tif (!which.sync('ttfautohint', { nothrow: true })) {\n\t\t\tlogger.log.verbose('Hinting skipped, ttfautohint not found.');\n\t\t\treturn false;\n\t\t}\n\n\t\ttemp.track();\n\t\tconst tempDir = temp.mkdirSync();\n\t\tconst originalFilepath = path.join(tempDir, 'font.ttf');\n\t\tconst hintedFilepath = path.join(tempDir, 'hinted.ttf');\n\n\t\tif (!o.autoHint){\n\t\t\treturn false;\n\t\t}\n\t\t// Save original font to temporary directory\n\t\tfs.writeFileSync(originalFilepath, font);\n\n\t\t// Run ttfautohint\n\t\tconst args = [\n\t\t\t'ttfautohint',\n\t\t\t'--symbol',\n\t\t\t'--fallback-script=latn',\n\t\t\t'--windows-compatibility',\n\t\t\t'--no-info',\n\t\t\toriginalFilepath,\n\t\t\thintedFilepath\n\t\t].join(' ');\n\n\t\tconst execPromise = util.promisify(exec);\n\t\ttry {\n\t\t\tawait execPromise(args, { maxBuffer: o.execMaxBuffer });\n\t\t} catch (err) {\n\t\t\tif (err.code === 127) {\n\t\t\t\tlogger.log.verbose('Hinting skipped, ttfautohint not found.');\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tlogger.log.error('Can’t run ttfautohint.\\n\\n' + err.message);\n\t\t\treturn false;\n\t\t}\n\t\tconst hintedFont = fs.readFileSync(hintedFilepath);\n\t\treturn hintedFont;\n\t}\n\n};\n"],"mappings":"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"}
@@ -0,0 +1,105 @@
1
+ //#region package.json
2
+ var name = "@hibi_10000/grunt-webfont";
3
+ var description = "Ultimate SVG to webfont converter for Grunt.";
4
+ var version = "2.0.1";
5
+ var homepage = "https://github.com/Hibi-10000/grunt-webfont";
6
+ var author = "Hibi_10000";
7
+ var contributors = [
8
+ "Artem Sapegin (http://sapegin.me/)",
9
+ "Maxime Thirouin (http://moox.io/)",
10
+ "Aaron Lampros (https://github.com/alampros)",
11
+ "Cyrille Meichel (https://github.com/landru29)"
12
+ ];
13
+ var repository = {
14
+ "type": "git",
15
+ "url": "git+https://github.com/Hibi-10000/grunt-webfont.git"
16
+ };
17
+ var bugs = { "url": "https://github.com/Hibi-10000/grunt-webfont/issues" };
18
+ var keywords = [
19
+ "gruntplugin",
20
+ "font",
21
+ "webfont",
22
+ "fontforge",
23
+ "font-face",
24
+ "woff",
25
+ "woff2",
26
+ "ttf",
27
+ "svg",
28
+ "eot",
29
+ "truetype",
30
+ "css",
31
+ "icon"
32
+ ];
33
+ var license = "MIT";
34
+ var main = "dist/webfont.js";
35
+ var type = "module";
36
+ var scripts = {
37
+ "build": "tsdown",
38
+ "test:node": "node --test ./test/webfont.test.ts",
39
+ "test:grunt": "pnpm build & grunt --stack"
40
+ };
41
+ var engines = {
42
+ "node": ">=22",
43
+ "pnpm": ">=10"
44
+ };
45
+ var dependencies = {
46
+ "chalk": "^5.6.2",
47
+ "consola": "^3.4.2",
48
+ "glob": "^11.0.3",
49
+ "lodash": "^4.17.21",
50
+ "temp": "^0.9.4",
51
+ "ttf2woff2": "^8.0.0"
52
+ };
53
+ var optionalDependencies = {
54
+ "svg2ttf": "^6.0.3",
55
+ "svgicons2svgfont": "~15.0.1",
56
+ "svgo": "^4.0.0",
57
+ "ttf2eot": "^3.1.0",
58
+ "ttf2woff": "^3.0.0",
59
+ "which": "^5.0.0"
60
+ };
61
+ var devDependencies = {
62
+ "@types/grunt": "^0.4.32",
63
+ "@types/lodash": "^4.17.20",
64
+ "@types/node": "^22.18.1",
65
+ "@types/nodeunit": "^0.0.36",
66
+ "@types/stylus": "^0.48.43",
67
+ "@types/svg2ttf": "^5.0.3",
68
+ "@types/temp": "^0.9.4",
69
+ "@types/which": "^3.0.4",
70
+ "@types/xml2js": "^0.4.14",
71
+ "grunt": "^1.6.1",
72
+ "grunt-cli": "^1.5.0",
73
+ "grunt-contrib-clean": "^2.0.1",
74
+ "grunt-contrib-nodeunit": "^5.0.0",
75
+ "load-grunt-tasks": "^5.1.0",
76
+ "stylus": "^0.64.0",
77
+ "tsdown": "^0.15.0",
78
+ "typescript": "^5.9.2",
79
+ "xml2js": "^0.6.2"
80
+ };
81
+ var peerDependencies = { "grunt": ">=0.4.0" };
82
+ var package_default = {
83
+ name,
84
+ description,
85
+ version,
86
+ homepage,
87
+ author,
88
+ contributors,
89
+ repository,
90
+ bugs,
91
+ keywords,
92
+ license,
93
+ main,
94
+ type,
95
+ scripts,
96
+ engines,
97
+ dependencies,
98
+ optionalDependencies,
99
+ devDependencies,
100
+ peerDependencies
101
+ };
102
+
103
+ //#endregion
104
+ export { package_default as default };
105
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"@hibi_10000/grunt-webfont\",\n \"description\": \"Ultimate SVG to webfont converter for Grunt.\",\n \"version\": \"2.0.1\",\n \"homepage\": \"https://github.com/Hibi-10000/grunt-webfont\",\n \"author\": \"Hibi_10000\",\n \"contributors\": [\n \"Artem Sapegin (http://sapegin.me/)\",\n \"Maxime Thirouin (http://moox.io/)\",\n \"Aaron Lampros (https://github.com/alampros)\",\n \"Cyrille Meichel (https://github.com/landru29)\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/Hibi-10000/grunt-webfont.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/Hibi-10000/grunt-webfont/issues\"\n },\n \"keywords\": [\n \"gruntplugin\",\n \"font\",\n \"webfont\",\n \"fontforge\",\n \"font-face\",\n \"woff\",\n \"woff2\",\n \"ttf\",\n \"svg\",\n \"eot\",\n \"truetype\",\n \"css\",\n \"icon\"\n ],\n \"license\": \"MIT\",\n \"main\": \"dist/webfont.js\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsdown\",\n \"test:node\": \"node --test ./test/webfont.test.ts\",\n \"test:grunt\": \"pnpm build & grunt --stack\"\n },\n \"engines\": {\n \"node\": \">=22\",\n \"pnpm\": \">=10\"\n },\n \"dependencies\": {\n \"chalk\": \"^5.6.2\",\n \"consola\": \"^3.4.2\",\n \"glob\": \"^11.0.3\",\n \"lodash\": \"^4.17.21\",\n \"temp\": \"^0.9.4\",\n \"ttf2woff2\": \"^8.0.0\"\n },\n \"optionalDependencies\": {\n \"svg2ttf\": \"^6.0.3\",\n \"svgicons2svgfont\": \"~15.0.1\",\n \"svgo\": \"^4.0.0\",\n \"ttf2eot\": \"^3.1.0\",\n \"ttf2woff\": \"^3.0.0\",\n \"which\": \"^5.0.0\"\n },\n \"devDependencies\": {\n \"@types/grunt\": \"^0.4.32\",\n \"@types/lodash\": \"^4.17.20\",\n \"@types/node\": \"^22.18.1\",\n \"@types/nodeunit\": \"^0.0.36\",\n \"@types/stylus\": \"^0.48.43\",\n \"@types/svg2ttf\": \"^5.0.3\",\n \"@types/temp\": \"^0.9.4\",\n \"@types/which\": \"^3.0.4\",\n \"@types/xml2js\": \"^0.4.14\",\n \"grunt\": \"^1.6.1\",\n \"grunt-cli\": \"^1.5.0\",\n \"grunt-contrib-clean\": \"^2.0.1\",\n \"grunt-contrib-nodeunit\": \"^5.0.0\",\n \"load-grunt-tasks\": \"^5.1.0\",\n \"stylus\": \"^0.64.0\",\n \"tsdown\": \"^0.15.0\",\n \"typescript\": \"^5.9.2\",\n \"xml2js\": \"^0.6.2\"\n },\n \"peerDependencies\": {\n \"grunt\": \">=0.4.0\"\n }\n}\n"],"mappings":";WACU;kBACO;cACJ;eACC;aACF;mBACM;CACd;CACA;CACA;CACA;CACD;iBACa;CACZ,QAAQ;CACR,OAAO;CACR;WACO,EACN,OAAO,sDACR;eACW;CACV;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;cACU;WACH;WACA;cACG;CACT,SAAS;CACT,aAAa;CACb,cAAc;CACf;cACU;CACT,QAAQ;CACR,QAAQ;CACT;mBACe;CACd,SAAS;CACT,WAAW;CACX,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,aAAa;CACd;2BACuB;CACtB,WAAW;CACX,oBAAoB;CACpB,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,SAAS;CACV;sBACkB;CACjB,gBAAgB;CAChB,iBAAiB;CACjB,eAAe;CACf,mBAAmB;CACnB,iBAAiB;CACjB,kBAAkB;CAClB,eAAe;CACf,gBAAgB;CAChB,iBAAiB;CACjB,SAAS;CACT,aAAa;CACb,uBAAuB;CACvB,0BAA0B;CAC1B,oBAAoB;CACpB,UAAU;CACV,UAAU;CACV,cAAc;CACd,UAAU;CACX;uBACmB,EAClB,SAAS,WACV;sBApFH;;;;;;;;;;;;;;;;;;;CAqFC"}
@@ -0,0 +1,158 @@
1
+ //#region tasks/types.d.ts
2
+ interface Logger {
3
+ log: {
4
+ error: (...args: any[]) => void;
5
+ warn: (...args: any[]) => void;
6
+ info: (...args: any[]) => void;
7
+ verbose: (...args: any[]) => void;
8
+ };
9
+ fail: {
10
+ fatal: (...args: any[]) => void;
11
+ warn?: (...args: any[]) => void;
12
+ };
13
+ }
14
+ interface CustomOutput {
15
+ template: string;
16
+ dest: string;
17
+ syntax?: string;
18
+ context?: Partial<Context>;
19
+ }
20
+ interface TemplateOptions {
21
+ baseClass?: string;
22
+ classPrefix?: string;
23
+ }
24
+ interface Config {
25
+ src: string;
26
+ dest?: string;
27
+ destCss?: string;
28
+ destScss?: string;
29
+ destSass?: string;
30
+ destLess?: string;
31
+ destStyl?: string;
32
+ options?: Options;
33
+ }
34
+ interface Options {
35
+ font?: string;
36
+ destCss?: string;
37
+ destScss?: string;
38
+ destSass?: string;
39
+ destLess?: string;
40
+ destStyl?: string;
41
+ dest?: string;
42
+ relativeFontPath?: string;
43
+ fontPathVariables?: boolean;
44
+ hashes?: boolean;
45
+ ligatures?: boolean;
46
+ template?: string;
47
+ syntax?: string;
48
+ templateOptions?: TemplateOptions;
49
+ stylesheets?: string[];
50
+ stylesheet?: string;
51
+ htmlDemo?: boolean;
52
+ htmlDemoTemplate?: string;
53
+ htmlDemoFilename?: string;
54
+ styles?: string;
55
+ types?: string;
56
+ order?: string;
57
+ embed?: boolean | string;
58
+ rename?: (path: string, suffix?: string) => string;
59
+ engine?: "fontforge" | "node";
60
+ autoHint?: boolean;
61
+ codepoints?: {
62
+ [key: string]: number;
63
+ };
64
+ codepointsFile?: string;
65
+ startCodepoint?: number;
66
+ ie7?: boolean;
67
+ normalize?: boolean;
68
+ optimize?: boolean;
69
+ round?: number;
70
+ fontHeight?: number;
71
+ descent?: number;
72
+ version?: string | boolean;
73
+ cache?: string;
74
+ callback?: (filename: string, types: string[], glyphs: string[], hash: string) => void;
75
+ customOutputs?: CustomOutput[];
76
+ execMaxBuffer?: number;
77
+ destHtml?: string;
78
+ fontFilename?: string;
79
+ fontFamilyName?: string;
80
+ skip?: boolean;
81
+ }
82
+ interface OptionsInternal extends TemplateOptions {
83
+ logger: Logger;
84
+ fontBaseName: string;
85
+ destCss: string;
86
+ destScss: string;
87
+ destSass: string;
88
+ destLess: string;
89
+ destStyl: string;
90
+ dest: string;
91
+ relativeFontPath: string;
92
+ fontPathVariables: boolean;
93
+ addHashes: boolean;
94
+ addLigatures: boolean;
95
+ template: string;
96
+ syntax: string;
97
+ templateOptions: TemplateOptions;
98
+ stylesheets: string[];
99
+ htmlDemo: boolean;
100
+ htmlDemoTemplate: string;
101
+ htmlDemoFilename: string;
102
+ styles: string[] | string;
103
+ types: string[];
104
+ order: string[];
105
+ embed: string[];
106
+ rename: (path: string, suffix?: string) => string;
107
+ engine: "fontforge" | "node";
108
+ autoHint: boolean;
109
+ codepoints: {
110
+ [key: string]: number;
111
+ };
112
+ codepointsFile: string;
113
+ startCodepoint: number;
114
+ ie7: boolean;
115
+ normalize: boolean;
116
+ optimize: boolean;
117
+ round: number;
118
+ fontHeight: number;
119
+ descent: number;
120
+ version: string | boolean;
121
+ cache: string;
122
+ callback: (filename: string, types: string[], glyphs: string[], hash: string) => void;
123
+ customOutputs: CustomOutput[];
124
+ execMaxBuffer: number;
125
+ fontName?: string;
126
+ destCssPaths?: {
127
+ css: string;
128
+ scss: string;
129
+ sass: string;
130
+ less: string;
131
+ styl: string;
132
+ };
133
+ destHtml?: string;
134
+ fontfaceStyles?: boolean;
135
+ baseStyles?: boolean;
136
+ extraStyles?: boolean;
137
+ files?: string[];
138
+ glyphs?: string[];
139
+ hash?: string;
140
+ fontFilename?: string;
141
+ fontFamilyName?: string;
142
+ fontSrc1?: string;
143
+ fontSrc2?: string;
144
+ fontRawSrcs?: string[][];
145
+ cssTemplate?: {
146
+ filename: string;
147
+ template: string;
148
+ };
149
+ fontPathVariable?: string;
150
+ }
151
+ interface Context extends OptionsInternal {
152
+ testHeading?: string;
153
+ stylesheet?: string;
154
+ iconsStyles?: true;
155
+ }
156
+ //#endregion
157
+ export { Config, Logger, Options };
158
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,105 @@
1
+ import path from "node:path";
2
+ import { globSync } from "glob";
3
+ import { consola } from "consola";
4
+
5
+ //#region tasks/util/util.ts
6
+ const consolaLogger = {
7
+ log: {
8
+ error: consola.error.raw,
9
+ warn: consola.warn.raw,
10
+ info: consola.info.raw,
11
+ verbose: consola.verbose.raw
12
+ },
13
+ fail: { fatal: (...args) => {
14
+ consola.fatal.raw(...args);
15
+ process.exit(1);
16
+ } }
17
+ };
18
+ /**
19
+ * Unicode Private Use Area start.
20
+ * http://en.wikipedia.org/wiki/Private_Use_(Unicode)
21
+ */
22
+ const UNICODE_PUA_START = 61697;
23
+ /**
24
+ * @font-face’s src values generation rules.
25
+ */
26
+ const fontsSrcsMap = {
27
+ eot: {
28
+ 0: { ext: ".eot" },
29
+ 1: {
30
+ ext: ".eot?#iefix",
31
+ format: "embedded-opentype"
32
+ }
33
+ },
34
+ woff: {
35
+ 0: false,
36
+ 1: {
37
+ ext: ".woff",
38
+ format: "woff",
39
+ embeddable: true
40
+ }
41
+ },
42
+ woff2: {
43
+ 0: false,
44
+ 1: {
45
+ ext: ".woff2",
46
+ format: "woff2",
47
+ embeddable: true
48
+ }
49
+ },
50
+ ttf: {
51
+ 0: false,
52
+ 1: {
53
+ ext: ".ttf",
54
+ format: "truetype",
55
+ embeddable: true
56
+ }
57
+ },
58
+ svg: {
59
+ 0: false,
60
+ 1: {
61
+ ext: ".svg#{fontBaseName}",
62
+ format: "svg"
63
+ }
64
+ }
65
+ };
66
+ /**
67
+ * CSS fileaname prefixes: _icons.scss.
68
+ */
69
+ const cssFilePrefixes = {
70
+ _default: "",
71
+ sass: "_",
72
+ scss: "_"
73
+ };
74
+ /**
75
+ * @font-face’s src parts seperators.
76
+ */
77
+ const fontSrcSeparators = {
78
+ _default: ",\n ",
79
+ styl: ", "
80
+ };
81
+ /**
82
+ * List of available font formats.
83
+ */
84
+ const fontFormats = "eot,woff2,woff,ttf,svg";
85
+ /**
86
+ * Returns list of all generated font files.
87
+ *
88
+ * @param o Options.
89
+ */
90
+ const generatedFontFiles = (o) => {
91
+ return globSync(path.posix.join(o.dest, `${o.fontFilename}*.{${o.types}}`));
92
+ };
93
+ /**
94
+ * Returns path to font of specified format.
95
+ *
96
+ * @param o Options.
97
+ * @param type Font type (see `wf.fontFormats`).
98
+ */
99
+ const getFontPath = (o, type) => {
100
+ return path.join(o.dest, `${o.fontFilename}.${type}`);
101
+ };
102
+
103
+ //#endregion
104
+ export { UNICODE_PUA_START, consolaLogger, cssFilePrefixes, fontFormats, fontSrcSeparators, fontsSrcsMap, generatedFontFiles, getFontPath };
105
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","names":["consolaLogger: Logger"],"sources":["../../tasks/util/util.ts"],"sourcesContent":["/**\n * grunt-webfont: common stuff\n *\n * @author Artem Sapegin (http://sapegin.me), Hibi_10000\n */\n\nimport path from 'node:path';\nimport { globSync } from 'glob';\nimport { consola } from 'consola';\n\nimport type { Logger, OptionsInternal } from '../types.ts';\n\nexport const consolaLogger: Logger = {\n\tlog: {\n\t\terror: consola.error.raw,\n\t\twarn: consola.warn.raw,\n\t\tinfo: consola.info.raw,\n\t\tverbose: consola.verbose.raw,\n\t},\n\tfail: {\n\t\tfatal: (...args) => {\n\t\t\tconsola.fatal.raw(...args);\n\t\t\tprocess.exit(1);\n\t\t}\n\t},\n}\n\n/**\n * Unicode Private Use Area start.\n * http://en.wikipedia.org/wiki/Private_Use_(Unicode)\n */\nexport const UNICODE_PUA_START = 0xF101;\n\n/**\n * @font-face’s src values generation rules.\n */\nexport const fontsSrcsMap = {\n\teot: {\n\t\t0: {\n\t\t\text: '.eot',\n\t\t},\n\t\t1: {\n\t\t\text: '.eot?#iefix',\n\t\t\tformat: 'embedded-opentype',\n\t\t},\n\t},\n\twoff: {\n\t\t0: false as false,\n\t\t1: {\n\t\t\text: '.woff',\n\t\t\tformat: 'woff',\n\t\t\tembeddable: true,\n\t\t},\n\t},\n\twoff2: {\n\t\t0: false as false,\n\t\t1: {\n\t\t\text: '.woff2',\n\t\t\tformat: 'woff2',\n\t\t\tembeddable: true,\n\t\t},\n\t},\n\tttf: {\n\t\t0: false as false,\n\t\t1: {\n\t\t\text: '.ttf',\n\t\t\tformat: 'truetype',\n\t\t\tembeddable: true,\n\t\t},\n\t},\n\tsvg: {\n\t\t0: false as false,\n\t\t1: {\n\t\t\text: '.svg#{fontBaseName}',\n\t\t\tformat: 'svg',\n\t\t},\n\t},\n};\n\n/**\n * CSS fileaname prefixes: _icons.scss.\n */\nexport const cssFilePrefixes = {\n\t_default: '',\n\tsass: '_',\n\tscss: '_'\n};\n\n/**\n * @font-face’s src parts seperators.\n */\nexport const fontSrcSeparators = {\n\t_default: ',\\n\\t\\t',\n\tstyl: ', '\n};\n\n/**\n * List of available font formats.\n */\nexport const fontFormats = 'eot,woff2,woff,ttf,svg';\n\n/**\n * Returns list of all generated font files.\n *\n * @param o Options.\n */\nexport const generatedFontFiles = (o: OptionsInternal): string[] => {\n\treturn globSync(path.posix.join(o.dest, `${o.fontFilename}*.{${o.types}}`));\n};\n\n/**\n * Returns path to font of specified format.\n *\n * @param o Options.\n * @param type Font type (see `wf.fontFormats`).\n */\nexport const getFontPath = (o: OptionsInternal, type: string): string => {\n\treturn path.join(o.dest, `${o.fontFilename}.${type}`);\n};\n"],"mappings":";;;;;AAYA,MAAaA,gBAAwB;CACpC,KAAK;EACJ,OAAO,QAAQ,MAAM;EACrB,MAAM,QAAQ,KAAK;EACnB,MAAM,QAAQ,KAAK;EACnB,SAAS,QAAQ,QAAQ;EACzB;CACD,MAAM,EACL,QAAQ,GAAG,SAAS;AACnB,UAAQ,MAAM,IAAI,GAAG,KAAK;AAC1B,UAAQ,KAAK,EAAE;IAEhB;CACD;;;;;AAMD,MAAa,oBAAoB;;;;AAKjC,MAAa,eAAe;CAC3B,KAAK;EACJ,GAAG,EACF,KAAK,QACL;EACD,GAAG;GACF,KAAK;GACL,QAAQ;GACR;EACD;CACD,MAAM;EACL,GAAG;EACH,GAAG;GACF,KAAK;GACL,QAAQ;GACR,YAAY;GACZ;EACD;CACD,OAAO;EACN,GAAG;EACH,GAAG;GACF,KAAK;GACL,QAAQ;GACR,YAAY;GACZ;EACD;CACD,KAAK;EACJ,GAAG;EACH,GAAG;GACF,KAAK;GACL,QAAQ;GACR,YAAY;GACZ;EACD;CACD,KAAK;EACJ,GAAG;EACH,GAAG;GACF,KAAK;GACL,QAAQ;GACR;EACD;CACD;;;;AAKD,MAAa,kBAAkB;CAC9B,UAAU;CACV,MAAM;CACN,MAAM;CACN;;;;AAKD,MAAa,oBAAoB;CAChC,UAAU;CACV,MAAM;CACN;;;;AAKD,MAAa,cAAc;;;;;;AAO3B,MAAa,sBAAsB,MAAiC;AACnE,QAAO,SAAS,KAAK,MAAM,KAAK,EAAE,MAAM,GAAG,EAAE,aAAa,KAAK,EAAE,MAAM,GAAG,CAAC;;;;;;;;AAS5E,MAAa,eAAe,GAAoB,SAAyB;AACxE,QAAO,KAAK,KAAK,EAAE,MAAM,GAAG,EAAE,aAAa,GAAG,OAAO"}
@@ -0,0 +1,8 @@
1
+ import { Config, Logger, Options } from "./types.js";
2
+
3
+ //#region tasks/webfont.d.ts
4
+ declare const _default: (grunt: IGrunt) => void;
5
+ declare const webfont: (name: string, target: string, filesSrc: string[], params: Config, options: Options, logger?: Logger) => Promise<void>;
6
+ //#endregion
7
+ export { _default as default, webfont };
8
+ //# sourceMappingURL=webfont.d.ts.map