From a3fd9061efd29918bbc2cc272756a4ae99f53199 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Fri, 11 Mar 2016 06:14:40 +0100 Subject: [PATCH 1/5] Add shadow to outer group of text --- src/shapes/text.class.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shapes/text.class.js b/src/shapes/text.class.js index fb448ccd794..87b350d55a9 100644 --- a/src/shapes/text.class.js +++ b/src/shapes/text.class.js @@ -881,8 +881,10 @@ * @private */ _wrapSVGTextAndBg: function(markup, textAndBg) { + var noShadow = true; markup.push( - '\t\n', + '\t\n', textAndBg.textBgRects.join(''), '\t\t\n', + 'style="', this.getSvgStyles(noShadow), '" >\n', textAndBg.textSpans.join(''), '\t\t\n', '\t\n' From cc9d826d4c6b9171777dc94470f88711caeb759d Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Fri, 11 Mar 2016 06:16:42 +0100 Subject: [PATCH 2/5] add ability to skip shadow to style export This is necessary for text now. --- src/mixins/object.svg_export.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mixins/object.svg_export.js b/src/mixins/object.svg_export.js index 20e85462027..5e01cf04d91 100644 --- a/src/mixins/object.svg_export.js +++ b/src/mixins/object.svg_export.js @@ -5,7 +5,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot * Returns styles-string for svg-export * @return {String} */ - getSvgStyles: function() { + getSvgStyles: function(skipShadow) { var fill = this.fill ? (this.fill.toLive ? 'url(#SVGID_' + this.fill.id + ')' : this.fill) @@ -23,7 +23,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1', visibility = this.visible ? '' : ' visibility: hidden;', - filter = this.getSvgFilter(); + filter = skipShadow ? '' : this.getSvgFilter(); return [ 'stroke: ', stroke, '; ', From bb9aef97264d76ba4667829f42c7dda8418fb35e Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Fri, 11 Mar 2016 06:37:23 +0100 Subject: [PATCH 3/5] do not output useless empty style declaration --- src/shapes/text.class.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/shapes/text.class.js b/src/shapes/text.class.js index 87b350d55a9..984bf363247 100644 --- a/src/shapes/text.class.js +++ b/src/shapes/text.class.js @@ -881,10 +881,12 @@ * @private */ _wrapSVGTextAndBg: function(markup, textAndBg) { - var noShadow = true; + var noShadow = true, filter = this.getSvgFilter(), + style = filter === '' ? '' : ' style="' + this.getSvgFilter() + '"'; + markup.push( - '\t\n', + '\t\n', textAndBg.textBgRects.join(''), '\t\t Date: Fri, 11 Mar 2016 10:52:20 +0100 Subject: [PATCH 4/5] Do not call 2 times this.getSvgFilter() --- src/shapes/text.class.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shapes/text.class.js b/src/shapes/text.class.js index 984bf363247..7b9f417747a 100644 --- a/src/shapes/text.class.js +++ b/src/shapes/text.class.js @@ -882,7 +882,7 @@ */ _wrapSVGTextAndBg: function(markup, textAndBg) { var noShadow = true, filter = this.getSvgFilter(), - style = filter === '' ? '' : ' style="' + this.getSvgFilter() + '"'; + style = filter === '' ? '' : ' style="' + filter + '"'; markup.push( '\t Date: Fri, 11 Mar 2016 11:09:12 +0100 Subject: [PATCH 5/5] improved docs --- src/mixins/object.svg_export.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mixins/object.svg_export.js b/src/mixins/object.svg_export.js index 5e01cf04d91..4bcc008a259 100644 --- a/src/mixins/object.svg_export.js +++ b/src/mixins/object.svg_export.js @@ -3,6 +3,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot /** * Returns styles-string for svg-export + * @param {Boolean} skipShadow a boolean to skip shadow filter output * @return {String} */ getSvgStyles: function(skipShadow) {