From bf994849e0936b3c55c00c2dc745f63b0f259055 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Fri, 2 Mar 2012 14:43:25 +0200 Subject: [PATCH] bug fixes for body background & firefox font --- readme.md | 1 + src/Parse.js | 13 ++++++++++--- src/Renderer.js | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 71de62e..d579566 100644 --- a/readme.md +++ b/readme.md @@ -39,6 +39,7 @@ For more information and examples, please visit the niklasvh) * Added support for CORS images and option to create canvas as tainted (niklasvh) * Improved minification saved ~1K! (cobexer) * Added integrated support for Flashcanvas (niklasvh) diff --git a/src/Parse.js b/src/Parse.js index b2a9641..af6b425 100644 --- a/src/Parse.js +++ b/src/Parse.js @@ -286,9 +286,13 @@ html2canvas.Parse = function (element, images, opts) { } ctx.setVariable("fillStyle", color); - ctx.setVariable("font", font_variant + " " + bold + " " + font_style + " " + size + " " + family); - - + + /* + need to be defined in the order as defined in http://www.w3.org/TR/CSS21/fonts.html#font-shorthand + to properly work in Firefox + */ + ctx.setVariable("font", font_style+ " " + font_variant + " " + bold + " " + size + " " + family); + if (align){ ctx.setVariable("textAlign", "right"); }else{ @@ -1260,6 +1264,9 @@ html2canvas.Parse = function (element, images, opts) { parseElement(children[i], stack); } + + stack.backgroundColor = getCSS( body, "backgroundColor" ); + return stack; }; diff --git a/src/Renderer.js b/src/Renderer.js index acace9e..fe4a0b3 100644 --- a/src/Renderer.js +++ b/src/Renderer.js @@ -94,7 +94,7 @@ html2canvas.Renderer = function(parseQueue, opts){ canvas.height = canvas.style.height = (!usingFlashcanvas) ? options.height || zStack.ctx.height : Math.min(flashMaxSize, (options.height || zStack.ctx.height) ); fstyle = ctx.fillStyle; - ctx.fillStyle = "#fff"; + ctx.fillStyle = zStack.backgroundColor; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = fstyle;