From 57d7bdc68b774c1e55ebc281786b93c7336eb4e4 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 21 Jan 2019 22:59:20 -0500 Subject: add src/sdl/font.[hc] --- src/sdl/main.c | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) (limited to 'src/sdl/main.c') diff --git a/src/sdl/main.c b/src/sdl/main.c index 852a5ae..7560d3f 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -15,37 +15,12 @@ #include "assets.h" #include "solve.h" #include "sounds.h" +#include "font.h" #define WINDOW_TITLE "Pablotron Sokoban" #define WINDOW_WIDTH 800 #define WINDOW_HEIGHT 600 -static TTF_Font * -load_font( - const asset_id_t id -) { - // get asset - const asset_t * const asset = asset_get(id); - if (!asset) { - die("asset_get()"); - } - - // create io - SDL_RWops *rw = SDL_RWFromConstMem(asset->buf, asset->len); - if (!rw) { - die("SDL_RWFromConstMem(): %s", SDL_GetError()); - } - - // load font - TTF_Font *font = TTF_OpenFontIndexRW(rw, 1, 16, 0); - if (!font) { - die("TTF_OpenFontIndex(): %s", TTF_GetError()); - } - - // return font - return font; -} - static void on_resize( draw_ctx_t * const draw_ctx @@ -288,7 +263,7 @@ int main(int argc, char *argv[]) { // init sprites, set window icon, load font sprites_init(renderer, draw_ctx.sprites); sprites_set_window_icon(win, SPRITE_HOME); - draw_ctx.font = load_font(ASSET_ROBOTO_TTF); + draw_ctx.font = font_load(ASSET_ROBOTO_TTF, 16); // register solve event const Uint32 solve_event_type = SDL_RegisterEvents(1); -- cgit v1.2.3