diff --git a/src/scene/text-bitmap/DynamicBitmapFont.ts b/src/scene/text-bitmap/DynamicBitmapFont.ts index 6b5bb58b2a..caa75e8ff0 100644 --- a/src/scene/text-bitmap/DynamicBitmapFont.ts +++ b/src/scene/text-bitmap/DynamicBitmapFont.ts @@ -150,6 +150,9 @@ export class DynamicBitmapFont extends AbstractBitmapFont 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]; @@ -176,7 +179,7 @@ export class DynamicBitmapFont extends AbstractBitmapFont maxCharHeight = Math.ceil(Math.max(paddedHeight, maxCharHeight));// / 1.5; } - if (currentX + paddedWidth > this._textureSize) + if (currentX + paddedWidth > maxTextureWidth) { currentY += maxCharHeight; @@ -184,7 +187,7 @@ export class DynamicBitmapFont extends AbstractBitmapFont maxCharHeight = paddedHeight; currentX = 0; - if (currentY + maxCharHeight > this._textureSize) + if (currentY + maxCharHeight > maxTextureHeight) { textureSource.update();