extensions/pdfViewer/pdf/build/pdf.worker.js
function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  var charCodeToGlyphId = Object.create(null);
  var glyphId, charCode, baseEncoding;

  if (properties.baseEncodingName) {
    // If a valid base encoding name was used, the mapping is initialized with
    // that.
    baseEncoding = Encodings[properties.baseEncodingName];
    for (charCode = 0; charCode < baseEncoding.length; charCode++) {
      glyphId = glyphNames.indexOf(baseEncoding[charCode]);
      if (glyphId >= 0) {
        charCodeToGlyphId[charCode] = glyphId;
      } else {
        charCodeToGlyphId[charCode] = 0; // notdef
      }
    }
  } else if (!!(properties.flags & FontFlags.Symbolic)) {
    // For a symbolic font the encoding should be the fonts built-in
    // encoding.
    for (charCode in builtInEncoding) {
      charCodeToGlyphId[charCode] = builtInEncoding[charCode];
    }
  } else {
    // For non-symbolic fonts that don't have a base encoding the standard
    // encoding should be used.
    baseEncoding = Encodings.StandardEncoding;
    for (charCode = 0; charCode < baseEncoding.length; charCode++) {
      glyphId = glyphNames.indexOf(baseEncoding[charCode]);
      if (glyphId >= 0) {
        charCodeToGlyphId[charCode] = glyphId;
      } else {
        charCodeToGlyphId[charCode] = 0; // notdef
      }
    }
  }

  // Lastly, merge in the differences.
  var differences = properties.differences;
  if (differences) {
    for (charCode in differences) {
      var glyphName = differences[charCode];
      glyphId = glyphNames.indexOf(glyphName);
      if (glyphId >= 0) {
        charCodeToGlyphId[charCode] = glyphId;
      } else {
        charCodeToGlyphId[charCode] = 0; // notdef
      }
    }
  }
  return charCodeToGlyphId;
}
function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  var charCodeToGlyphId = Object.create(null);
  var glyphId, charCode, baseEncoding;

  if (properties.baseEncodingName) {
    // If a valid base encoding name was used, the mapping is initialized with
    // that.
    baseEncoding = Encodings[properties.baseEncodingName];
    for (charCode = 0; charCode < baseEncoding.length; charCode++) {
      glyphId = glyphNames.indexOf(baseEncoding[charCode]);
      if (glyphId >= 0) {
        charCodeToGlyphId[charCode] = glyphId;
      } else {
        charCodeToGlyphId[charCode] = 0; // notdef
      }
    }
  } else if (!!(properties.flags & FontFlags.Symbolic)) {
    // For a symbolic font the encoding should be the fonts built-in
    // encoding.
    for (charCode in builtInEncoding) {
      charCodeToGlyphId[charCode] = builtInEncoding[charCode];
    }
  } else {
    // For non-symbolic fonts that don't have a base encoding the standard
    // encoding should be used.
    baseEncoding = Encodings.StandardEncoding;
    for (charCode = 0; charCode < baseEncoding.length; charCode++) {
      glyphId = glyphNames.indexOf(baseEncoding[charCode]);
      if (glyphId >= 0) {
        charCodeToGlyphId[charCode] = glyphId;
      } else {
        charCodeToGlyphId[charCode] = 0; // notdef
      }
    }
  }

  // Lastly, merge in the differences.
  var differences = properties.differences;
  if (differences) {
    for (charCode in differences) {
      var glyphName = differences[charCode];
      glyphId = glyphNames.indexOf(glyphName);
      if (glyphId >= 0) {
        charCodeToGlyphId[charCode] = glyphId;
      } else {
        charCodeToGlyphId[charCode] = 0; // notdef
      }
    }
  }
  return charCodeToGlyphId;
}
function type1FontGlyphMapping ( properties , builtInEncoding , glyphNames ) { var charCodeToGlyphId = Object . create ( null ) ; var glyphId , charCode , baseEncoding ; if ( properties . baseEncodingName ) { // If a valid base encoding name was used, the mapping is initialized with // that. baseEncoding = Encodings [ properties . baseEncodingName ] ; for ( charCode = 0 ; charCode < baseEncoding . length ; charCode ++ ) { glyphId = glyphNames . indexOf ( baseEncoding [ charCode ] ) ; if ( glyphId >= 0 ) { charCodeToGlyphId [ charCode ] = glyphId ; } else { charCodeToGlyphId [ charCode ] = 0 ; // notdef } } } else if ( ! ! ( properties . flags & FontFlags . Symbolic ) ) { // For a symbolic font the encoding should be the fonts built-in // encoding. for ( charCode in builtInEncoding ) { charCodeToGlyphId [ charCode ] = builtInEncoding [ charCode ] ; } } else { // For non-symbolic fonts that don't have a base encoding the standard // encoding should be used. baseEncoding = Encodings . StandardEncoding ; for ( charCode = 0 ; charCode < baseEncoding . length ; charCode ++ ) { glyphId = glyphNames . indexOf ( baseEncoding [ charCode ] ) ; if ( glyphId >= 0 ) { charCodeToGlyphId [ charCode ] = glyphId ; } else { charCodeToGlyphId [ charCode ] = 0 ; // notdef } } } // Lastly, merge in the differences. var differences = properties . differences ; if ( differences ) { for ( charCode in differences ) { var glyphName = differences [ charCode ] ; glyphId = glyphNames . indexOf ( glyphName ) ; if ( glyphId >= 0 ) { charCodeToGlyphId [ charCode ] = glyphId ; } else { charCodeToGlyphId [ charCode ] = 0 ; // notdef } } } return charCodeToGlyphId ; }
Shared logic for building a char code to glyph id mapping for Type1 and
simple CFF fonts. See section 9.6.6.2 of the spec.
@param {Object} properties Font properties object.
@param {Object} builtInEncoding The encoding contained within the actual font
data.
@param {Array} Array of glyph names where the index is the glyph ID.
@returns {Object} A char code to glyph ID map.
Shared logic for building a char code to glyph id mapping for Type1 and simple CFF fonts . See section 9 . 6 . 6 . 2 of the spec .