diff --git a/src/shapes/textbox.class.js b/src/shapes/textbox.class.js index 2cd5eab3d88..4d01c150e4d 100644 --- a/src/shapes/textbox.class.js +++ b/src/shapes/textbox.class.js @@ -335,7 +335,7 @@ offset += word.length; lineWidth += infixWidth + wordWidth - additionalSpace; - if (lineWidth >= desiredWidth && !lineJustStarted) { + if (lineWidth > desiredWidth && !lineJustStarted) { graphemeLines.push(line); line = []; lineWidth = wordWidth; diff --git a/test/unit/textbox.js b/test/unit/textbox.js index 149530732bc..7d1a511ca4a 100644 --- a/test/unit/textbox.js +++ b/test/unit/textbox.js @@ -516,4 +516,18 @@ assert.equal(textbox.styleHas('fontFamily', 1), true, 'style has fontFamily on line 1'); }); + QUnit.test('The same text does not need to be wrapped.', function(assert) { + var str = '0123456789'; + var measureTextbox = new fabric.Textbox(str, { + fontSize: 20, + splitByGrapheme: false, + }); + var newTextbox = new fabric.Textbox(str, { + width: measureTextbox.width, + fontSize: 20, + splitByGrapheme: true, + }); + assert.equal(newTextbox.textLines.length, measureTextbox.textLines.length, 'The same text is not wrapped'); + }); + })();