Documentation / @debuffjp/core / BitmapFont
Class: BitmapFont
Defined in: render/bitmap-font.ts:39
A pixel font from a sprite sheet. Pass it as font to draw.text and draw.measure: glyphs land on whole pixels, so it stays crisp at any integer scale.
// assets/font@6x9.png: glyphs on a 6×9 grid, exported from Aseprite
const font = new BitmapFont({ frames: assets.frames("font"), chars: BitmapFont.ASCII });
draw.text("coins 3", 4, 4, { font, color: "#fbbf24" });Constructors
Constructor
new BitmapFont(
o):BitmapFont
Defined in: render/bitmap-font.ts:50
Parameters
o
Returns
BitmapFont
Properties
height
readonlyheight:number
Defined in: render/bitmap-font.ts:44
Cell height in pixels.
lineHeight
readonlylineHeight:number
Defined in: render/bitmap-font.ts:45
spacing
readonlyspacing:number
Defined in: render/bitmap-font.ts:46
ASCII
readonlystaticASCII:string
Defined in: render/bitmap-font.ts:41
Printable ASCII from space to "~", the order most font sheets use.
Methods
glyph()
glyph(
ch):Glyph|undefined
Defined in: render/bitmap-font.ts:69
Parameters
ch
string
Returns
Glyph | undefined
lineWidth()
lineWidth(
line):number
Defined in: render/bitmap-font.ts:83
Width of one line, without trailing spacing.
Parameters
line
string
Returns
number
measure()
measure(
text):object
Defined in: render/bitmap-font.ts:74
Size of text in pixels. Lines split on "\n".
Parameters
text
string
Returns
object
h
h:
number
w
w:
number