mirror of
https://github.com/kiliman/operator-mono-lig.git
synced 2026-08-12 02:10:52 +02:00
🐛 Fix errors if glyphs don't exist for other font weights
This commit is contained in:
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user