Change getFontDeclaration (#3191)

* Change getFontDeclaration
This commit is contained in:
Andrea Bogazzi 2016-08-22 11:27:34 +02:00 committed by GitHub
parent 181cdec80c
commit 702126eb85
2 changed files with 11 additions and 2 deletions

View file

@ -844,7 +844,8 @@
},
/**
* @private
* return font declaration string for canvas context
* @returns {String} font declaration formatted for canvas context.
*/
_getFontDeclaration: function() {
return [
@ -852,7 +853,7 @@
(fabric.isLikelyNode ? this.fontWeight : this.fontStyle),
(fabric.isLikelyNode ? this.fontStyle : this.fontWeight),
this.fontSize + 'px',
(fabric.isLikelyNode ? ('"' + this.fontFamily + '"') : this.fontFamily)
'"' + this.fontFamily + '"'
].join(' ');
},

View file

@ -71,6 +71,14 @@
equal(text.toString(), '#<fabric.Text (1): { "text": "x", "fontFamily": "Times New Roman" }>');
});
test('_getFontDeclaration', function() {
var text = createTextObject();
ok(typeof text._getFontDeclaration == 'function', 'has a private method _getFontDeclaration');
var fontDecl = text._getFontDeclaration();
ok(typeof fontDecl == 'string', 'it returns a string');
equal(fontDecl, 'normal 40px "Times New Roman"');
});
test('toObject', function() {
var text = createTextObject();
ok(typeof text.toObject == 'function');