From 101b74455c35909834f7a0bfd218a02d862838be Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Fri, 1 Dec 2017 10:22:35 -0500 Subject: [PATCH] Clear the canvas just before the image is ready to draw. --- src/svg-quirks-mode/svg-renderer.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/svg-quirks-mode/svg-renderer.js b/src/svg-quirks-mode/svg-renderer.js index 30e26c6..ccf09e3 100644 --- a/src/svg-quirks-mode/svg-renderer.js +++ b/src/svg-quirks-mode/svg-renderer.js @@ -299,15 +299,14 @@ class SvgRenderer { const ratio = this.getDrawRatio(); const bbox = this._measurements; - // Set up the canvas for drawing. - this._canvas.width = bbox.width * ratio; - this._canvas.height = bbox.height * ratio; - this._context.clearRect(0, 0, this._canvas.width, this._canvas.height); - this._context.scale(ratio, ratio); - // Convert the SVG text to an Image, and then draw it to the canvas. const img = new Image(); img.onload = () => { + // Set up the canvas for drawing. + this._canvas.width = bbox.width * ratio; + this._canvas.height = bbox.height * ratio; + this._context.clearRect(0, 0, this._canvas.width, this._canvas.height); + this._context.scale(ratio, ratio); this._context.drawImage(img, 0, 0); // Reset the canvas transform after drawing. this._context.setTransform(1, 0, 0, 1, 0, 0);