diff --git a/GRRLIB/GRRLIB/GRRLIB_fileIO.c b/GRRLIB/GRRLIB/GRRLIB_fileIO.c index e875f62..f4350d6 100644 --- a/GRRLIB/GRRLIB/GRRLIB_fileIO.c +++ b/GRRLIB/GRRLIB/GRRLIB_fileIO.c @@ -81,7 +81,7 @@ GRRLIB_texImg* GRRLIB_LoadTextureFromFile(const char *filename) { GRRLIB_texImg *tex; u8 *data; - // return NULL it load fails + // Return NULL if load fails if (GRRLIB_LoadFile(filename, &data) <= 0) { return NULL; } @@ -95,6 +95,32 @@ GRRLIB_texImg* GRRLIB_LoadTextureFromFile(const char *filename) { return tex; } +/** + * Load a TTF from a file. + * @param filename The TTF filename to load. + * @return A GRRLIB_ttfFont structure filled with font information. + * If an error occurs NULL will be returned. + */ +GRRLIB_ttfFont* GRRLIB_LoadTTFFromFile(const char *filename) { + GRRLIB_ttfFont *ttf; + u8 *data; + + s32 size = GRRLIB_LoadFile(filename, &data); + + // Return NULL if load fails + if (size <= 0) { + return NULL; + } + + // Convert to TTF + ttf = GRRLIB_LoadTTF(data, size); + + // Free up the buffer + free(data); + + return ttf; +} + /** * Make a PNG screenshot. * It should be called after drawing stuff on the screen, but before GRRLIB_Render. diff --git a/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h b/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h index a27ca93..5a007fa 100644 --- a/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h +++ b/GRRLIB/GRRLIB/grrlib/GRRLIB__lib.h @@ -88,9 +88,10 @@ void GRRLIB_Circle (const f32 x, const f32 y, const f32 radius, //------------------------------------------------------------------------------ // GRRLIB_fileIO - File I/O (SD Card) -int GRRLIB_LoadFile (const char* filename, u8* *data); -GRRLIB_texImg* GRRLIB_LoadTextureFromFile (const char* filename); -bool GRRLIB_ScrShot (const char* filename); +int GRRLIB_LoadFile (const char* filename, u8* *data); +GRRLIB_texImg* GRRLIB_LoadTextureFromFile (const char* filename); +GRRLIB_ttfFont* GRRLIB_LoadTTFFromFile (const char* filename); +bool GRRLIB_ScrShot (const char* filename); //------------------------------------------------------------------------------ // GRRLIB_print.c - Will someone please tell me what these are :)