Base64 Bitmap Font
This example demonstrates how to load a bitmap font by providing Base64 encoded strings for both the image texture and the XML font data, instead of using external file paths.
800 × 600
// #module
import { carrierCommandFont, carrierCommandXML } from '../../../assets/base64/carrier-command-font.js';
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.bitmapFont('carrier', carrierCommandFont, carrierCommandXML);
}
create ()
{
this.add.bitmapText(64, 200, 'carrier', 'Bitmap Fonts\nloading via base64\nin Phaser 3');
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);