Create a PIXI.BitmapText instance with this text "1111111111111111111111111". Remember its width, then change the text to "1" and check the width again, it will be the same.
This problem exists when PIXI.BitmapText instance has PIXI.Mesh instance as children with more than 199 vertices
https://pixijs.io/examples/#/text/bitmap-text.js
Paste this code:
const app = new PIXI.Application({ backgroundColor: 0x1099bb });
document.body.appendChild(app.view);
app.loader
.add('desyrel', 'examples/assets/bitmap-font/desyrel.xml')
.load(onAssetsLoaded);
function onAssetsLoaded() {
const bitmapFontText = new PIXI.BitmapText('11111111111111111111111111111111111111111111111', { font: '55px Desyrel'});
console.log(bitmapFontText.width);
bitmapFontText.x = 50;
bitmapFontText.y = 200;
bitmapFontText.text = '1';
console.log(bitmapFontText.width);
app.stage.addChild(bitmapFontText);
}
pixi.js
version: 5.3.2Here's a JSFiddle version:
https://jsfiddle.net/bigtimebuddy/syt6gdpb/
Here's a JSFiddle version:
https://jsfiddle.net/bigtimebuddy/syt6gdpb/
As I understand, this problem arises because we don't clean vertices buffer when new text smaller than previous.
Check how this condition works
Probably zeroing out the vertex buffer would fix this problem, if it not newly created.
Most helpful comment
As I understand, this problem arises because we don't clean vertices buffer when new text smaller than previous.
Check how this condition works