Class: BitmapFontManager

BitmapFontManager

The BitmapFontManager is a helper that exists to install and uninstall fonts into the cache for BitmapText objects.

new BitmapFontManager ()

Example

 import { BitmapFontManager, BitmapText } from 'pixi.js';

 BitmapFontManager.install({
   name: 'TitleFont',
   style: {}
 });

 const title = new BitmapText({ text: 'This is the title', style: { fontFamily: 'TitleFont' }});

Members

ALPHA Array<Array<string>> readonly

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

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

ALPHANUMERIC Array<Array<string>> readonly

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

ASCII Array<Array<string>> readonly

This character set consists of all the ASCII table.

See:

defaultOptions Omit<BitmapFontInstallOptions, "style">

Default options for installing a new BitmapFont.

NUMERIC Array<Array<string>> readonly

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

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

Methods

getFont (text, style) BitmapFont

Get a font for the specified text and style.

Name Type Description
text string

The text to get the font for

style TextStyle

The style to use

Returns:
Type Description
BitmapFont

getLayout (text, style, trimEnd) BitmapTextLayoutData

Get the layout of a text for the specified style.

Name Type Default Description
text string

The text to get the layout for

style TextStyle

The style to use

trimEnd boolean true

Whether to ignore whitespaces at the end of each line

Returns:
Type Description
BitmapTextLayoutData

install (…options) BitmapFont

Generates a bitmap-font for the given style and character set

Name Type Description
options [string | BitmapFontInstallOptions, unknown, unknown]

Setup options for font generation.

Returns:
Type Description
BitmapFont Font generated by style options.
Example
 import { BitmapFontManager, BitmapText } from 'pixi.js';

 BitmapFontManager.install('TitleFont', {
     fontFamily: 'Arial',
     fontSize: 12,
     strokeThickness: 2,
     fill: 'purple',
 });

 const title = new BitmapText({ text: 'This is the title', fontFamily: 'TitleFont' });

install (name, style, options) BitmapFont Deprecated`` : since 7.0.0

Name Type Attributes Description
name string
style TextStyle | TextStyleOptions <optional>
options BitmapFontInstallOptions <optional>
Returns:
Type Description
BitmapFont

measureText (text, style, trimEnd) {
   width: number,
   height: number,
   scale: number,
   offsetY: number
}

Measure the text using the specified style.

Name Type Default Description
text string

The text to measure

style TextStyle

The style to use

trimEnd boolean true

Whether to ignore whitespaces at the end of each line

Returns:
Type Description
{
   width: number,
   height: number,
   scale: number,
   offsetY: number
}

uninstall (name)

Uninstalls a bitmap font from the cache.

Name Type Description
name string

The name of the bitmap font to uninstall.