parse-attribs.js 772 B

1234567891011121314151617181920212223242526272829
  1. //Some versions of GlyphDesigner have a typo
  2. //that causes some bugs with parsing.
  3. //Need to confirm with recent version of the software
  4. //to see whether this is still an issue or not.
  5. var GLYPH_DESIGNER_ERROR = 'chasrset'
  6. module.exports = function parseAttributes(obj) {
  7. obj = Object.assign({}, obj)
  8. if (GLYPH_DESIGNER_ERROR in obj) {
  9. obj['charset'] = obj[GLYPH_DESIGNER_ERROR]
  10. delete obj[GLYPH_DESIGNER_ERROR]
  11. }
  12. for (var k in obj) {
  13. if (k === 'face' || k === 'charset')
  14. continue
  15. else if (k === 'padding' || k === 'spacing')
  16. obj[k] = parseIntList(obj[k])
  17. else
  18. obj[k] = parseInt(obj[k], 10)
  19. }
  20. return obj
  21. }
  22. function parseIntList(data) {
  23. return data.split(',').map(function(val) {
  24. return parseInt(val, 10)
  25. })
  26. }