Falls back to ErrorFont when font object is not available or corrupted
This commit is contained in:
parent
8c3fdd069a
commit
8c3a82ff4d
@ -145,10 +145,16 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
|
|
||||||
assert(fontRes, 'fontRes not available');
|
assert(fontRes, 'fontRes not available');
|
||||||
|
|
||||||
font = xref.fetchIfRef(font) || fontRes.get(fontName);
|
|
||||||
assertWellFormed(isDict(font));
|
|
||||||
|
|
||||||
++this.fontIdCounter;
|
++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;
|
var loadedName = font.loadedName;
|
||||||
if (!loadedName) {
|
if (!loadedName) {
|
||||||
// keep track of each font we translated so the caller can
|
// 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,
|
translated = this.translateFont(font, xref, resources,
|
||||||
dependency);
|
dependency);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
translated = { error: e instanceof Error ? e.message : e };
|
translated = new ErrorFont(e instanceof Error ? e.message : e);
|
||||||
}
|
}
|
||||||
font.translated = translated;
|
font.translated = translated;
|
||||||
|
|
||||||
@ -209,10 +215,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
|
|
||||||
var loadedName = font.loadedName;
|
var loadedName = font.loadedName;
|
||||||
if (!font.sent) {
|
if (!font.sent) {
|
||||||
var data = font.translated;
|
var data = font.translated.exportData();
|
||||||
|
|
||||||
if (data instanceof Font)
|
|
||||||
data = data.exportData();
|
|
||||||
|
|
||||||
handler.send('obj', [
|
handler.send('obj', [
|
||||||
loadedName,
|
loadedName,
|
||||||
|
@ -4075,6 +4075,9 @@ var ErrorFont = (function ErrorFontClosure() {
|
|||||||
ErrorFont.prototype = {
|
ErrorFont.prototype = {
|
||||||
charsToGlyphs: function ErrorFont_charsToGlyphs() {
|
charsToGlyphs: function ErrorFont_charsToGlyphs() {
|
||||||
return [];
|
return [];
|
||||||
|
},
|
||||||
|
exportData: function ErrorFont_exportData() {
|
||||||
|
return {error: this.error};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user