1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Merge pull request #11746 from Snuffleupagus/issue-11740

Create the glyph mapping correctly for composite Type1, i.e. CIDFontType0, fonts (issue 11740)
This commit is contained in:
Tim van der Meij 2020-04-07 00:10:12 +02:00 committed by GitHub
commit 70c54ab9d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 3 deletions

View file

@ -3642,6 +3642,22 @@ var Type1Font = (function Type1FontClosure() {
getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
var charstrings = this.charstrings;
if (properties.composite) {
const charCodeToGlyphId = Object.create(null);
// Map CIDs directly to GIDs.
for (
let glyphId = 0, charstringsLen = charstrings.length;
glyphId < charstringsLen;
glyphId++
) {
const charCode = properties.cMap.charCodeOf(glyphId);
// Add 1 because glyph 0 is duplicated.
charCodeToGlyphId[charCode] = glyphId + 1;
}
return charCodeToGlyphId;
}
var glyphNames = [".notdef"],
glyphId;
for (glyphId = 0; glyphId < charstrings.length; glyphId++) {

View file

@ -437,7 +437,7 @@ var Type1Parser = (function Type1ParserClosure() {
r = ((value + r) * c1 + c2) & ((1 << 16) - 1);
}
}
return Array.prototype.slice.call(decrypted, discardNumber, j);
return decrypted.slice(discardNumber, j);
}
function isSpecial(c) {
@ -457,10 +457,14 @@ var Type1Parser = (function Type1ParserClosure() {
if (encrypted) {
var data = stream.getBytes();
var isBinary = !(
isHexDigit(data[0]) &&
(isHexDigit(data[0]) || isWhiteSpace(data[0])) &&
isHexDigit(data[1]) &&
isHexDigit(data[2]) &&
isHexDigit(data[3])
isHexDigit(data[3]) &&
isHexDigit(data[4]) &&
isHexDigit(data[5]) &&
isHexDigit(data[6]) &&
isHexDigit(data[7])
);
stream = new Stream(
isBinary