From 306691b02acce8711ad82c8efc736164e1fe7cd2 Mon Sep 17 00:00:00 2001 From: Krow Savcik Date: Tue, 13 Feb 2024 18:31:38 +0200 Subject: feature: simple text rendering ability --- src/cdraw.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/cdraw.c') diff --git a/src/cdraw.c b/src/cdraw.c index ecec5de..6088df9 100644 --- a/src/cdraw.c +++ b/src/cdraw.c @@ -1,12 +1,18 @@ #include +#include +#include +#include #include #include +#define SBDF_IMPLEMENTATION +#define SBDF_USESDL +#include "sbdf.h" #include "cdraw.h" #include "types.h" +#include "debug.h" #include "action.h" #include "canvas.h" -#include "debug.h" #include "palette.h" #include "ui.h" @@ -21,6 +27,7 @@ typedef struct { SDL_Window *win; void *ren; +void *font; void *def_palette; struct Canvas* cur_canvas; @@ -50,12 +57,15 @@ main_quit() SDL_DestroyWindow(win); IMG_Quit(); SDL_Quit(); + SBDF_FontDestroy(font); + font = NULL; return 1; } uint main_window_init(const char *s) { + /* TODO: defer*/ int ss; if (SDL_Init(SDL_INIT_VIDEO) < 0) { printf("SDL_Init failed: %s\n", SDL_GetError()); @@ -88,6 +98,10 @@ main_window_init(const char *s) if (def_palette == NULL) return 1; + font = SBDF_FontLoad(def_font); + if (font == NULL) + return 1; + ui_create(def_theme_path); if (s == NULL) cur_canvas = canvas_init(64, 64, ren); -- cgit v1.2.3