Skip to content

Commit

Permalink
remove temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
delphiactual committed Jun 12, 2024
1 parent 3d60763 commit a9f728b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2,074 deletions.
2,065 changes: 0 additions & 2,065 deletions DIM-custom-font/DIM-Symbols.svg

This file was deleted.

Binary file removed DIM-custom-font/DIM-Symbols.ttf
Binary file not shown.
Binary file removed DIM-custom-font/DIM-Symbols.woff
Binary file not shown.
Binary file modified output/DIMSymbols.woff2
Binary file not shown.
25 changes: 16 additions & 9 deletions src/generate-custom-glyph-enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import ttf2woff2 from 'ttf2woff2';
import ttf2woff from 'ttf2woff';
import fse from 'fs-extra';

const { writeFileSync, readFileSync } = fse;
const { writeFileSync, readFileSync, unlinkSync } = fse;

const acc: Record<string, number> = {};

const svgFile = './DIM-custom-font/DIM-Symbols.svg';
const woffFile = svgFile.replace('svg', 'woff');
const ttfFile = svgFile.replace('svg', 'ttf');
const woff2File = './output/DIMSymbols.woff2';

webfont({
files: './DIM-custom-font/SVGs/',
dest: './DIM-custom-font/',
Expand All @@ -22,17 +27,19 @@ webfont({
})
.then((result) => {
// Writes buffer into .svg font file for other conversions
writeFile('./DIM-custom-font/DIM-Symbols.svg', result.svg);
writeFileSync(svgFile, result.svg!);
// loadSync requires .otf or .woff filetype for enumeration
const ttf = svg2ttf(readFileSync('./DIM-custom-font/DIM-Symbols.svg', 'utf8'), { ts: 0 });
writeFileSync('./DIM-custom-font/DIM-Symbols.woff', ttf2woff(ttf.buffer));
writeFileSync(ttfFile, svg2ttf(readFileSync(svgFile, 'utf8'), { ts: 0 }).buffer);
writeFileSync(woffFile, ttf2woff(readFileSync(ttfFile)));
// Generate font format to be used by DIM
writeFileSync(
'./output/DIMSymbols.woff2',
ttf2woff2(readFileSync('./DIM-custom-font/DIM-Symbols.ttf')),
);
writeFileSync(woff2File, ttf2woff2(readFileSync(ttfFile)));

const font = loadSync(woffFile);

const font = loadSync('./DIM-custom-font/DIM-Symbols.woff');
// no need to keep these temp files
unlinkSync(svgFile);
unlinkSync(ttfFile);
unlinkSync(woffFile);

for (let i = 0; i < font.glyphs.length; i++) {
const glyph = font.glyphs.get(i);
Expand Down

0 comments on commit a9f728b

Please sign in to comment.