Ignore .notdef in the differences array when building a fallback toUnicode map in PartialEvaluator_buildToUnicode (issue 5256)

Fixes 5256.
This commit is contained in:
Jonas Jenwald 2016-06-27 13:51:11 +02:00
parent e908b71309
commit bdd58ab1d2
4 changed files with 17 additions and 3 deletions

View File

@ -1750,7 +1750,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// the differences array only contains adobe standard or symbol set names, // the differences array only contains adobe standard or symbol set names,
// in pratice it seems better to always try to create a toUnicode // in pratice it seems better to always try to create a toUnicode
// map based of the default encoding. // map based of the default encoding.
var toUnicode, charcode; var toUnicode, charcode, glyphName;
if (!properties.composite /* is simple font */) { if (!properties.composite /* is simple font */) {
toUnicode = []; toUnicode = [];
var encoding = properties.defaultEncoding.slice(); var encoding = properties.defaultEncoding.slice();
@ -1758,12 +1758,18 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Merge in the differences array. // Merge in the differences array.
var differences = properties.differences; var differences = properties.differences;
for (charcode in differences) { for (charcode in differences) {
encoding[charcode] = differences[charcode]; glyphName = differences[charcode];
if (glyphName === '.notdef') {
// Skip .notdef to prevent rendering errors, e.g. boxes appearing
// where there should be spaces (fixes issue5256.pdf).
continue;
}
encoding[charcode] = glyphName;
} }
var glyphsUnicodeMap = getGlyphsUnicode(); var glyphsUnicodeMap = getGlyphsUnicode();
for (charcode in encoding) { for (charcode in encoding) {
// a) Map the character code to a character name. // a) Map the character code to a character name.
var glyphName = encoding[charcode]; glyphName = encoding[charcode];
// b) Look up the character name in the Adobe Glyph List (see the // b) Look up the character name in the Adobe Glyph List (see the
// Bibliography) to obtain the corresponding Unicode value. // Bibliography) to obtain the corresponding Unicode value.
if (glyphName === '') { if (glyphName === '') {

View File

@ -13,6 +13,7 @@
!issue3214.pdf !issue3214.pdf
!issue4665.pdf !issue4665.pdf
!issue4684.pdf !issue4684.pdf
!issue5256.pdf
!issue5801.pdf !issue5801.pdf
!issue5946.pdf !issue5946.pdf
!issue5972.pdf !issue5972.pdf

BIN
test/pdfs/issue5256.pdf Normal file

Binary file not shown.

View File

@ -1387,6 +1387,13 @@
"link": true, "link": true,
"type": "eq" "type": "eq"
}, },
{ "id": "issue5256",
"file": "pdfs/issue5256.pdf",
"md5": "9383e17ced31f9afc940fb7898df8e68",
"rounds": 1,
"link": false,
"type": "eq"
},
{ "id": "issue6360", { "id": "issue6360",
"file": "pdfs/issue6360.pdf", "file": "pdfs/issue6360.pdf",
"md5": "58c5455ffd84b1c07ad2d0fa90cd5e26", "md5": "58c5455ffd84b1c07ad2d0fa90cd5e26",