mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-22 19:39:24 +01:00
Don't exit on font load failure, add ARRAY_SIZE
This commit is contained in:
parent
a286b4b355
commit
d3ed78078c
12
utils.cpp
12
utils.cpp
@ -12,30 +12,26 @@ TTF_Font *read_and_alloc_font(const char *path, int pt_size)
|
||||
{
|
||||
TTF_Font *out;
|
||||
SDL_RWops *rw;
|
||||
Uint8 *data = (Uint8*)malloc(1 * 1024*1024);
|
||||
Uint8 *data = (Uint8*)xmalloc(1 * 1024*1024);
|
||||
FILE *fp = fopen(path, "r");
|
||||
|
||||
if (!data) {
|
||||
fprintf(stderr, "Malloc failed\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!fp) {
|
||||
fprintf(stderr, "Could not open font %s\n", path);
|
||||
exit(1);
|
||||
return NULL;
|
||||
}
|
||||
fread(data, 1, 1 * 1024 * 1024, fp);
|
||||
rw = SDL_RWFromMem(data, 1 * 1024 * 1024);
|
||||
if (!rw)
|
||||
{
|
||||
fprintf(stderr, "Could not create RW: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
out = TTF_OpenFontRW(rw, 1, pt_size);
|
||||
if (!out)
|
||||
{
|
||||
fprintf(stderr, "TTF: Unable to create font %s (%s)\n",
|
||||
path, TTF_GetError());
|
||||
exit(1);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user