PixiJS provides three text rendering systems, each with different tradeoffs:
Text: High-quality, styled raster textBitmapText: Ultra-fast, GPU-optimized bitmap fontsHTMLText: Richly formatted HTML inside the Pixi sceneEach approach has tradeoffs in fidelity, speed, and flexibility.
Text: Rich dynamic text with stylesThe Text class renders using the browser's native text engine, then converts the result into a texture.
import { Text } from 'pixi.js';
const text = new Text({
text: 'Hello PixiJS!',
style: {
fontFamily: 'Arial',
fontSize: 32,
fill: '#ffffff',
}
});
Use it when:
Avoid when:
BitmapText: High-performance glyph renderingBitmapText draws characters from a pre-baked bitmap font image, bypassing font rasterization entirely.
import { BitmapFont, BitmapText } from 'pixi.js';
BitmapFont.install({
name: 'Game Font',
style: {
fontFamily: 'Arial',
fontSize: 32,
fill: '#ffffff'
}
});
const text = new BitmapText({
text: 'High Performance!',
style: {
fontFamily: 'Game Font',
fontSize: 32
}
});
Use it when:
Avoid when:
To use BitmapText, you must first register a bitmap font via:
BitmapFont.install(...) to create on the fly, orAssets.load(...) if using a 3rd-party BMFont or AngelCode exportHTMLText: Styled HTML inside the sceneHTMLText renders HTML markup in your PixiJS scene using SVG <foreignObject>.
import { HTMLText } from 'pixi.js';
const text = new HTMLText({
text: '<b>Bold</b> and <i>Italic</i>',
style: {
fontSize: 24,
fill: '#ffffff'
}
});
Use it when:
<b>, <i>, <span>)Avoid when:
| Metric | Text |
BitmapText |
HTMLText |
|---|---|---|---|
| Memory usage | Medium (one texture per string) | Low (shared texture atlas) | High (DOM elements + textures) |
| Rendering speed | Medium | Fast | Slow |
| Update speed | Slow for frequent updates | Fast for any updates | Medium |
TextBitmapTextHTMLTextText. Switch to BitmapText if you hit performance issues.