Skip to content

Commit

Permalink
Merge pull request pixijs#695 from mowday/dev
Browse files Browse the repository at this point in the history
Removed the trailing whitespace when wordwrapping a textfield
  • Loading branch information
GoodBoyDigital committed Apr 11, 2014
2 parents 7c1c6a9 + a435bf4 commit 07b0d9b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pixi/text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,21 +331,21 @@ PIXI.Text.prototype.wordWrap = function(text)
{
var wordWidth = this.context.measureText(words[j]).width;
var wordWidthWithSpace = wordWidth + this.context.measureText(' ').width;
if(wordWidthWithSpace > spaceLeft)
if(j === 0 || wordWidthWithSpace > spaceLeft)
{
// Skip printing the newline if it's the first word of the line that is
// greater than the word wrap width.
if(j > 0)
{
result += '\n';
}
result += words[j] + ' ';
result += words[j];
spaceLeft = this.style.wordWrapWidth - wordWidth;
}
else
{
spaceLeft -= wordWidthWithSpace;
result += words[j] + ' ';
result += ' ' + words[j];
}
}

Expand Down

0 comments on commit 07b0d9b

Please sign in to comment.