Font registry implementation. A flat id-indexed table of loaded handles, with the decisions about owning and freeing them in core's font_slots.c. More...
Functions | |
| static void * | load_font (uint32_t resource) |
| Loads a font from its resource, for font_slots.c. | |
| static void | unload_font (void *handle) |
| Frees a font the app loaded, for font_slots.c. | |
| void | fonts_register (FontId id, GFont handle) |
| Store a loaded font handle under its slot id. | |
| void | fonts_register_system (FontId id, GFont handle) |
| Store a system font handle under its slot id, without taking ownership. | |
| GFont | fonts_get (FontId id) |
| Resolve a slot id to its handle. Falls back to the system font on a miss. | |
| void | fonts_unload_all (void) |
| Unload every font the app owns and clear the registry. | |
| bool | fonts_load (FontId id, uint32_t resource_id) |
| Load a custom font from its resource and register it under its slot id, in one call. | |
| bool | fonts_swap (FontId id, uint32_t resource_id) |
| Swap the font in a slot for another resource, freeing the one it held. | |
Variables | |
| static void * | s_fonts [FONT_SLOTS_MAX] |
| Loaded font handles, indexed by FontId. | |
| static uint8_t | s_states [FONT_SLOTS_MAX] |
| A FontSlotState for each slot: whether the app loaded the handle and so has to free it, and whether the slot records the resource it came from. | |
| static uint32_t | s_resources [FONT_SLOTS_MAX] |
| The resource each slot's font was loaded from, read only while its state says it was. | |
| static const FontSlots | s_slots = {.handles = s_fonts, .states = s_states, .count = FONT_SLOTS_MAX} |
| The tables handed to font_slots.c. | |
Font registry implementation. A flat id-indexed table of loaded handles, with the decisions about owning and freeing them in core's font_slots.c.
|
static |
Loads a font from its resource, for font_slots.c.
| resource | The font's resource id. |
|
static |
Frees a font the app loaded, for font_slots.c.
| handle | The font to free. |
|
static |
The resource each slot's font was loaded from, read only while its state says it was.
Only fonts_load and fonts_swap reach this, so a face that calls neither leaves it out of its build.
|
static |
A FontSlotState for each slot: whether the app loaded the handle and so has to free it, and whether the slot records the resource it came from.
A system font is parked with fonts_register_system and stays unowned, because unloading one the firmware owns faults.