Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fabric.Textbox): The same text does not need to be wrapped #6621

Merged
merged 2 commits into from
Sep 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/shapes/textbox.class.js
Original file line number Diff line number Diff line change
@@ -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;
14 changes: 14 additions & 0 deletions test/unit/textbox.js
Original file line number Diff line number Diff line change
@@ -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');
});

})();