get method

dynamic get(
  1. dynamic index
)

Implementation

get(index) {
  // this.glyphs[index] is 'undefined' when low memory mode is on. glyph is pushed on request only.
  if (this.glyphs[index] == null) {
    this.font._push(index);
    if ( this.glyphs[index] is Function ) {
      this.glyphs[index] = this.glyphs[index]();
    }

    var glyph = this.glyphs[index];
    var unicodeObj = this.font._IndexToUnicodeMap[index];

    if (unicodeObj) {
        for (var j = 0; j < unicodeObj.unicodes.length; j++)
            glyph.addUnicode(unicodeObj.unicodes[j]);
    }

    if (this.font.cffEncoding) {
        if (this.font.isCIDFont) {
            glyph.name = 'gid' + index;
        } else {
            glyph.name = this.font.cffEncoding.charset[index];
        }
    } else if (this.font.glyphNames.names) {
        glyph.name = this.font.glyphNames.glyphIndexToName(index);
    }

    this.glyphs[index].advanceWidth = this.font._hmtxTableData[index].advanceWidth;
    this.glyphs[index].leftSideBearing = this.font._hmtxTableData[index].leftSideBearing;
  } else {
    if ( this.glyphs[index] is Function ) {
      this.glyphs[index] = this.glyphs[index]();
    }
  }

  return this.glyphs[index];
}