Merge pull request #3997 from Snuffleupagus/bug-946506
Fix loading of fonts that are not referenced by an object identifier
This commit is contained in:
commit
81cb24bff5
@ -475,16 +475,24 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
return this.fontCache.get(fontRef);
|
return this.fontCache.get(fontRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
font = xref.fetchIfRef(fontRef);
|
font = xref.fetchIfRef(fontRef);
|
||||||
if (!isDict(font)) {
|
if (!isDict(font)) {
|
||||||
return errorFont();
|
return errorFont();
|
||||||
}
|
}
|
||||||
this.fontCache.put(fontRef, font);
|
// Workaround for bad PDF generators that doesn't reference fonts
|
||||||
|
// properly, i.e. by not using an object identifier.
|
||||||
|
// Check if the fontRef is a Dict (as opposed to a standard object),
|
||||||
|
// in which case we don't cache the font and instead reference it by
|
||||||
|
// fontName in font.loadedName below.
|
||||||
|
var fontRefIsDict = isDict(fontRef);
|
||||||
|
if (!fontRefIsDict) {
|
||||||
|
this.fontCache.put(fontRef, font);
|
||||||
|
}
|
||||||
|
|
||||||
// keep track of each font we translated so the caller can
|
// keep track of each font we translated so the caller can
|
||||||
// load them asynchronously before calling display on a page
|
// load them asynchronously before calling display on a page
|
||||||
font.loadedName = 'g_font_' + fontRef.num + '_' + fontRef.gen;
|
font.loadedName = 'g_font_' + (fontRefIsDict ?
|
||||||
|
fontName.replace(/\W/g, '') : (fontRef.num + '_' + fontRef.gen));
|
||||||
|
|
||||||
if (!font.translated) {
|
if (!font.translated) {
|
||||||
var translated;
|
var translated;
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -61,3 +61,4 @@
|
|||||||
!issue2099-1.pdf
|
!issue2099-1.pdf
|
||||||
!issue3371.pdf
|
!issue3371.pdf
|
||||||
!issue2956.pdf
|
!issue2956.pdf
|
||||||
|
!bug946506.pdf
|
||||||
|
BIN
test/pdfs/bug946506.pdf
Normal file
BIN
test/pdfs/bug946506.pdf
Normal file
Binary file not shown.
@ -42,6 +42,16 @@
|
|||||||
"type": "load",
|
"type": "load",
|
||||||
"about": "PDF with undefined stream length."
|
"about": "PDF with undefined stream length."
|
||||||
},
|
},
|
||||||
|
{ "id": "bug946506",
|
||||||
|
"file": "pdfs/bug946506.pdf",
|
||||||
|
"md5": "c28911b5c31bdc337c2ce404c5971cfc",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": false,
|
||||||
|
"firstPage": 1,
|
||||||
|
"lastPage": 1,
|
||||||
|
"type": "eq",
|
||||||
|
"about": "Fonts referenced only by name and not by an object identifier."
|
||||||
|
},
|
||||||
{ "id": "issue3879",
|
{ "id": "issue3879",
|
||||||
"file": "pdfs/issue3879.pdf",
|
"file": "pdfs/issue3879.pdf",
|
||||||
"md5": "1cd1f1c3271515a14e65ff2980e14663",
|
"md5": "1cd1f1c3271515a14e65ff2980e14663",
|
||||||
|
Loading…
Reference in New Issue
Block a user