diff --git a/fonts.js b/fonts.js index bbff14e89..bcec5d2ac 100644 --- a/fonts.js +++ b/fonts.js @@ -710,7 +710,13 @@ var Font = (function Font() { }; function createOS2Table(properties, override) { - var override = override || {}; + override = override || { + unitsPerEm: 0, + yMax: 0, + yMin: 0, + ascent: 0, + descent: 0 + }; var ulUnicodeRange1 = 0; var ulUnicodeRange2 = 0; @@ -1322,7 +1328,8 @@ var Font = (function Font() { 'OS/2': stringToArray(createOS2Table(properties)), // Character to glyphs mapping - 'cmap': createCMapTable(charstrings.slice(), font.glyphIds), + 'cmap': createCMapTable(charstrings.slice(), + ('glyphIds' in font) ? font.glyphIds: null), // Font header 'head': (function fontFieldsHead() { @@ -2612,7 +2619,8 @@ var Type2CFF = (function type2CFF() { if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255)) unicode += kCmapGlyphOffset; - var width = isNum(mapping.width) ? mapping.width : defaultWidth; + var width = ('width' in mapping) && isNum(mapping.width) ? mapping.width + : defaultWidth; properties.encoding[code] = { unicode: unicode, width: width diff --git a/pdf.js b/pdf.js index d4326b5ab..30337b898 100644 --- a/pdf.js +++ b/pdf.js @@ -5136,7 +5136,8 @@ var CanvasGraphics = (function canvasGraphics() { stroke: function canvasGraphicsStroke() { var ctx = this.ctx; var strokeColor = this.current.strokeColor; - if (strokeColor && strokeColor.type === 'Pattern') { + if (strokeColor && strokeColor.hasOwnProperty('type') && + strokeColor.type === 'Pattern') { // for patterns, we transform to pattern space, calculate // the pattern, call stroke, and restore to user space ctx.save(); @@ -5157,7 +5158,8 @@ var CanvasGraphics = (function canvasGraphics() { var ctx = this.ctx; var fillColor = this.current.fillColor; - if (fillColor && fillColor.type === 'Pattern') { + if (fillColor && fillColor.hasOwnProperty('type') && + fillColor.type === 'Pattern') { ctx.save(); ctx.fillStyle = fillColor.getPattern(ctx); ctx.fill(); @@ -5177,7 +5179,8 @@ var CanvasGraphics = (function canvasGraphics() { var ctx = this.ctx; var fillColor = this.current.fillColor; - if (fillColor && fillColor.type === 'Pattern') { + if (fillColor && fillColor.hasOwnProperty('type') && + fillColor.type === 'Pattern') { ctx.save(); ctx.fillStyle = fillColor.getPattern(ctx); ctx.fill(); @@ -5187,7 +5190,8 @@ var CanvasGraphics = (function canvasGraphics() { } var strokeColor = this.current.strokeColor; - if (strokeColor && strokeColor.type === 'Pattern') { + if (strokeColor && strokeColor.hasOwnProperty('type') && + strokeColor.type === 'Pattern') { ctx.save(); ctx.strokeStyle = strokeColor.getPattern(ctx); ctx.stroke(); diff --git a/web/compatibility.js b/web/compatibility.js index 36df0e2a5..ad4c8f8a9 100644 --- a/web/compatibility.js +++ b/web/compatibility.js @@ -163,7 +163,7 @@ // IE9 text/html data URI (function checkDocumentDocumentModeCompatibility() { - if (document.documentMode !== 9) + if (!('documentMode' in document) || document.documentMode !== 9) return; // overriding the src property var originalSrcDescriptor = Object.getOwnPropertyDescriptor( diff --git a/web/viewer.html b/web/viewer.html index 160c5ce57..5da063b91 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -17,12 +17,12 @@