mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 06:52:20 +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.
|
||||
|
|
|
@ -90,6 +90,7 @@ 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);
|
||||
GRRLIB_ttfFont* GRRLIB_LoadTTFFromFile (const char* filename);
|
||||
bool GRRLIB_ScrShot (const char* filename);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue