Module bank_fonts

Loads and caches bitmap fonts for the Micro2D engine.

Each font consists of a Lua data file and a PNG image sheet.

You can use my own tool called BMFont2Lua to convert your own BMFonts JSON files to Lua table.

Info:

  • Author: Sharper Dev

Functions

FontsBank.loadFont (id, fontPath) Loads a font from the given path and associates it with the given ID.
FontsBank.unloadFont (id) Frees the image sheet and removes the font associated with the ID.
FontsBank.getFont (id) Returns the cached font entry for the ID, or nil if it is not loaded.


Functions

FontsBank.loadFont (id, fontPath)
Loads a font from the given path and associates it with the given ID.

The font is stored in memory and can be retrieved using FontsBank.getFont(id).

Parameters:

  • id string The ID to associate the font with.
  • fontPath string The path to the font files. The font name should be the last part of the path, and the files should be named <fontName>.lua and <fontName>.png.

Returns:

    table The loaded font data.

Usage:

    local myFont = FontsBank.loadFont("myFont", "romfs/micro2d/fonts/myFont")
FontsBank.unloadFont (id)
Frees the image sheet and removes the font associated with the ID.

Parameters:

  • id string ID of the font to unload.

Usage:

    FontsBank.unloadFont("myFont")
FontsBank.getFont (id)
Returns the cached font entry for the ID, or nil if it is not loaded.

Parameters:

  • id string ID of the font to retrieve.

Returns:

    table|nil Font entry containing data and sheet.

Usage:

    local myFont = FontsBank.getFont("myFont")
generated by LDoc 1.5.0 Last updated 2026-10-04 12:53:32