From 471aef5fc650f8549c1ee6b792ffff852f677282 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 8 Mar 2023 08:45:42 +0100 Subject: [PATCH] Support (rare) Type3 fonts with Pattern resources (issue 16127) This simply extends the approach in PR 10727 to also cover Patterns, which shouldn't be a common occurrence in Type3 fonts (since this is the first issue we've seen). --- src/core/evaluator.js | 10 +++++++++- src/display/api.js | 1 + src/display/canvas.js | 2 +- test/pdfs/issue16127.pdf.link | 1 + test/test_manifest.json | 10 ++++++++++ 5 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 test/pdfs/issue16127.pdf.link diff --git a/src/core/evaluator.js b/src/core/evaluator.js index eb6c0b7fc..873ceec6b 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -1482,8 +1482,16 @@ class PartialEvaluator { ); const patternIR = shadingFill.getIR(); id = `pattern_${this.idFactory.createObjId()}`; + if (this.parsingType3Font) { + id = `${this.idFactory.getDocId()}_type3_${id}`; + } localShadingPatternCache.set(shading, id); - this.handler.send("obj", [id, this.pageIndex, "Pattern", patternIR]); + + if (this.parsingType3Font) { + this.handler.send("commonobj", [id, "Pattern", patternIR]); + } else { + this.handler.send("obj", [id, this.pageIndex, "Pattern", patternIR]); + } } return id; } diff --git a/src/display/api.js b/src/display/api.js index 521142c0a..b6171fb92 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -2777,6 +2777,7 @@ class WorkerTransport { break; case "FontPath": case "Image": + case "Pattern": this.commonObjs.resolve(id, exportedData); break; default: diff --git a/src/display/canvas.js b/src/display/canvas.js index 74da9d151..4443426df 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -2517,7 +2517,7 @@ class CanvasGraphics { if (this.cachedPatterns.has(objId)) { pattern = this.cachedPatterns.get(objId); } else { - pattern = getShadingPattern(this.objs.get(objId)); + pattern = getShadingPattern(this.getObject(objId)); this.cachedPatterns.set(objId, pattern); } if (matrix) { diff --git a/test/pdfs/issue16127.pdf.link b/test/pdfs/issue16127.pdf.link new file mode 100644 index 000000000..ad1cc07ef --- /dev/null +++ b/test/pdfs/issue16127.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/10913919/Noto.Color.Emoji.-.Google.Fonts.-.Chrome.112.-.Full.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index cb23055be..8f897e092 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -2378,6 +2378,16 @@ "type": "eq", "about": "Type3 fonts with image resources; both pages need to be tested, otherwise the bug won't manifest." }, + { "id": "issue16127", + "file": "pdfs/issue16127.pdf", + "md5": "42714567a818876f51ef960df21600f5", + "link": true, + "rounds": 1, + "firstPage": 1, + "lastPage": 2, + "type": "eq", + "about": "Type3 fonts with pattern resources; both pages need to be tested, otherwise the bug won't manifest." + }, { "id": "doc_actions", "file": "pdfs/doc_actions.pdf", "md5": "ceae4eb405a0b40394f4d63d7525a870",