Optimize
This commit is contained in:
parent
4139b9b142
commit
ce4212a639
4 changed files with 79 additions and 42 deletions
19
font-src/support/font-io/font-io.mjs
Normal file
19
font-src/support/font-io/font-io.mjs
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue