diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-03-08 19:34:22 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-03-08 19:34:22 +0100 |
commit | 5587dd76de4d17038111e713d135e8a0a4f17453 (patch) | |
tree | e34c7b3ca2404b7401a5b832fac1490419a3c928 /src | |
parent | 1f7a0ac6b903eb90ef8468aa2b2bd95d5df43c34 (diff) | |
download | svg.js-5587dd76de4d17038111e713d135e8a0a4f17453.tar.gz svg.js-5587dd76de4d17038111e713d135e8a0a4f17453.zip |
add ability to use `font()` method like `attr()` method (#620)
Diffstat (limited to 'src')
-rw-r--r-- | src/sugar.js | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/sugar.js b/src/sugar.js index 098c892..e577ea7 100644 --- a/src/sugar.js +++ b/src/sugar.js @@ -101,16 +101,17 @@ SVG.extend(SVG.Path, { SVG.extend(SVG.Parent, SVG.Text, SVG.Tspan, SVG.FX, { // Set font - font: function(o) { - for (var k in o) - k == 'leading' ? - this.leading(o[k]) : - k == 'anchor' ? - this.attr('text-anchor', o[k]) : - k == 'size' || k == 'family' || k == 'weight' || k == 'stretch' || k == 'variant' || k == 'style' ? - this.attr('font-'+ k, o[k]) : - this.attr(k, o[k]) + font: function(a, v) { + if (typeof a == 'object') { + for (v in a) this.font(v, a[v]) + } - return this + return a == 'leading' ? + this.leading(v) : + a == 'anchor' ? + this.attr('text-anchor', v) : + a == 'size' || a == 'family' || a == 'weight' || a == 'stretch' || a == 'variant' || a == 'style' ? + this.attr('font-'+ a, v) : + this.attr(a, v) } }) |