PIXI.BitmapFont

class BitmapFont

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

Constructor


new PIXI.BitmapFont(data: PIXI.BitmapFontData, textures: PIXI.Texture[] | PIXI.Texture<Dict>, ownsTextures: boolean) → {}
Parameters:
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.

Summary


Properties from BitmapFont

Array<Array<string>>
static ALPHA
Array<Array<string>>
static ALPHANUMERIC
Array<Array<string>>
static ASCII
Dict<PIXI.BitmapFont>
static available

Collection of available/installed fonts.

PIXI.IBitmapFontOptions
static defaultOptions
Array<Array<string>>
static NUMERIC
Dict<IBitmapFontCharacter>
chars

The map of characters by character code.

number
distanceFieldRange

The range of the distance field in pixels.

string
distanceFieldType

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

string
font

The name of the font face.

number
lineHeight

The line-height of the font face in pixels.

Dict<PIXI.Texture>
pageTextures

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

number
size

The size of the font face in pixels.

Methods from BitmapFont

Public Properties


ALPHA BitmapFont.ts:65
static ALPHA: Array<Array<string>>

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


 BitmapFont.from("ExampleFont", style, { chars: BitmapFont.ALPHA })
ALPHANUMERIC BitmapFont.ts:81
static ALPHANUMERIC: Array<Array<string>>

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

ASCII BitmapFont.ts:87
static ASCII: Array<Array<string>>

This character set consists of all the ASCII table.

See: http://www.asciitable.com/
available BitmapFont.ts:110
static available: Dict<PIXI.BitmapFont>

Collection of available/installed fonts.

defaultOptions BitmapFont.ts:94
static defaultOptions: PIXI.IBitmapFontOptions

Collection of default options when using BitmapFont.from.

Properties:
Name Type Attributes Default Value Description
chars string | Array<string> | Array<Array<string>>

<constant>

padding number

<optional>

4
resolution number

<optional>

1
textureHeight number

<optional>

512
textureWidth number

<optional>

512
NUMERIC BitmapFont.ts:73
static NUMERIC: Array<Array<string>>

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


 BitmapFont.from("ExampleFont", style, { chars: BitmapFont.NUMERIC })
chars BitmapFont.ts:122
chars: Dict<IBitmapFontCharacter>

The map of characters by character code.

distanceFieldRange BitmapFont.ts:128
distanceFieldRange: number

The range of the distance field in pixels.

distanceFieldType BitmapFont.ts:131
distanceFieldType: string

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

font BitmapFont.ts:113
font: string

The name of the font face.

lineHeight BitmapFont.ts:119
lineHeight: number

The line-height of the font face in pixels.

pageTextures BitmapFont.ts:125
pageTextures: Dict<PIXI.Texture>

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

size BitmapFont.ts:116
size: number

The size of the font face in pixels.

Public Methods


from BitmapFont.ts:317
static from(name: string, textStyle: PIXI.TextStyle | ITextStyle<Partial>, options: PIXI.IBitmapFontOptions) → {PIXI.BitmapFont}

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:


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

 const title = new PIXI.BitmapText("This is the title", { fontName: "TitleFont" });
Parameters:
Name Type Attributes Default Description
name string

The name of the custom font to use with BitmapText.

textStyle 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>

PIXI.BitmapFont.ALPHANUMERIC

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>

1

Render resolution for glyphs.

options.textureWidth number

<optional>

512

Optional width of atlas, smaller values to reduce memory.

options.textureHeight number

<optional>

512

Optional height of atlas, smaller values to reduce memory.

options.padding number

<optional>

4

Padding between glyphs on texture atlas.

Returns:
Type Description
PIXI.BitmapFont

Font generated by style options.

install BitmapFont.ts:252
static install(data: string | XMLDocument | PIXI.BitmapFontData, textures: PIXI.Texture | PIXI.Texture[] | Dict<PIXI.Texture>, ownsTextures: boolean) → {PIXI.BitmapFont}

Register a new bitmap font.

Parameters:
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.

Returns:
Type Description
PIXI.BitmapFont

Result font object with font, size, lineHeight and char fields.

uninstall BitmapFont.ts:300
static uninstall(name: string) → {void}

Remove bitmap font by name.

Parameters:
Name Type Description
name string

Name of the font to uninstall.

Returns:
Type Description
void
destroy BitmapFont.ts:228
destroy() → {void}

Remove references to created glyph textures.

Returns:
Type Description
void

Powered by webdoc!