Skip to content

Commit

Permalink
Fix splitByGrapheme and circle ToSVG (#5544)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored Mar 2, 2019
1 parent 37b4275 commit e6f8692
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/shapes/circle.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
'<path d="M ' + startX + ' ' + startY,
' A ' + this.radius + ' ' + this.radius,
' 0 ', +largeFlag + ' 1', ' ' + endX + ' ' + endY,
'"', 'COMMON_PARTS', ' />\n'
'" ', 'COMMON_PARTS', ' />\n'
];
}
return svgString;
Expand Down
6 changes: 3 additions & 3 deletions src/shapes/textbox.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -349,7 +349,7 @@
lineWidth += additionalSpace;
}

if (!lineJustStarted) {
if (!lineJustStarted && !splitByGrapheme) {
line.push(infix);
}
line = line.concat(word);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '<g transform=\"matrix(1 0 0 1 10.5 10.5)\" >\n<path d=\"M 10 0 A 10 10 0 0 1 -10 0\"style=\"stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;\" />\n</g>\n');
assert.equal(svgClipPath, '\t<path d=\"M 10 0 A 10 10 0 0 1 -10 0\"transform=\"matrix(1 0 0 1 10.5 10.5)\" />\n', 'half circle as clipPath');
assert.equal(svg, '<g transform=\"matrix(1 0 0 1 10.5 10.5)\" >\n<path d=\"M 10 0 A 10 10 0 0 1 -10 0\" style=\"stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;\" />\n</g>\n');
assert.equal(svgClipPath, '\t<path d=\"M 10 0 A 10 10 0 0 1 -10 0\" transform=\"matrix(1 0 0 1 10.5 10.5)\" />\n', 'half circle as clipPath');
});

QUnit.test('fromElement', function(assert) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/textbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit e6f8692

Please sign in to comment.