Merge pull request #5367 from rexrainbow/bugfix-text.basicWordWrap

Don't add white space when measure last word of a line
This commit is contained in:
Richard Davey 2020-11-20 11:37:21 +00:00 committed by GitHub
commit 401487d4b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -520,7 +520,12 @@ var Text = new Class({
{
var word = words[j];
var wordWidth = context.measureText(word).width;
var wordWidthWithSpace = wordWidth + whiteSpaceWidth;
var wordWidthWithSpace = wordWidth;
if (j < lastWordIndex)
{
wordWidthWithSpace += whiteSpaceWidth;
}
if (wordWidthWithSpace > spaceLeft)
{