diff --git a/src/shapes/text.class.js b/src/shapes/text.class.js index e4ff78c4e9a..324f780dd5d 100644 --- a/src/shapes/text.class.js +++ b/src/shapes/text.class.js @@ -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(' '); }, diff --git a/test/unit/text.js b/test/unit/text.js index c9faac4e1f2..2450bef89ff 100644 --- a/test/unit/text.js +++ b/test/unit/text.js @@ -71,6 +71,14 @@ equal(text.toString(), '#'); }); + 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');