🐛 Fix errors if glyphs don't exist for other font weights

This commit is contained in:
Kiliman
2019-07-23 15:47:27 -04:00
committed by unknown
parent 8360f4ad81
commit 9cef42b1fb
+10 -1
View File
@@ -51,7 +51,8 @@ const buildFont = profile => {
)
.filter(name => !/\d+\.liga$/.test(name)) // skip alternates (ends with .#)
.filter(name => filterLigatures(name, profile.ligatures))
.map(name => mapLigatures(name, profile.ligatures));
.map(name => mapLigatures(name, profile.ligatures))
.filter(entry => filterGlyphsExists(entry));
const ligaturesWithLIG = ligatures;
//[...ligatures, { name: 'LIG', glyph: 'LIG' }];
@@ -130,6 +131,11 @@ const mapLigatures = (name, ligatures) => {
return entry;
};
const filterGlyphsExists = ({ glyph }) => {
const exists = fs.existsSync(`./ligature/${ligFontName}/glyphs/${glyph}.xml`);
return exists;
};
const sortLigatures = ligatures => {
// sort by most glyphs then alphabetically
const sorted = ligatures
@@ -256,6 +262,9 @@ const patchGlyphs = (dom, ligatures) => {
};
const patchGsub = (dom, ligatures) => {
// don't patch if no ligatures other than LIG
if (ligatures.length <= 1) return;
ligatures
.filter(ligature => /_/.test(ligature.glyph))
.forEach(ligature => {