From 5587dd76de4d17038111e713d135e8a0a4f17453 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Wed, 8 Mar 2017 19:34:22 +0100 Subject: add ability to use `font()` method like `attr()` method (#620) --- src/sugar.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') 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) } }) -- cgit v1.2.3