diff options
Diffstat (limited to 'src/gui/font.h')
| -rw-r--r-- | src/gui/font.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gui/font.h b/src/gui/font.h index b38f822a..db964fb0 100644 --- a/src/gui/font.h +++ b/src/gui/font.h @@ -4,6 +4,7 @@ // for the face lifetime. #ifndef UI_FONT_H #define UI_FONT_H +#include <stddef.h> #include <stdint.h> #ifdef __cplusplus @@ -12,6 +13,15 @@ extern "C" { typedef struct UIFont UIFont; +// Every allocation FreeType, HarfBuzz and this shim make: C's malloc, calloc, +// realloc and free, implemented by gui.zig over a Zig allocator. HarfBuzz is +// compiled to call them (hb_malloc_impl and friends); FreeType gets them as +// each library's memory manager. +void *ui_malloc(size_t size); +void *ui_calloc(size_t count, size_t size); +void *ui_realloc(void *block, size_t size); +void ui_free(void *block); + // Parse the first face in an in-memory font. `data` must stay alive for the // lifetime of the font. Returns NULL on failure. UIFont *ui_font_new(const uint8_t *data, int32_t len); @@ -76,6 +86,12 @@ int ui_font_raster_centered(UIFont *f, float px, uint32_t glyph, int bold, void ui_font_free(UIFont *f); +// HarfBuzz makes a few process-wide objects on first use and keeps them for +// the life of the process (the default Unicode functions, the locale's +// language, hb-ft's font functions). Making them here, with `f`'s face, lets +// the caller hand them an allocator that does not count them as leaks. +void ui_font_prime(UIFont *f); + #ifdef __cplusplus } #endif |
