mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2025-02-17 04:46:20 +01:00
33 lines
602 B
C++
33 lines
602 B
C++
![]() |
TTF_Font *read_font(const char *path)
|
||
|
{
|
||
|
TTF_Font *out;
|
||
|
SDL_RWops *rw;
|
||
|
Uint8 *data = (Uint8*)malloc(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\n");
|
||
|
exit(1);
|
||
|
}
|
||
|
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);
|
||
|
}
|
||
|
out = TTF_OpenFontRW(rw, 1, 20);
|
||
|
if (!out)
|
||
|
{
|
||
|
fprintf(stderr, "Unable to open font %s\n", path);
|
||
|
exit(1);
|
||
|
}
|
||
|
fclose(fp);
|
||
|
|
||
|
return out;
|
||
|
}
|