Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rexrainbow committed Oct 7, 2024
1 parent 5796591 commit 0105a20
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/gameobjects/text/GetTextSize.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,21 @@ var GetTextSize = function (text, size, lines)
{
var lineWidth = style.strokeThickness;

lineWidth += context.measureText(lines[i]).width;

if (lines[i].length > 1)
if (text.letterSpacing === 0)
{
lineWidth += context.measureText(lines[i]).width;
}
else
{
lineWidth += text.letterSpacing * (lines[i].length - 1);
var line = lines[i];
for(var j=0; j< line.length; j++)
{
lineWidth += context.measureText(line[j]).width + text.letterSpacing;
}
if (line.length > 0)
{
lineWidth -= text.letterSpacing;
}
}

// Adjust for wrapped text
Expand Down

0 comments on commit 0105a20

Please sign in to comment.