1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #4809 from Snuffleupagus/bug-866395-redux

Fix loading of fonts with empty font files (bug 866395 and issue 3522)
This commit is contained in:
Yury Delendik 2014-05-19 11:23:54 -05:00
commit 5cd6483ebb
6 changed files with 30 additions and 2 deletions

View file

@ -133,6 +133,10 @@ var ChunkedStream = (function ChunkedStreamClosure() {
return this.end - this.start;
},
get isEmpty() {
return this.length === 0;
},
getByte: function ChunkedStream_getByte() {
var pos = this.pos;
if (pos >= this.end) {

View file

@ -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.

View file

@ -35,6 +35,9 @@ var Stream = (function StreamClosure() {
get length() {
return this.end - this.start;
},
get isEmpty() {
return this.length === 0;
},
getByte: function Stream_getByte() {
if (this.pos >= this.end) {
return -1;
@ -128,6 +131,12 @@ var DecodeStream = (function DecodeStreamClosure() {
}
DecodeStream.prototype = {
get isEmpty() {
while (!this.eof && this.bufferLength === 0) {
this.readBlock();
}
return this.bufferLength === 0;
},
ensureBuffer: function DecodeStream_ensureBuffer(requested) {
var buffer = this.buffer;
var current;
@ -213,7 +222,7 @@ var DecodeStream = (function DecodeStreamClosure() {
}
return new Stream(this.buffer, start, length, dict);
},
skip: function Stream_skip(n) {
skip: function DecodeStream_skip(n) {
if (!n) {
n = 1;
}