Skip to content

Commit d13e79a

Browse files
authored
Merge pull request phaserjs#4427 from rexrainbow/master
Fix bug about counting height of text object
2 parents bc10276 + b562917 commit d13e79a

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/gameobjects/text/GetTextSize.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ var GetTextSize = function (text, size, lines)
5858
var lineSpacing = text.lineSpacing;
5959

6060
// Adjust for line spacing
61-
if (lines.length > 1)
61+
if (drawnLines > 1)
6262
{
63-
height += lineSpacing * (lines.length - 1);
63+
height += lineSpacing * (drawnLines - 1);
6464
}
6565

6666
return {

src/gameobjects/text/static/Text.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ var Text = new Class({
532532
}
533533

534534
result += words[j] + ' ';
535-
spaceLeft = wordWrapWidth - wordWidth;
535+
spaceLeft = wordWrapWidth - wordWidthWithSpace;
536536
}
537537
else
538538
{
@@ -1125,11 +1125,19 @@ var Text = new Class({
11251125
{
11261126
this.width = w;
11271127
}
1128+
else
1129+
{
1130+
this.width = style.fixedWidth;
1131+
}
11281132

11291133
if (style.fixedHeight === 0)
11301134
{
11311135
this.height = h;
11321136
}
1137+
else
1138+
{
1139+
this.height = style.fixedHeight;
1140+
}
11331141

11341142
this.updateDisplayOrigin();
11351143

0 commit comments

Comments
 (0)