LogoPixi’VN
pixi-jsClasses

Class: BitmapFontManager

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:346

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

Advanced

Example

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

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

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

Properties

ALPHA

> readonly static ALPHA: (string | string[])[]

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:249

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

Example

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

ALPHANUMERIC

> readonly static ALPHANUMERIC: (string | string[])[]

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:261

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


ASCII

> readonly static ASCII: string[][]

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:267

This character set consists of all the ASCII table.

See

http://www.asciitable.com/


defaultOptions

> static defaultOptions: Omit<BitmapFontInstallOptions, "style">

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:269

Default options for installing a new BitmapFont.


measureCache

> readonly static measureCache: LRU<BitmapTextLayoutData>

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:271

Cache for measured text layouts to avoid recalculating them multiple times.


NUMERIC

> readonly static NUMERIC: string[][]

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:256

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

Example

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

Methods

getFont()

> static getFont(text, style): BitmapFont

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:277

Get a font for the specified text and style.

Parameters

text

string

The text to get the font for

style

TextStyle

The style to use

Returns

BitmapFont


getLayout()

> static getLayout(text, style, trimEnd?): BitmapTextLayoutData

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:284

Get the layout of a text for the specified style.

Parameters

text

string

The text to get the layout for

style

TextStyle

The style to use

trimEnd?

boolean

Whether to ignore whitespaces at the end of each line

Returns

BitmapTextLayoutData


install()

Call Signature

> static install(options): BitmapFont

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:313

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

Parameters
options

BitmapFontInstallOptions

Setup options for font generation.

Returns

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' });

Call Signature

> static install(name, style?, options?): BitmapFont

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:315

Parameters
name

string

style?

TextStyle | TextStyleOptions

options?

BitmapFontInstallOptions

Returns

BitmapFont

Deprecated

since 7.0.0


measureText()

> static measureText(text, style, trimEnd?): object

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:291

Measure the text using the specified style.

Parameters

text

string

The text to measure

style

TextStyle

The style to use

trimEnd?

boolean

Whether to ignore whitespaces at the end of each line

Returns

object

height

> height: number

offsetY

> offsetY: number

scale

> scale: number

width

> width: number


uninstall()

> static uninstall(name): void

Defined in: node_modules/pixi.js/lib/scene/text-bitmap/BitmapFontManager.d.ts:320

Uninstalls a bitmap font from the cache.

Parameters

name

string

The name of the bitmap font to uninstall.

Returns

void