From fbe7b2eee7bd4b2091307b834408972b0daaf028 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 5 Apr 2017 13:32:36 +0200 Subject: [PATCH] Always ignore Type3 glyphs if their `OperatorList`s contain errors, regardless of the value of the `stopAtErrors` option Compared to the parsing of e.g. an entire page, it doesn't really make sense to only be able to render a Type3 glyph partially. --- src/core/evaluator.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index f1e49c80f..a43fc5e63 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -267,6 +267,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var TILING_PATTERN = 1, SHADING_PATTERN = 2; PartialEvaluator.prototype = { + clone: function(newOptions) { + newOptions = newOptions || DefaultPartialEvaluatorOptions; + var newEvaluator = Object.create(this); + newEvaluator.options = newOptions; + return newEvaluator; + }, + hasBlendModes: function PartialEvaluator_hasBlendModes(resources) { if (!isDict(resources)) { return false; @@ -2500,6 +2507,12 @@ var TranslatedFont = (function TranslatedFontClosure() { if (this.type3Loaded) { return this.type3Loaded; } + // When parsing Type3 glyphs, always ignore them if there are errors. + // Compared to the parsing of e.g. an entire page, it doesn't really + // make sense to only be able to render a Type3 glyph partially. + var type3Options = Object.create(evaluator.options); + type3Options.ignoreErrors = false; + var type3Evaluator = evaluator.clone(type3Options); var translatedFont = this.font; var loadCharProcsPromise = Promise.resolve(); @@ -2507,12 +2520,14 @@ var TranslatedFont = (function TranslatedFontClosure() { var fontResources = this.dict.get('Resources') || resources; var charProcKeys = charProcs.getKeys(); var charProcOperatorList = Object.create(null); + for (var i = 0, n = charProcKeys.length; i < n; ++i) { loadCharProcsPromise = loadCharProcsPromise.then(function (key) { var glyphStream = charProcs.get(key); var operatorList = new OperatorList(); - return evaluator.getOperatorList(glyphStream, task, fontResources, - operatorList).then(function () { + return type3Evaluator.getOperatorList(glyphStream, task, + fontResources, operatorList). + then(function () { charProcOperatorList[key] = operatorList.getIR(); // Add the dependencies to the parent operator list so they are