Skip to content

BitmapText

Creates a BitmapText

Renders a line or multiple lines of text using bitmap font.

The primary advantage of this class over Text is that all of your textures are pre-generated and loading, meaning that rendering is fast, and changing text has no performance implications.

Supporting character sets other than latin, such as CJK languages, may be impractical due to the number of characters.

To split a line you can use \n, \r or \r\n in your string.

PixiJS can auto-generate fonts on-the-fly using BitmapFont or use fnt files provided by: angelcode.com/products/bmfont/ for Windows or bmglyph.com for Mac.

You can also use SDF, MSDF and MTSDF BitmapFonts for vector-like scaling appearance provided by: github.com/soimy/msdf-bmfont-xml for SDF and MSDF fnt files or github.com/Chlumsky/msdf-atlas-gen for SDF, MSDF and MTSDF json files

A BitmapText can only be created when the font is loaded.

API

BitmapText Attributes

NameTypeDefaultDescription
anchor

number array object

0The anchor sets the origin point of the text.
anchor-xnumber0The x anchor sets the origin point of the text.
anchor-ynumber0The y anchor sets the origin point of the text.
styleobjectobjectThe style parameters.
textstring''The text to display.
alignenumleftThe alignment of the BitmapText.
font-namestringundefinedThe name of the font to use.
font-sizenumberundefinedThe size of the font.
letter-spacingnumberundefinedThe amount of spacing between letters.
max-widthnumberundefinedThe maximum width of the text before it wraps.
max-line-heightnumberundefinedThe maximum line height.
resolutionnumberundefinedThe resolution of the BitmapText.
dirtybooleanfalseWhether or not the text has changed.

more attributes in Container Props and PIXI.BitmapText

BitmapText Events

NameTypeDescription
renderfunctioncustom rendering listener

more events in Container Events

BitmapText Slots

NameDescription
defaultThe text to display.