Version
- Phaser Version: 4.0.0 (Vite bundler)
- Operating system: Windows 11
- Browser: Chrome 146.0.7680.178
Description
On games with pixelArt set to true, when a BitmapText horizontal origin is set to 0.5 some instances render incorrectly. In the example below, the instance with the text "Poker" is truncating the bitmaps for each letter:
I did some fiddling and I think this has to do with fractional horizontal coordinates when trying to position some texts. The problem does not happen when horizontal origin is set to 1 or 0:
Example Test Code
Game config:
const config: Phaser.Types.Core.GameConfig = {
type: Phaser.AUTO,
width: 800,
height: 450,
parent: 'game-container',
pixelArt: true,
roundPixels: true,
scale: {
zoom: 2,
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH
},
physics: {
default: 'arcade',
arcade: {
debug: false,
gravity: { y: 0, x: 0 }
}
},
backgroundColor: '#fff',
scene: [
new LoaderScene({ key: 'loader' }),
new TitleControllerScene({ key: 'title-controller' }),
new TitleMenuScene({ key: 'title-menu' }),
]
};
Scene code:
preload() {
this.load.bitmapFont('font-impact', '/fonts/Impact-BMFont.png', '/fonts/Impact-BMFont.xml');
}
create() {
// Render bug
this.scene.add.bitmapText(0, 0, 'font-impact', 'Poker').setOrigin(0.5, 0.5);
// Works fine
this.scene.add.bitmapText(0, 50, 'font-impact', 'New Game').setOrigin(0.5, 0.5);
}
It is important to note that it makes no difference if I set or not the bitmapText font size.
Additional Information
The issue does not happen when pixelArt is false.
Here's the bitmap font files needed to reproduce.
Impact-BMFont.xml
Version
Description
On games with
pixelArtset totrue, when a BitmapText horizontal origin is set to0.5some instances render incorrectly. In the example below, the instance with the text "Poker" is truncating the bitmaps for each letter:I did some fiddling and I think this has to do with fractional horizontal coordinates when trying to position some texts. The problem does not happen when horizontal origin is set to 1 or 0:
Example Test Code
Game config:
Scene code:
It is important to note that it makes no difference if I set or not the bitmapText font size.
Additional Information
The issue does not happen when
pixelArtisfalse.Here's the bitmap font files needed to reproduce.
Impact-BMFont.xml