diff --git a/Makefile b/Makefile index e9c2cc370..c9de61c1c 100644 --- a/Makefile +++ b/Makefile @@ -71,7 +71,7 @@ bundle: | $(BUILD_DIR) cat $(PDF_JS_FILES) > all_files.tmp; \ sed '/PDFJSSCRIPT_INCLUDE_ALL/ r all_files.tmp' pdf.js > ../$(BUILD_TARGET); \ sed -i.bak "s/PDFJSSCRIPT_BUNDLE_VER/`git log --format="%h" -n 1`/" ../$(BUILD_TARGET); \ - rm -f ../$(BUILD_TARGET).bak + rm -f ../$(BUILD_TARGET).bak; \ rm -f *.tmp; \ cd .. diff --git a/src/canvas.js b/src/canvas.js index 0ad02dc24..4feac4efe 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -832,8 +832,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { }, setStrokeColor: function canvasGraphicsSetStrokeColor(/*...*/) { var cs = this.current.strokeColorSpace; - var color = cs.getRgb(arguments); - var color = Util.makeCssRgb.apply(null, cs.getRgb(arguments)); + var rgbColor = cs.getRgb(arguments); + var color = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); this.ctx.strokeStyle = color; this.current.strokeColor = color; }, @@ -870,7 +870,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { }, setFillColor: function canvasGraphicsSetFillColor(/*...*/) { var cs = this.current.fillColorSpace; - var color = Util.makeCssRgb.apply(null, cs.getRgb(arguments)); + var rgbColor = cs.getRgb(arguments); + var color = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); this.ctx.fillStyle = color; this.current.fillColor = color; }, diff --git a/src/evaluator.js b/src/evaluator.js index 60ab66560..21530f42f 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -292,8 +292,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { // Create an IR of the pattern code. var depIdx = dependencyArray.length; var queueObj = {}; - var codeIR = this.getIRQueue(pattern, dict.get('Resources'), - queueObj, dependencyArray); + var codeIR = this.getIRQueue(pattern, dict.get('Resources') || + resources, queueObj, dependencyArray); // Add the dependencies that are required to execute the // codeIR. @@ -336,8 +336,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { // This adds the IRQueue of the xObj to the current queue. var depIdx = dependencyArray.length; - this.getIRQueue(xobj, xobj.dict.get('Resources'), queue, - dependencyArray); + this.getIRQueue(xobj, xobj.dict.get('Resources') || resources, + queue, dependencyArray); // Add the dependencies that are required to execute the // codeIR. diff --git a/src/fonts.js b/src/fonts.js index 329d7ad77..616521a16 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -339,6 +339,21 @@ var stdFontMap = { 'TimesNewRomanPSMT-Italic': 'Times-Italic' }; +/** + * Holds the map of the non-standard fonts that might be included as a standard + * fonts without glyph data. + */ +var nonStdFontMap = { + 'ComicSansMS': 'Comic Sans MS', + 'ComicSansMS-Bold': 'Comic Sans MS-Bold', + 'ComicSansMS-BoldItalic': 'Comic Sans MS-BoldItalic', + 'ComicSansMS-Italic': 'Comic Sans MS-Italic', + 'LucidaConsole': 'Courier', + 'LucidaConsole-Bold': 'Courier-Bold', + 'LucidaConsole-BoldItalic': 'Courier-BoldOblique', + 'LucidaConsole-Italic': 'Courier-Oblique' +}; + var serifFonts = { 'Adobe Jenson': true, 'Adobe Text': true, 'Albertus': true, 'Aldus': true, 'Alexandria': true, 'Algerian': true, @@ -785,7 +800,7 @@ var Font = (function FontClosure() { // The file data is not specified. Trying to fix the font name // to be used with the canvas.font. var fontName = name.replace(/[,_]/g, '-'); - fontName = stdFontMap[fontName] || fontName; + fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName; this.bold = (fontName.search(/bold/gi) != -1); this.italic = (fontName.search(/oblique/gi) != -1) || @@ -2121,10 +2136,11 @@ var Font = (function FontClosure() { window.btoa(data) + ');'); var rule = "@font-face { font-family:'" + fontName + "';src:" + url + '}'; + var styleElement = document.createElement('style'); document.documentElement.getElementsByTagName('head')[0].appendChild( - document.createElement('style')); + styleElement); - var styleSheet = document.styleSheets[document.styleSheets.length - 1]; + var styleSheet = styleElement.sheet; styleSheet.insertRule(rule, styleSheet.cssRules.length); return rule; diff --git a/src/pattern.js b/src/pattern.js index dbe2e5c23..dff2a5b44 100644 --- a/src/pattern.js +++ b/src/pattern.js @@ -94,9 +94,9 @@ Shadings.RadialAxial = (function RadialAxialClosure() { var colorStops = []; for (var i = t0; i <= t1; i += step) { - var color = fn([i]); - var rgbColor = Util.makeCssRgb.apply(this, cs.getRgb(color)); - colorStops.push([(i - t0) / diff, rgbColor]); + var rgbColor = cs.getRgb(fn([i])); + var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]); + colorStops.push([(i - t0) / diff, cssColor]); } this.colorStops = colorStops; @@ -234,9 +234,9 @@ var TilingPattern = (function TilingPatternClosure() { tmpCtx.strokeStyle = ctx.strokeStyle; break; case PaintType.UNCOLORED: - color = Util.makeCssRgb.apply(this, color); - tmpCtx.fillStyle = color; - tmpCtx.strokeStyle = color; + var cssColor = Util.makeCssRgb(this, color[0], color[1], color[2]); + tmpCtx.fillStyle = cssColor; + tmpCtx.strokeStyle = cssColor; break; default: error('Unsupported paint type: ' + paintType); diff --git a/test/pdfs/issue1055.pdf.link b/test/pdfs/issue1055.pdf.link new file mode 100644 index 000000000..8e2e7107c --- /dev/null +++ b/test/pdfs/issue1055.pdf.link @@ -0,0 +1 @@ +http://mcpherrin.ca/code/mozilla/engl208b.pdf diff --git a/test/test.py b/test/test.py index 888bd9ce8..84c6498ce 100644 --- a/test/test.py +++ b/test/test.py @@ -9,7 +9,7 @@ USAGE_EXAMPLE = "%prog" # The local web server uses the git repo as the document root. DOC_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__),"..")) -ANAL = True +GIT_CLONE_CHECK = True DEFAULT_MANIFEST_FILE = 'test_manifest.json' EQLOG_FILE = 'eq.log' BROWSERLOG_FILE = 'browser.log' @@ -344,7 +344,7 @@ def verifyPDFs(manifestList): def setUp(options): # Only serve files from a pdf.js clone - assert not ANAL or os.path.isfile('../src/pdf.js') and os.path.isdir('../.git') + assert not GIT_CLONE_CHECK or os.path.isfile('../src/pdf.js') and os.path.isdir('../.git') if options.masterMode and os.path.isdir(TMPDIR): print 'Temporary snapshot dir tmp/ is still around.' diff --git a/test/test_manifest.json b/test/test_manifest.json index 2110ea52e..fce77e0b2 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -416,5 +416,12 @@ "md5": "d0b6137846df6e0fe058f234a87fb588", "rounds": 1, "type": "eq" + }, + { "id": "issue1055", + "file": "pdfs/issue1055.pdf", + "md5": "3ba56c2e48dce81da8669b1b9cf98ff0", + "rounds": 1, + "link": true, + "type": "eq" } ]