diff --git a/index.js b/index.js index bca04cf..311be22 100644 --- a/index.js +++ b/index.js @@ -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 => {