From c420a02f5569766ab2c021f41575a65c66973ab4 Mon Sep 17 00:00:00 2001 From: Rob Jones Date: Wed, 12 Jun 2024 15:40:38 -0600 Subject: [PATCH] cleanuper --- src/generate-custom-glyph-enums.ts | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) 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++) {