Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ var drawing = module.exports = {};
// styling functions for plot elements
// -----------------------------------------------------

drawing.font = function(s, family, size, color, weight, style, variant) {
// also allow the form font(s, {family, size, color, weight, style, variant})
if(Lib.isPlainObject(family)) {
variant = family.variant;
style = family.style;
weight = family.weight;
color = family.color;
size = family.size;
family = family.family;
}
drawing.font = function(s, font) {
var variant = font.variant;
var style = font.style;
var weight = font.weight;
var color = font.color;
var size = font.size;
var family = font.family;

if(family) s.style('font-family', family);
if(size + 1) s.style('font-size', size + 'px');
if(color) s.call(Color.fill, color);
Expand Down
5 changes: 4 additions & 1 deletion test/jasmine/tests/drawing_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@ describe('Drawing', function() {
it('works with dummy nodes created in Drawing.tester', function() {
var node = Drawing.tester.append('text')
.text('bananas')
.call(Drawing.font, '"Open Sans", verdana, arial, sans-serif', 19)
.call(Drawing.font, {
family: '"Open Sans", verdana, arial, sans-serif',
size: 19
})
.call(svgTextUtils.convertToTspans).node();

expect(node.parentNode).toBe(Drawing.tester.node());
Expand Down