Skip to content

Commit

Permalink
fix(svg_parser): ISSUE-6220 Allow to parse font declaration that star…
Browse files Browse the repository at this point in the history
…ts with number (#6222)

font property (start with font size)error
  • Loading branch information
Swedish-li authored Mar 20, 2020
1 parent 4ab3c36 commit f9648fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
value = 'stroke';
}
}
else if (attr === 'href' || attr === 'xlink:href') {
else if (attr === 'href' || attr === 'xlink:href' || attr === 'font') {
return value;
}
else {
Expand Down
15 changes: 15 additions & 0 deletions test/unit/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@
{ left: 100, top: 200, width: 600, height: 600 });
});

QUnit.test('parseAttributeFontValueStartWithFontSize', function(assert) {
var element = fabric.document.createElementNS(
'http://www.w3.org/2000/svg',
'path'
);
element.setAttribute('style', 'font: 15px arial, sans-serif;');
var styleObj = fabric.parseAttributes(element, ['font']);
var expectedObject = {
font: '15px arial, sans-serif',
fontSize: 15,
fontFamily: 'arial, sans-serif'
};
assert.deepEqual(styleObj, expectedObject);
});

QUnit.test('parseElements', function(assert) {
var done = assert.async();
assert.ok(typeof fabric.parseElements === 'function');
Expand Down

0 comments on commit f9648fc

Please sign in to comment.