addGlyphNamesToUnicodeMap top-level property

Function addGlyphNamesToUnicodeMap
getter/setter pair

Implementation

Function addGlyphNamesToUnicodeMap = (font) {
  font._IndexToUnicodeMap = {};

  var glyphIndexMap = font.tables.cmap.glyphIndexMap;
  var charCodes = glyphIndexMap.keys.toList();

  for (var i = 0; i < charCodes.length; i += 1) {
    var c = charCodes[i];
    var glyphIndex = glyphIndexMap[c];
    if (font._IndexToUnicodeMap[glyphIndex] == null) {
      font._IndexToUnicodeMap[glyphIndex] = {
        "unicodes": [int.parse(c)]
      };
    } else {
      font._IndexToUnicodeMap[glyphIndex].unicodes.add(int.parse(c));
    }
  }
};