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) → {}
Name | Type | Attributes | Description |
---|---|---|---|
data | PIXI.BitmapFontData | ||
textures | PIXI.Texture[] | PIXI.Texture<Dict> | ||
ownsTextures | boolean |
<optional> |
Setting to |
Summary
Properties from BitmapFont
Array<Array<string>> |
|
Array<Array<string>> |
|
Array<Array<string>> |
|
Dict<PIXI.BitmapFont> |
Collection of available/installed fonts. |
PIXI.IBitmapFontOptions |
|
Array<Array<string>> |
|
Dict<IBitmapFontCharacter> |
The map of characters by character code. |
number |
The range of the distance field in pixels. |
string |
The kind of distance field for this font or "none". |
string |
The name of the font face. |
number |
The line-height of the font face in pixels. |
Dict<PIXI.Texture> |
The map of base page textures (i.e., sheets of glyphs). |
number |
The size of the font face in pixels. |
Methods from BitmapFont
PIXI.BitmapFont |
|
PIXI.BitmapFont |
|
void |
|
void |
Remove references to created glyph textures. |
Public Properties
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 })
static ALPHANUMERIC: Array<Array<string>>
This character set is the union of BitmapFont.ALPHA
and BitmapFont.NUMERIC
.
static ASCII: Array<Array<string>>
This character set consists of all the ASCII table.
static available: Dict<PIXI.BitmapFont>
Collection of available/installed fonts.
static defaultOptions: PIXI.IBitmapFontOptions
Collection of default options when using BitmapFont.from
.
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 |
static NUMERIC: Array<Array<string>>
This character set includes all decimal digits (from 0 to 9).
BitmapFont.from("ExampleFont", style, { chars: BitmapFont.NUMERIC })
distanceFieldRange: number
The range of the distance field in pixels.
distanceFieldType: string
The kind of distance field for this font or "none".
pageTextures: Dict<PIXI.Texture>
The map of base page textures (i.e., sheets of glyphs).
Public Methods
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" });
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, |
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. |
Type | Description |
---|---|
PIXI.BitmapFont |
Font generated by style options. |
static install(data: string | XMLDocument | PIXI.BitmapFontData, textures: PIXI.Texture | PIXI.Texture[] | Dict<PIXI.Texture>, ownsTextures: boolean) → {PIXI.BitmapFont}
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 |
Type | Description |
---|---|
PIXI.BitmapFont |
Result font object with font, size, lineHeight and char fields. |
static uninstall(name: string) → {void}
Remove bitmap font by name.
Name | Type | Description |
---|---|---|
name | string |
Name of the font to uninstall. |
Type | Description |
---|---|
void |
destroy() → {void}
Remove references to created glyph textures.
Type | Description |
---|---|
void |