Windows: Embed default font as a resource

After this, embedded MTLc3m.ttf is used unless the -fontfile option is
specified.
This commit is contained in:
kichikuou
2020-05-24 22:01:32 +09:00
parent b11ddd35c8
commit a0af5ef10c
8 changed files with 69 additions and 44 deletions
-28
View File
@@ -4,38 +4,10 @@
[ DRI ]
*/
#ifdef _WIN32
#include <windows.h>
#undef ERROR
#endif
#include "dri.h"
#include "crc32.h"
#include "../fileio.h"
namespace {
SDL_RWops* open_resource(const char* name, const char* type) {
#ifdef _WIN32
// On Windows, read from resource.
HINSTANCE hInst = GetModuleHandle(NULL);
HRSRC hRes = FindResource(hInst, name, type);
HGLOBAL hGlobal = LoadResource(hInst, hRes);
if (!hGlobal) {
WARNING("Cannot load resource %s (type: %s)", name, type);
return NULL;
}
return SDL_RWFromConstMem(LockResource(hGlobal), SizeofResource(hInst, hRes));
#else
// On Android, read from APK assets.
// On other platforms, read from a file under RESOURCE_PATH.
char path[_MAX_PATH];
sprintf_s(path, _MAX_PATH, "%s%s/%s", RESOURCE_PATH, type, name);
return SDL_RWFromFile(path, "rb");
#endif
}
} // namespace
uint8* DRI::load(const char* file_name, int page, int* size)
{
char tmp_name[_MAX_PATH];