code: function getSegments(font, bound) {
    var prevGlyph = null;
    var result = [];
    var segment = {};
  
    var delta;
    var prevEndCode = 0;
    var prevDelta = -1;
  
    _.forEach(font._glyphs, function (glyph) {
      if (glyph.unicode === undefined) { // ignore glyphs with missed unicode
        return;
      }
      if (bound === undefined || glyph.unicode <= bound) {
        // Initialize first segment or add new segment if code "hole" is found
        if (prevGlyph === null || glyph.unicode !== prevGlyph.unicode + 1) {
          if (prevGlyph !== null) {
            segment.end = prevGlyph;
            delta = prevEndCode - segment.start.unicode + prevDelta + 1;
            segment.delta = encodeDelta(delta);
            prevEndCode = segment.end.unicode;
            prevDelta = delta;
            result.push(segment);
            segment = {};
          }
          segment.start = glyph;
        }
        prevGlyph = glyph;
      }
    });
  
    // Need to finish the last segment
    if (prevGlyph !== null) {
      segment.end = prevGlyph;
      delta = prevEndCode - segment.start.unicode + prevDelta + 1;
      segment.delta = delta > 0x7FFF ? delta - 0x10000 : (delta < -0x7FFF ? delta + 0x10000 : delta);
      result.push(segment);
    }
    return result;
  }
docs: Calculate character segments with non-interruptable chains of unicodes