diff --git a/src/generate-custom-glyph-enums.ts b/src/generate-custom-glyph-enums.ts index f1d36db4..e6f9d1a1 100644 --- a/src/generate-custom-glyph-enums.ts +++ b/src/generate-custom-glyph-enums.ts @@ -6,13 +6,11 @@ import ttf2woff2 from 'ttf2woff2'; import ttf2woff from 'ttf2woff'; import fse from 'fs-extra'; -const { writeFileSync, readFileSync, unlinkSync } = fse; +const { writeFileSync, unlinkSync } = fse; const acc: Record = {}; -const svgFile = './DIM-custom-font/DIM-Symbols.svg'; -const woffFile = svgFile.replace('svg', 'woff'); -const ttfFile = svgFile.replace('svg', 'ttf'); +const woffFile = './DIM-custom-font/DIM-Symbols.woff'; const woff2File = './output/DIMSymbols.woff2'; webfont({ @@ -26,19 +24,16 @@ webfont({ descent: '150', }) .then((result) => { - // Writes buffer into .svg font file for other conversions - writeFileSync(svgFile, result.svg!); // loadSync requires .otf or .woff filetype for enumeration - writeFileSync(ttfFile, svg2ttf(readFileSync(svgFile, 'utf8'), { ts: 0 }).buffer); - writeFileSync(woffFile, ttf2woff(readFileSync(ttfFile))); + const ttf = Buffer.from(svg2ttf(String(result.svg!), { ts: 0 }).buffer); + + writeFileSync(woffFile, ttf2woff(ttf)); // Generate font format to be used by DIM - writeFileSync(woff2File, ttf2woff2(readFileSync(ttfFile))); + writeFileSync(woff2File, ttf2woff2(ttf)); const font = loadSync(woffFile); - // no need to keep these temp files - unlinkSync(svgFile); - unlinkSync(ttfFile); + // no need to keep this temp file unlinkSync(woffFile); for (let i = 0; i < font.glyphs.length; i++) {