Skip to content

Commit 82a513d

Browse files
authored
Merge pull request #6980 from plotly/reduce-font-args
Simplify drawing font args
2 parents d9308bd + d68cd0c commit 82a513d

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/components/drawing/index.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@ var drawing = module.exports = {};
2727
// styling functions for plot elements
2828
// -----------------------------------------------------
2929

30-
drawing.font = function(s, family, size, color, weight, style, variant) {
31-
// also allow the form font(s, {family, size, color, weight, style, variant})
32-
if(Lib.isPlainObject(family)) {
33-
variant = family.variant;
34-
style = family.style;
35-
weight = family.weight;
36-
color = family.color;
37-
size = family.size;
38-
family = family.family;
39-
}
30+
drawing.font = function(s, font) {
31+
var variant = font.variant;
32+
var style = font.style;
33+
var weight = font.weight;
34+
var color = font.color;
35+
var size = font.size;
36+
var family = font.family;
37+
4038
if(family) s.style('font-family', family);
4139
if(size + 1) s.style('font-size', size + 'px');
4240
if(color) s.call(Color.fill, color);

test/jasmine/tests/drawing_test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,10 @@ describe('Drawing', function() {
422422
it('works with dummy nodes created in Drawing.tester', function() {
423423
var node = Drawing.tester.append('text')
424424
.text('bananas')
425-
.call(Drawing.font, '"Open Sans", verdana, arial, sans-serif', 19)
425+
.call(Drawing.font, {
426+
family: '"Open Sans", verdana, arial, sans-serif',
427+
size: 19
428+
})
426429
.call(svgTextUtils.convertToTspans).node();
427430

428431
expect(node.parentNode).toBe(Drawing.tester.node());

0 commit comments

Comments
 (0)