File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff 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 } ;
You can’t perform that action at this time.
0 commit comments