[Phaser3] BMFFactory, create bitmapfonts at runtime

Hi all,
This class creates bitmapfonts at runtime and adds them to the bitmapfonts cache, using default or already loaded browser fonts (included webfonts).

Features

  • Converts any loaded font[1] in the browser to a bitmapfont, ready to use in Phaser3 at runtime.
  • Shares same texture for multiple bitmapfonts.
  • Ensures power of two texture size (optional).
  • Calcs kernings for 97 commonly used pairs. (optional).[2]
  • Supports list of fallback fonts.
  • Predefined fallback font lists for sans-serif, sans, and monospace types.

Repository and more info: https://github.com/jjcapellan/phaser3-bitmapfont-factory
Demo: https://jjcapellan.github.io/phaser3-bitmapfont-factory/
I hope you find it useful !!


  1. Fonts with ligatures are not supported. ↩︎

  2. In Phaser 3.55.2/WebGL kernings are not used by bitmapText objects. This was fixed in new Phaser v3.60. ↩︎

3 Likes

Update:
New version v1.1.1 adds support for the latest versions of Phaser(>3.55.2).
The latest changes made to Phaser have allowed font generation to be more than 4 times faster (Thanks Phaser contributors :grinning:).

1 Like