From f13c217b25dec1350765cc63ad7bfa396280f65e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 23 Jun 2014 20:55:51 +0200 Subject: [PATCH] Fix another seac regression (issue 4801) --- src/core/fonts.js | 55 +++++++++++++++++++++++++--------------- test/pdfs/.gitignore | 1 + test/pdfs/issue4801.pdf | Bin 0 -> 8375 bytes test/test_manifest.json | 7 +++++ 4 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 test/pdfs/issue4801.pdf diff --git a/src/core/fonts.js b/src/core/fonts.js index daf6257d4..09305051f 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -4110,18 +4110,28 @@ var Font = (function FontClosure() { this.toFontChar = newMapping.toFontChar; var numGlyphs = font.numGlyphs; - function getCharCode(charCodeToGlyphId, glyphId, addMap) { + function getCharCodes(charCodeToGlyphId, glyphId) { + var charCodes = null; + for (var charCode in charCodeToGlyphId) { + if (glyphId === charCodeToGlyphId[charCode]) { + if (!charCodes) { + charCodes = []; + } + charCodes.push(charCode | 0); + } + } + return charCodes; + } + + function createCharCode(charCodeToGlyphId, glyphId) { for (var charCode in charCodeToGlyphId) { if (glyphId === charCodeToGlyphId[charCode]) { return charCode | 0; } } - if (addMap) { - newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = - glyphId; - return newMapping.nextAvailableFontCharCode++; - } - return null; + newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = + glyphId; + return newMapping.nextAvailableFontCharCode++; } var seacs = font.seacs; @@ -4144,24 +4154,27 @@ var Font = (function FontClosure() { y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5] }; - var charCode = getCharCode(mapping, glyphId); - if (charCode === null) { + var charCodes = getCharCodes(mapping, glyphId); + if (!charCodes) { // There's no point in mapping it if the char code was never mapped // to begin with. continue; } - // Find a fontCharCode that maps to the base and accent glyphs. If one - // doesn't exists, create it. - var charCodeToGlyphId = newMapping.charCodeToGlyphId; - var baseFontCharCode = getCharCode(charCodeToGlyphId, baseGlyphId, - true); - var accentFontCharCode = getCharCode(charCodeToGlyphId, accentGlyphId, - true); - seacMap[charCode] = { - baseFontCharCode: baseFontCharCode, - accentFontCharCode: accentFontCharCode, - accentOffset: accentOffset - }; + for (var i = 0, ii = charCodes.length; i < ii; i++) { + var charCode = charCodes[i]; + // Find a fontCharCode that maps to the base and accent glyphs. + // If one doesn't exists, create it. + var charCodeToGlyphId = newMapping.charCodeToGlyphId; + var baseFontCharCode = createCharCode(charCodeToGlyphId, + baseGlyphId); + var accentFontCharCode = createCharCode(charCodeToGlyphId, + accentGlyphId); + seacMap[charCode] = { + baseFontCharCode: baseFontCharCode, + accentFontCharCode: accentFontCharCode, + accentOffset: accentOffset + }; + } } properties.seacMap = seacMap; } diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index c44306c7d..ad859818d 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -81,3 +81,4 @@ !issue4246.pdf !issue4461.pdf !issue4573.pdf +!issue4801.pdf diff --git a/test/pdfs/issue4801.pdf b/test/pdfs/issue4801.pdf new file mode 100644 index 0000000000000000000000000000000000000000..e82d5bad8014e8b601cfa98c93314f5ebb194862 GIT binary patch literal 8375 zcmds7c{tSH_b(+GOA$#??<~psHv1rC%bu)Bw!vU*!^{ZTqGXFog~~1oC2K^BEiEE@ zDoY8;o+k*}v5wI@Vfd;5Z0vHE!0qt+eON0NG%&>+^ zVhC6@2R0(nDBe_iU?RizLli(*xQc2{TYA>$D7+kmLE#`20SjSd(GV8%?`MsBsl{MfmL@Cr zm!?0%Skwv~hbBNcEO=0|;8za9$zma_9B2b%;eb9gqmM*FI2`!JV<7@);~9Mn2Fw9G zKoJg$0dtUm&fp_JSl|Q#0S{!YD8T|@Xgp!XqSeNl$yhWHfRlwV1b{Xi5X9iepdc(3 zD8|}V1a>X6fgph1IkvM0Om2~U>LlzNC*u8!k}T~&=4N*V^Mg}#z2^Vt6ejI z!MxTZU~r%Z=KXQkvMT|$(coE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