From: Ulrich-Matthias Schäfer Date: Thu, 8 Nov 2018 12:53:14 +0000 (+0100) Subject: `SVG.Text.rebuild()` now takes every font-size into account (#512) X-Git-Tag: 3.0.0~43 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=15fd93ef07c1860fba7d7b285fe94dcb97c6f334;p=svg.js.git `SVG.Text.rebuild()` now takes every font-size into account (#512) --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fb06b0..8e09b70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http: - `clone()` does not add the clone to the dom anymore - `SVG.Text.textPath()` returns only the first textpath child - `attr()` excepts array now to get multiple values at once +- `SVG.Text.rebuild()` now takes every font-size into account (#512) ### Fixed - fixed a bug in clipping and masking where empty nodes persists after removal -> __TODO!__ diff --git a/dist/svg.js b/dist/svg.js index e80e6bd..ba031c9 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -6,7 +6,7 @@ * @copyright Wout Fierens * @license MIT * -* BUILT: Thu Nov 08 2018 12:57:03 GMT+0100 (GMT+01:00) +* BUILT: Thu Nov 08 2018 13:49:37 GMT+0100 (GMT+01:00) */; var SVG = (function () { 'use strict'; @@ -6313,8 +6313,11 @@ var SVG = (function () { if (this._rebuild) { var self = this; var blankLineOffset = 0; - var dy = this.dom.leading * new SVGNumber(this.attr('font-size')); + var leading = this.dom.leading; this.each(function () { + var fontSize = window.getComputedStyle(this.node).getPropertyValue('font-size'); + var dy = leading * new SVGNumber(fontSize); + if (this.dom.newLined) { this.attr('x', self.attr('x')); diff --git a/src/elements/Text.js b/src/elements/Text.js index f1aa402..f221004 100644 --- a/src/elements/Text.js +++ b/src/elements/Text.js @@ -122,9 +122,13 @@ export default class Text extends Shape { if (this._rebuild) { var self = this var blankLineOffset = 0 - var dy = this.dom.leading * new SVGNumber(this.attr('font-size')) + var leading = this.dom.leading this.each(function () { + var fontSize = window.getComputedStyle(this.node) + .getPropertyValue('font-size') + var dy = leading * new SVGNumber(fontSize) + if (this.dom.newLined) { this.attr('x', self.attr('x'))