Merge pull request #4427 from rexrainbow/master

Fix bug about counting height of text object
This commit is contained in:
Richard Davey 2019-04-05 17:25:27 +01:00 committed by GitHub
commit d13e79a8db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View file

@ -58,9 +58,9 @@ var GetTextSize = function (text, size, lines)
var lineSpacing = text.lineSpacing; var lineSpacing = text.lineSpacing;
// Adjust for line spacing // Adjust for line spacing
if (lines.length > 1) if (drawnLines > 1)
{ {
height += lineSpacing * (lines.length - 1); height += lineSpacing * (drawnLines - 1);
} }
return { return {

View file

@ -532,7 +532,7 @@ var Text = new Class({
} }
result += words[j] + ' '; result += words[j] + ' ';
spaceLeft = wordWrapWidth - wordWidth; spaceLeft = wordWrapWidth - wordWidthWithSpace;
} }
else else
{ {
@ -1125,11 +1125,19 @@ var Text = new Class({
{ {
this.width = w; this.width = w;
} }
else
{
this.width = style.fixedWidth;
}
if (style.fixedHeight === 0) if (style.fixedHeight === 0)
{ {
this.height = h; this.height = h;
} }
else
{
this.height = style.fixedHeight;
}
this.updateDisplayOrigin(); this.updateDisplayOrigin();