Merge pull request #10685 from Snuffleupagus/preEvaluateFont-better-hashing

Take the `FirstChar`/`LastChar` properties into account when computing the hash in `PartialEvaluator.preEvaluateFont` (issue 10665)
This commit is contained in:
Tim van der Meij 2019-03-28 00:06:39 +01:00 committed by GitHub
commit a63de0e2d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 5 deletions

View File

@ -695,20 +695,19 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var fontCapability = createPromiseCapability(); var fontCapability = createPromiseCapability();
var preEvaluatedFont = this.preEvaluateFont(font); var preEvaluatedFont = this.preEvaluateFont(font);
var descriptor = preEvaluatedFont.descriptor; const { descriptor, hash, } = preEvaluatedFont;
var fontRefIsRef = isRef(fontRef), fontID; var fontRefIsRef = isRef(fontRef), fontID;
if (fontRefIsRef) { if (fontRefIsRef) {
fontID = fontRef.toString(); fontID = fontRef.toString();
} }
if (isDict(descriptor)) { if (hash && isDict(descriptor)) {
if (!descriptor.fontAliases) { if (!descriptor.fontAliases) {
descriptor.fontAliases = Object.create(null); descriptor.fontAliases = Object.create(null);
} }
var fontAliases = descriptor.fontAliases; var fontAliases = descriptor.fontAliases;
var hash = preEvaluatedFont.hash;
if (fontAliases[hash]) { if (fontAliases[hash]) {
var aliasFontRef = fontAliases[hash].aliasRef; var aliasFontRef = fontAliases[hash].aliasRef;
if (fontRefIsRef && aliasFontRef && if (fontRefIsRef && aliasFontRef &&
@ -785,7 +784,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
try { try {
// error, but it's still nice to have font type reported // error, but it's still nice to have font type reported
var descriptor = preEvaluatedFont.descriptor;
var fontFile3 = descriptor && descriptor.get('FontFile3'); var fontFile3 = descriptor && descriptor.get('FontFile3');
var subtype = fontFile3 && fontFile3.get('Subtype'); var subtype = fontFile3 && fontFile3.get('Subtype');
var fontType = getFontType(preEvaluatedFont.type, var fontType = getFontType(preEvaluatedFont.type,
@ -2352,6 +2350,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
} }
} }
const firstChar = (dict.get('FirstChar') || 0);
const lastChar = (dict.get('LastChar') || (composite ? 0xFFFF : 0xFF));
hash.update(`${firstChar}-${lastChar}`);
var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode'); var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
if (isStream(toUnicode)) { if (isStream(toUnicode)) {
var stream = toUnicode.str || toUnicode; var stream = toUnicode.str || toUnicode;

View File

@ -76,6 +76,7 @@
!issue10388_reduced.pdf !issue10388_reduced.pdf
!issue10438_reduced.pdf !issue10438_reduced.pdf
!issue10529.pdf !issue10529.pdf
!issue10665_reduced.pdf
!bad-PageLabels.pdf !bad-PageLabels.pdf
!decodeACSuccessive.pdf !decodeACSuccessive.pdf
!filled-background.pdf !filled-background.pdf

Binary file not shown.

View File

@ -2564,6 +2564,13 @@
"link": false, "link": false,
"type": "eq" "type": "eq"
}, },
{ "id": "issue10665",
"file": "pdfs/issue10665_reduced.pdf",
"md5": "4c8938c808153f6b3840e8a5eb68b804",
"rounds": 1,
"link": false,
"type": "eq"
},
{ "id": "issue1466", { "id": "issue1466",
"file": "pdfs/issue1466.pdf", "file": "pdfs/issue1466.pdf",
"md5": "8a8877432e5bb10cfd50d60488d947bb", "md5": "8a8877432e5bb10cfd50d60488d947bb",