Skip to content

BitmapFont

A bitmap font: glyphs by code point, kerning pairs, its size and line height (stage units at size). Made by engine.load (a BMFont) or engine.bitmapFont; texts use it with { bitmapFont: name }.

new BitmapFont(size, lineHeight, base, baker?, host?): BitmapFont

Use engine.bitmapFont or engine.load.

number

number

number

((code) => Glyph | null) | null

A generated font’s baker (null: a BMFont, glyphs given up front).

GlyphHost | null

A generated font’s engine side (bake again when its resolution, fonts, effects or atlas change).

BitmapFont

readonly size: number

The size its units are at: a text of this size draws the glyphs 1:1.


readonly lineHeight: number

The line’s height, font units.


readonly base: number

From the line’s top to the baseline, font units.

set(code, g): void

Sets a glyph (BMFont loading).

number

Glyph | null

void


setKerning(first, second, amount): void

Sets a kerning pair, font units.

number

number

number

void


prepare(): void

Before a draw: a generated font whose resolution, tier, web font or atlas changed forgets its glyphs.

void


glyph(code): Glyph | null

The glyph of a code point (baked now if the font is generated), or null.

number

Glyph | null


kerning(a, b): number

Kerning between two code points, font units (0 for most pairs).

number

number

number


measure(text): number

A string’s width, font units.

string

number


run(text, ctx?, m?, x0?, y0?, kx?, ky?, tint?, alpha?, blend?): number

Lays text out: its width, font units. With ctx, also draws it in the space of m, the line’s top-left at (x0, y0), font units scaled by kx, ky: one quad per glyph, nothing allocated (code points read in place).

string

DrawContext

Mat

number

number

number

number

number

number

Blend

number