From e6f86928b92495bf231dee7017d144b4fa9bb15f Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 2 Mar 2019 15:06:28 +0100 Subject: [PATCH] Fix splitByGrapheme and circle ToSVG (#5544) --- src/shapes/circle.class.js | 2 +- src/shapes/textbox.class.js | 6 +++--- test/unit/circle.js | 4 ++-- test/unit/textbox.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/shapes/circle.class.js b/src/shapes/circle.class.js index 2cc6a72bd6d..25039a47c3c 100644 --- a/src/shapes/circle.class.js +++ b/src/shapes/circle.class.js @@ -106,7 +106,7 @@ '\n' + '" ', 'COMMON_PARTS', ' />\n' ]; } return svgString; diff --git a/src/shapes/textbox.class.js b/src/shapes/textbox.class.js index 34b2a54f533..9c269a4fd5c 100644 --- a/src/shapes/textbox.class.js +++ b/src/shapes/textbox.class.js @@ -68,7 +68,7 @@ * Use this regular expression to split strings in breakable lines * @private */ - _wordJoiners: /[ \t\r\u200B\u200C]/, + _wordJoiners: /[ \t\r]/, /** * Use this boolean property in order to split strings that have no white space concept. @@ -127,7 +127,7 @@ charCount++; realLineCount++; } - else if (this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) && i > 0) { + else if (!this.graphemeSplit && this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) && i > 0) { // this case deals with space's that are removed from end of lines when wrapping realLineCharCount++; charCount++; @@ -349,7 +349,7 @@ lineWidth += additionalSpace; } - if (!lineJustStarted) { + if (!lineJustStarted && !splitByGrapheme) { line.push(infix); } line = line.concat(word); diff --git a/test/unit/circle.js b/test/unit/circle.js index ddbb9103c78..b75234b1e85 100644 --- a/test/unit/circle.js +++ b/test/unit/circle.js @@ -150,8 +150,8 @@ var circle = new fabric.Circle({ width: 100, height: 100, radius: 10, endAngle: Math.PI }); var svg = circle.toSVG(); var svgClipPath = circle.toClipPathSVG(); - assert.equal(svg, '\n\n\n'); - assert.equal(svgClipPath, '\t\n', 'half circle as clipPath'); + assert.equal(svg, '\n\n\n'); + assert.equal(svgClipPath, '\t\n', 'half circle as clipPath'); }); QUnit.test('fromElement', function(assert) { diff --git a/test/unit/textbox.js b/test/unit/textbox.js index 9a60129edc0..2adeb11363f 100644 --- a/test/unit/textbox.js +++ b/test/unit/textbox.js @@ -131,7 +131,7 @@ assert.equal(textbox.textLines[0], 'xa', 'first line match expectations spacing 800'); }); QUnit.test('wrapping with different things', function(assert) { - var textbox = new fabric.Textbox('xa\u200Bxb\u200Bxc\u200Cxd\u200Cxe ya yb id', { + var textbox = new fabric.Textbox('xa xb\txc\rxd xe ya yb id', { width: 16, }); assert.equal(textbox.textLines[0], 'xa', '0 line match expectations');