Skip to content

Commit

Permalink
fix: avoid blank space in the DynamicBitmapFont resource (pixijs#11025)
Browse files Browse the repository at this point in the history
  • Loading branch information
rnike authored Nov 8, 2024
1 parent ab3840f commit 10b663a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/scene/text-bitmap/DynamicBitmapFont.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ export class DynamicBitmapFont extends AbstractBitmapFont<DynamicBitmapFont>
let maxCharHeight = 0;
let skipTexture = false;

const maxTextureWidth = canvas.width / this.resolution;
const maxTextureHeight = canvas.height / this.resolution;

for (let i = 0; i < charList.length; i++)
{
const char = charList[i];
Expand All @@ -176,15 +179,15 @@ export class DynamicBitmapFont extends AbstractBitmapFont<DynamicBitmapFont>
maxCharHeight = Math.ceil(Math.max(paddedHeight, maxCharHeight));// / 1.5;
}

if (currentX + paddedWidth > this._textureSize)
if (currentX + paddedWidth > maxTextureWidth)
{
currentY += maxCharHeight;

// reset the line x and height..
maxCharHeight = paddedHeight;
currentX = 0;

if (currentY + maxCharHeight > this._textureSize)
if (currentY + maxCharHeight > maxTextureHeight)
{
textureSource.update();

Expand Down

0 comments on commit 10b663a

Please sign in to comment.