Skip to content

Commit 67bd05b

Browse files
committed
fix to processing#8469 in dev-2.0
1 parent 3a7992c commit 67bd05b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/type/textCore.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,11 @@ function textCore(p5, fn) {
17901790
return { bounds, lines };
17911791
};
17921792

1793+
Renderer.prototype._trimEnd = function (str) {
1794+
// trim trailing linebreaks and whitespace only
1795+
return str.replace(/[\s\n]+$/, '');
1796+
};
1797+
17931798
/*
17941799
Adjust width, height of bounds based on current rectMode
17951800
* @private
@@ -2247,13 +2252,13 @@ function textCore(p5, fn) {
22472252
testLine = `${line + words[widx]}` + splitter;
22482253
testWidth = this._textWidthSingle(testLine);
22492254
if (line.length > 0 && testWidth > maxWidth) {
2250-
newLines.push(line.trim());
2255+
newLines.push(this._trimEnd(line));
22512256
line = `${words[widx]}` + splitter;
22522257
} else {
22532258
line = testLine;
22542259
}
22552260
}
2256-
newLines.push(line.trim());
2261+
newLines.push(this._trimEnd(line));
22572262
}
22582263
return newLines;
22592264
};

0 commit comments

Comments
 (0)