inline the fonts

This commit is contained in:
2021-12-09 13:53:34 +11:00
parent e91a52f1d8
commit e9deeeb4db
2 changed files with 2 additions and 7 deletions

View File

@ -33,12 +33,7 @@ for (const [name, f] of Object.entries(fonts)) {
const words = typeof selector === 'string' ? Array.from(doc.querySelectorAll(selector)).map(x => x.textContent).join(' ') : selector();
const subset = await subsetFont(await readFile(path), words, { targetFormat: 'woff2' });
const hash = makeHash(subset);
const outName = `static/${name}-${weight}.${hash}.woff2`;
html = html.replace(`FONT_${name}_${weight}`, outName);
await writeFile('dist/' + outName, subset);
html = html.replace(`FONT_${name}_${weight}`, 'data:font/woff2;base64,' + subset.toString('base64'));
}
}