diff --git a/src/evaluator.js b/src/evaluator.js index ed49f821b..353eabd67 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -145,10 +145,16 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { assert(fontRes, 'fontRes not available'); - font = xref.fetchIfRef(font) || fontRes.get(fontName); - assertWellFormed(isDict(font)); - ++this.fontIdCounter; + + font = xref.fetchIfRef(font) || fontRes.get(fontName); + if (!isDict(font)) { + return { + translated: new ErrorFont('Font ' + fontName + ' is not available'), + loadedName: 'font_' + this.uniquePrefix + this.fontIdCounter + }; + } + var loadedName = font.loadedName; if (!loadedName) { // keep track of each font we translated so the caller can @@ -161,7 +167,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { translated = this.translateFont(font, xref, resources, dependency); } catch (e) { - translated = { error: e instanceof Error ? e.message : e }; + translated = new ErrorFont(e instanceof Error ? e.message : e); } font.translated = translated; @@ -209,10 +215,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var loadedName = font.loadedName; if (!font.sent) { - var data = font.translated; - - if (data instanceof Font) - data = data.exportData(); + var data = font.translated.exportData(); handler.send('obj', [ loadedName, diff --git a/src/fonts.js b/src/fonts.js index 74f64af14..6d9972583 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -4075,6 +4075,9 @@ var ErrorFont = (function ErrorFontClosure() { ErrorFont.prototype = { charsToGlyphs: function ErrorFont_charsToGlyphs() { return []; + }, + exportData: function ErrorFont_exportData() { + return {error: this.error}; } };