D8 theme for the Digital Herbarium repo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
776 B

var Promise = require("bluebird"),
indexBy = require('lodash.indexby'),
readFile = Promise.promisify(require("fs").readFile),
parseXml = Promise.promisify(require("xml2js").parseString);
var SVG_FILE = require.resolve("font-awesome/fonts/fontawesome-webfont.svg");
function getFontData() {
return readFile(SVG_FILE)
.then(function (fontData) {
return fontData.toString("utf-8");
})
.then(parseXml)
.then(function (parsedXml) {
return parsedXml.svg.defs[0].font[0].glyph;
})
.map(function (xmlGlyph) {
return {
data: xmlGlyph.$,
unicodeDec: xmlGlyph.$.unicode.charCodeAt(0)
};
})
.then(function (fontData) {
return indexBy(fontData, "unicodeDec");
});
}
module.exports = getFontData;