Skip to content

Instantly share code, notes, and snippets.

@santhoshtr
Created February 21, 2020 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santhoshtr/bc005a54f2e070638df87995aa5f3cf4 to your computer and use it in GitHub Desktop.
Save santhoshtr/bc005a54f2e070638df87995aa5f3cf4 to your computer and use it in GitHub Desktop.
process ligatures and glyphs for Manjari
const glyphs = require('./glyphs.json').glyphs
const ligatures = require('./ligatures.json').ligatures
const getGlyphValue = (glyphname) => {
const glyph = glyphs.find(g => g.glyph === glyphname);
return glyph && glyph.value;
}
const process = () => {
const ligaturesLength = ligatures.length;
const glyphMap = {}
for (let i = 0; i < ligaturesLength; i++) {
let ligature = ligatures[i];
if (!ligature.sequence) continue;
let glypNames = ligature.sequence.split(' ');
let glyphValues = [];
for (let j = 0; j < glypNames.length; j++) {
let value = getGlyphValue(glypNames[j]);
if (value) {
glyphMap[glypNames[j]] = value
}
glyphValues.push(glyphMap[glypNames[j]] || '?')
}
glyphMap[ligature['name']] = glyphValues.join('')
ligature['value'] = glyphMap[ligature['name']]
ligature['ml_sequence'] = glyphValues.join(' + ')
}
return ligatures;
}
const precessedLigatures = process();
console.log(JSON.stringify(precessedLigatures))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment