Class: BitmapFont


BitmapFont represents a typeface available for use with the BitmapText class. Use the install method for adding a font to be used.

new PIXI.BitmapFont (data, textures, ownsTextures)

Name Type Attributes Description
data PIXI.BitmapFontData
textures PIXI.Texture[] | PIXI.Texture<Dict>
ownsTextures boolean <optional>

Setting to true will destroy page textures when the font is uninstalled.


PIXI.BitmapFont.ALPHA Array<Array<string>> staticreadonly

This character set includes all the letters in the alphabet (both lower- and upper- case).


 BitmapFont.from("ExampleFont", style, { chars: BitmapFont.ALPHA })

PIXI.BitmapFont.ALPHANUMERIC Array<Array<string>> staticreadonly

This character set is the union of BitmapFont.ALPHA and BitmapFont.NUMERIC.

PIXI.BitmapFont.ASCII Array<Array<string>> staticreadonly

This character set consists of all the ASCII table.


PIXI.BitmapFont.available Dict<PIXI.BitmapFont> staticreadonly

Collection of available/installed fonts.

PIXI.BitmapFont.defaultOptions PIXI.IBitmapFontOptions staticreadonly

Collection of default options when using BitmapFont.from.

Name Type Attributes Value Description
chars string | Array<string> | Array<Array<string>> <constant>
padding number <constant>
resolution number <constant>
textureHeight number <constant>
textureWidth number <constant>

PIXI.BitmapFont.NUMERIC Array<Array<string>> staticreadonly

This character set includes all decimal digits (from 0 to 9).


 BitmapFont.from("ExampleFont", style, { chars: BitmapFont.NUMERIC })

chars Dict<IBitmapFontCharacter> readonly

The map of characters by character code.

distanceFieldRange number readonly

The range of the distance field in pixels.

distanceFieldType string readonly

The kind of distance field for this font or "none".

font string readonly

The name of the font face.

lineHeight number readonly

The line-height of the font face in pixels.

pageTextures Dict<PIXI.Texture> readonly

The map of base page textures (i.e., sheets of glyphs).

size number readonly

The size of the font face in pixels.


PIXI.BitmapFont.from (name, style, options) PIXI.BitmapFont static

Generates a bitmap-font for the given style and character set. This does not support kernings yet. With style properties, only the following non-layout properties are used:

Name Type Attributes Default Description
name string

The name of the custom font to use with BitmapText.

style PIXI.TextStyle | ITextStyle<Partial> <optional>

Style options to render with BitmapFont.

options PIXI.IBitmapFontOptions <optional>

Setup options for font or name of the font.

options.chars string | Array<string> | Array<Array<string>> <optional>

characters included in the font set. You can also use ranges. For example, [['a', 'z'], ['A', 'Z'], "!@#$%^&*()~{}[] "]. Don't forget to include spaces ' ' in your character set!

options.resolution number <optional>

Render resolution for glyphs.

options.textureWidth number <optional>

Optional width of atlas, smaller values to reduce memory.

options.textureHeight number <optional>

Optional height of atlas, smaller values to reduce memory.

options.padding number <optional>

Padding between glyphs on texture atlas.

Type Description
PIXI.BitmapFont Font generated by style options.

 PIXI.BitmapFont.from("TitleFont", {
     fontFamily: "Arial",
     fontSize: 12,
     strokeThickness: 2,
     fill: "purple"

 const title = new PIXI.BitmapText("This is the title", { fontName: "TitleFont" });

PIXI.BitmapFont.install (data, textures, ownsTextures) PIXI.BitmapFont static

Register a new bitmap font.

Name Type Attributes Description
data string | XMLDocument | PIXI.BitmapFontData

The characters map that could be provided as xml or raw string.

textures PIXI.Texture | PIXI.Texture[] | Dict<PIXI.Texture>

List of textures for each page.

ownsTextures boolean <optional>

Set to true to destroy page textures when the font is uninstalled. By default fonts created with BitmapFont.from or from the BitmapFontLoader are true.

Type Description
PIXI.BitmapFont Result font object with font, size, lineHeight and char fields.

PIXI.BitmapFont.uninstall (name) void static

Remove bitmap font by name.

Name Type Description
name string

Name of the font to uninstall.

destroy () void

Remove references to created glyph textures.