Skip to content

Instantly share code, notes, and snippets.

@tzurbaev
Created September 19, 2021 18: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 tzurbaev/14325ecf140c657c216dddc22a5f15e6 to your computer and use it in GitHub Desktop.
Save tzurbaev/14325ecf140c657c216dddc22a5f15e6 to your computer and use it in GitHub Desktop.
const opentype = require('opentype.js')
opentype.load('fonts/a106a7f0-cd46-4110-81ed-417957a52738.otf', (err, font) => {
if (err) {
console.error('Unable to load font!', { err })
return
}
const map = {
one: 1,
two: 2,
three: 3,
four: 4,
five: 5,
six: 6,
seven: 7,
eight: 8,
nine: 9,
zero: 0,
}
const strings = [
'ЩDTн',
'nЮR',
'УDЩ',
'SнC',
'УDR',
]
strings.forEach(item => {
const glyphs = font.stringToGlyphs(item)
const names = glyphs.map(glyph => glyph.name)
const value = names.map(value => map[value])
console.log(`Original: "${item}", glyphs: "${names.join(', ')}", value: "${value.join('')}"`)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment