Loading...
Searching...
No Matches
fonts.h
Go to the documentation of this file.
1
11#pragma once
12#include <pebble.h>
13
18
23typedef uint8_t FontId;
24
28#ifndef FONT_SLOTS_MAX
29#define FONT_SLOTS_MAX 24
30#endif
31
32// a FontId is a uint8_t, and the registry turns away an id past the cap, which needs one id above
33// it. at 256 the SDK's -Werror stops the build on a compare that can never be true
34#if FONT_SLOTS_MAX < 1 || FONT_SLOTS_MAX > 255
35#error "FONT_SLOTS_MAX has to be 1 to 255"
36#endif
37
59void fonts_register(FontId id, GFont handle);
60
78bool fonts_load(FontId id, uint32_t resource_id);
79
113bool fonts_swap(FontId id, uint32_t resource_id);
114
125void fonts_register_system(FontId id, GFont handle);
126
133GFont fonts_get(FontId id);
134
141void fonts_unload_all(void);
142
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.
Definition fonts.c:112
GFont fonts_get(FontId id)
Resolve a slot id to its handle. Falls back to the system font on a miss.
Definition fonts.c:75
bool fonts_swap(FontId id, uint32_t resource_id)
Swap the font in a slot for another resource, freeing the one it held.
Definition fonts.c:129
uint8_t FontId
A font slot id. The face defines its slots as 0 to FONT_SLOTS_MAX-1 and the registry treats the id as...
Definition fonts.h:23
void fonts_unload_all(void)
Unload every font the app owns and clear the registry.
Definition fonts.c:107
void fonts_register_system(FontId id, GFont handle)
Store a system font handle under its slot id, without taking ownership.
Definition fonts.c:64
void fonts_register(FontId id, GFont handle)
Store a loaded font handle under its slot id.
Definition fonts.c:53