Skip to content

Commit

Permalink
cleanuper
Browse files Browse the repository at this point in the history
  • Loading branch information
delphiactual committed Jun 12, 2024
1 parent a9f728b commit c420a02
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/generate-custom-glyph-enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, number> = {};

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({
Expand All @@ -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++) {
Expand Down

0 comments on commit c420a02

Please sign in to comment.