Utilize hb.js for building compatibility ligatures.

This commit is contained in:
be5invis 2023-08-16 21:56:56 -07:00
parent d35b849f68
commit 74846d3113
8 changed files with 99 additions and 101 deletions

View file

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