Loads bitmap font from texture atlas and metrics file.
Takes bitmapPath (path to font texture atlas image file, PNG format), metricsPath (path to font metrics data file, .fnt format).
Returns font handle (positive integer for success, 0 for failure).
2D Overlay
Parameters & Returns
Parameters
bitmapPathString
metricsPathString
Returns
Int
Quick Summary
Loads bitmap font from texture atlas and metrics file.
Takes bitmapPath (path to font texture atlas image file, PNG format), metricsPath (path to font metrics data file, .fnt format).
Returns font handle (positive integer for success, 0 for failure).
Technical Exegesis...
Loads bitmap font from texture atlas and metrics file. Takes bitmapPath (path to font texture atlas image file, PNG format), metricsPath (path to font metrics data file, .fnt format). Returns font handle (positive integer for success, 0 for failure). Creates font resource with pre-rendered character glyphs, uploads texture to GPU, parses character metrics for layout.
Loads bitmap font from texture atlas and metrics file. Takes bitmapPath (path to font texture atlas image file, PNG format), metricsPath (path to font metrics data file, .fnt format). Returns font handle (positive integer for success, 0 for failure). Creates font resource with pre-rendered character glyphs, uploads texture to GPU, parses character metrics for layout.
Font file format: bitmap font (pre-rendered character atlas, not TrueType), texture atlas (all characters in single PNG image, packed efficiently), metrics file (character positions, sizes, kerning data in .fnt format), generated by font tools (BMFont, Hiero, etc).
Loading process: loads PNG texture (character atlas image, alpha channel for antialiasing), parses metrics file (character UVs, dimensions, offsets), uploads texture to GPU (cached in VRAM for rendering), stores metrics in CPU memory (for text layout calculations).
Use cases: (1) Load UI fonts (menu text, buttons, labels), (2) Load game fonts (score, health, dialogue), (3) Load styled fonts (titles, headers, special text), (4) Load multiple sizes (small UI, medium text, large titles).
Common patterns: load default font = myFont=b2dLoadFont("font.png", "font.fnt"); load sized fonts = smallFont=b2dLoadFont("font16.png", "font16.fnt"): largeFont=b2dLoadFont("font32.png", "font32.fnt"); check success = font=b2dLoadFont(path, metrics): If font=0 Then Print "Font load failed!" EndIf.
File requirements: bitmap path must be valid PNG (RGBA or RGB with alpha), metrics path must be valid .fnt format (BMFont-compatible XML or text), files must exist and be readable (returns 0 if missing), paths relative to executable or absolute.
Performance: loading cost ~10-50ms (depends on texture size), one-time cost at load time (not per-frame), texture stays in GPU memory (cached until freed), multiple loads of same font create new handles (not shared).
Error handling: returns 0 on failure (file not found, invalid format, out of memory), error logged to console (if verbose mode enabled), safe to continue on failure (0 handle ignored in draw functions).
Related: b2dFreeFont releases font resources, b2dDrawText uses font for rendering, b2dGetFontWidth queries font character width, b2dGetFontHeight queries font line height.