Skip to content

Commit

Permalink
Twist logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rexrainbow committed Oct 7, 2024
1 parent 0105a20 commit 03ce4ce
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/gameobjects/text/GetTextSize.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,26 @@ var GetTextSize = function (text, size, lines)
style.syncFont(canvas, context);

// Text Width
var letterSpacing = text.letterSpacing;

for (var i = 0; i < drawnLines; i++)
{
var lineWidth = style.strokeThickness;

if (text.letterSpacing === 0)
if (letterSpacing === 0)
{
lineWidth += context.measureText(lines[i]).width;
}
else
{
var line = lines[i];

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

lineWidth += letterSpacing * (line.length - 1);
}

// Adjust for wrapped text
Expand Down

0 comments on commit 03ce4ce

Please sign in to comment.