diff --git a/src/generate-custom-glyph-enums.ts b/src/generate-custom-glyph-enums.ts index e6f9d1a1..160ede91 100644 --- a/src/generate-custom-glyph-enums.ts +++ b/src/generate-custom-glyph-enums.ts @@ -1,17 +1,15 @@ import { loadSync } from 'opentype.js'; import { webfont } from 'webfont'; import { writeFile } from './helpers.js'; +import { infoLog } from './log.js'; import svg2ttf from 'svg2ttf'; import ttf2woff2 from 'ttf2woff2'; import ttf2woff from 'ttf2woff'; import fse from 'fs-extra'; const { writeFileSync, unlinkSync } = fse; - const acc: Record = {}; - -const woffFile = './DIM-custom-font/DIM-Symbols.woff'; -const woff2File = './output/DIMSymbols.woff2'; +const TAG = "CUSTOM-GLYPHS" webfont({ files: './DIM-custom-font/SVGs/', @@ -24,18 +22,18 @@ webfont({ descent: '150', }) .then((result) => { + const woffFile = './DIM-custom-font/DIM-Symbols.woff'; + const woff2File = './output/DIMSymbols.woff2' // loadSync requires .otf or .woff filetype for enumeration const ttf = Buffer.from(svg2ttf(String(result.svg!), { ts: 0 }).buffer); - writeFileSync(woffFile, ttf2woff(ttf)); + infoLog(TAG, `TEMP: ${woffFile} saved.`) // Generate font format to be used by DIM writeFileSync(woff2File, ttf2woff2(ttf)); + infoLog(TAG, `${woff2File} saved.`) const font = loadSync(woffFile); - // no need to keep this temp file - unlinkSync(woffFile); - for (let i = 0; i < font.glyphs.length; i++) { const glyph = font.glyphs.get(i); if (glyph.name && glyph.unicode) { @@ -51,6 +49,9 @@ webfont({ writeFile('./output/dim-custom-symbols.ts', outputEnum); writeFile('./data/dim-custom-symbols.ts', outputEnum); + // no need to keep this temp file + unlinkSync(woffFile); + infoLog(TAG, `TEMP: ${woffFile} removed.`) }) .catch((error) => { throw error;