Created
February 21, 2020 05:59
-
-
Save santhoshtr/bc005a54f2e070638df87995aa5f3cf4 to your computer and use it in GitHub Desktop.
process ligatures and glyphs for Manjari
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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