This commit is contained in:
be5invis 2023-04-19 17:44:10 -07:00
parent 4139b9b142
commit ce4212a639
4 changed files with 79 additions and 42 deletions

View file

@ -0,0 +1,19 @@
import fs from "fs";
import { FontIo, Ot } from "ot-builder";
export async function readTTF(input) {
const buf = await fs.promises.readFile(input);
const sfnt = FontIo.readSfntOtf(buf);
const font = FontIo.readFont(sfnt, Ot.ListGlyphStoreFactory);
return font;
}
export async function saveTTF(output, font) {
const sfnt = FontIo.writeFont(font, {
glyphStore: { statOs2XAvgCharWidth: false },
generateDummyDigitalSignature: true
});
const buf = FontIo.writeSfntOtf(sfnt);
await fs.promises.writeFile(output, buf);
}