mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-12-22 18:39:18 +00:00
Add LoadTTFFromFile
This commit is contained in:
parent
c4321117e8
commit
72eae433e6
2 changed files with 31 additions and 4 deletions
|
@ -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.
|
||||
|
|
|
@ -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 :)
|
||||
|
|
Loading…
Reference in a new issue