From ab4046b852410a89c0d5b1fc7ae4380d8e184c04 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Thu, 5 Oct 2017 13:30:01 -0400 Subject: [PATCH] Only enlarge by half stroke width on either side --- src/svg-quirks-mode/svg-renderer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/svg-quirks-mode/svg-renderer.js b/src/svg-quirks-mode/svg-renderer.js index 23adc6a..016ce06 100644 --- a/src/svg-quirks-mode/svg-renderer.js +++ b/src/svg-quirks-mode/svg-renderer.js @@ -234,11 +234,11 @@ class SvgRenderer { // Enlarge the bbox from the largest found stroke width // This may have false-positives, but at least the bbox will always // contain the full graphic including strokes. - const largestStrokeWidth = this._findLargestStrokeWidth(this._svgTag); - bbox.width += largestStrokeWidth * 2; - bbox.height += largestStrokeWidth * 2; - bbox.x -= largestStrokeWidth; - bbox.y -= largestStrokeWidth; + const halfStrokeWidth = this._findLargestStrokeWidth(this._svgTag) / 2; + bbox.width += halfStrokeWidth * 2; + bbox.height += halfStrokeWidth * 2; + bbox.x -= halfStrokeWidth; + bbox.y -= halfStrokeWidth; // Set the correct measurements on the SVG tag, and save them. this._svgTag.setAttribute('width', bbox.width);