From 3e1db41ddd64be44d3e193d92cd3541a96e38a53 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 18 May 2014 00:57:06 +0200 Subject: [PATCH] Fix loading of fonts with empty font files (bug 866395 and issue 3522) --- src/core/fonts.js | 8 +++++++- test/pdfs/.gitignore | 1 + test/pdfs/bug866395.pdf | Bin 0 -> 1879 bytes test/test_manifest.json | 8 ++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/bug866395.pdf diff --git a/src/core/fonts.js b/src/core/fonts.js index 6d01710c7..5620cbcb3 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -2204,7 +2204,13 @@ var Font = (function FontClosure() { this.defaultVMetrics = properties.defaultVMetrics; } - if (!file) { + if (!file || file.isEmpty) { + if (file) { + // Some bad PDF generators will include empty font files, + // attempting to recover by assuming that no file exists. + warn('Font file is empty in "' + name + '" (' + this.loadedName + ')'); + } + this.missingFile = true; // The file data is not specified. Trying to fix the font name // to be used with the canvas.font. diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index efd18259a..726a852d3 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -55,6 +55,7 @@ !gradientfill.pdf !bug903856.pdf !bug850854.pdf +!bug866395.pdf !basicapi.pdf !mixedfonts.pdf !shading_extend.pdf diff --git a/test/pdfs/bug866395.pdf b/test/pdfs/bug866395.pdf new file mode 100644 index 0000000000000000000000000000000000000000..26af56bb9188e5594c3bbccfa10ac83508435477 GIT binary patch literal 1879 zcmd5-eP|nH7;jZ{zA!D*O=J#UD;*bIdiUPta>*FQCTVEq){Z1wm8RBP@;14d+@+U` zw)#)46d77Skg=6c98{;^#~*_-oF8MlI%PPiI24tx3Tl~-i4)v#9X{_}u1T!m{`3Nu zd*A2#d4A9Hv}}t+y`)t^L{zYVjh(yDrcH=X4i_or!>Xm`jV$7~saaaWL<|5+9JRF} zs%IFhb5k#5^CEsL&1h=K7{a|EBVbVwuq@y{#D|Tt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