#ifndef HUSH_FONTS_H
#define HUSH_FONTS_H
#include <SDL_ttf.h>
#include <stdint.h>
#define FONT_SANS_REGULAR 0
#define FONT_SANS_BOLD 1
#define FONT_SANS_ITALIC 2
#define FONT_SANS_BOLD_ITALIC 3
#define FONT_MONO_REGULAR 4
#define FONT_MONO_BOLD 5
#define FONT_MONO_ITALIC 6
#define FONT_MONO_BOLD_ITALIC 7
#define FONT_COUNT 8
/* The exact shape Clay's SDL2 renderer expects for its font-array parameter (see
vendor/clay_renderer_SDL2.c) -- defined here, the canonical single copy, rather than in that
vendored file, so fonts.c/editor.h/hittest.h/render.h can all share it. `font` is opened once
at an arbitrary placeholder size; every actual measure/draw call re-sets the real size via
TTF_SetFontSize first (see hittest.c/render.c), so the size it was opened at is irrelevant. */
typedef struct {
uint32_t fontId;
TTF_Font *font;
} SDL2_Font;
/* fonts[] must have room for FONT_COUNT entries. `overridePaths[i]`, if non-NULL, replaces the
bundled default for that slot (see font_index/FONT_* above); pass NULL for the whole array to
use only the bundled defaults. A bad override path falls back to the bundled default rather
than leaving an unusable font. */
void fonts_load(SDL2_Font *fonts, char *const *overridePaths);
void fonts_unload(SDL2_Font *fonts);
static inline int font_index(int mono, int bold, int italic) {
return (mono ? FONT_MONO_REGULAR : FONT_SANS_REGULAR) + (bold ? 1 : 0) + (italic ? 2 : 0);
}
#endif