More cleanup

This commit is contained in:
be5invis 2020-11-23 17:45:51 -08:00
parent e2ff6698d1
commit 0031b3362e

View file

@ -10,13 +10,15 @@ module.exports = function finalizeFont(para, glyphStore, excludedCodePoints, res
return glyphStore;
};
// In FontConfig, a font is considered "monospace" if and only if all non-combining characters
// (AW > 0) have the same width. We use this method to validate whether our "Fixed" subfamilies
// are properly built.
function validateMonospace(para, glyphStore) {
if (!para.forceMonospace) return;
let awSet = new Set();
for (const g of glyphStore.glyphs()) {
awSet.add(Math.round(g.advanceWidth || 0));
}
if (awSet.size > 2) {
throw new Error("Unreachable! Fixed variant has wide characters");
const aw = Math.round(g.advanceWidth || 0);
if (aw > 0) awSet.add(aw);
}
if (awSet.size > 1) throw new Error("Unreachable! Fixed variant has wide characters");
}