Iosevka/font-src/gen/finalize/index.js
be5invis 7c78329244 * Replace autoRef with semantic inclusion for more stable results.
* Move files around to make repository organized better.
2020-10-17 15:45:00 -07:00

22 lines
685 B
JavaScript

"use strict";
const finalizeGlyphs = require("./glyphs");
const gcFont = require("./gc");
module.exports = function finalizeFont(para, glyphStore, excludedCodePoints, restFont) {
glyphStore = forceMonospaceIfNeeded(para, glyphStore);
glyphStore = gcFont(glyphStore, excludedCodePoints, restFont, {});
glyphStore = finalizeGlyphs(para, glyphStore);
return glyphStore;
};
function forceMonospaceIfNeeded(para, glyphStore) {
const unitWidth = Math.round(para.width);
if (!para.forceMonospace || para.spacing > 0) return glyphStore;
return glyphStore.filterByGlyph({
has: g => {
const gw = Math.round(g.advanceWidth || 0);
return gw === 0 || gw === unitWidth;
}
});
}