Android: Allow specifying custom fonts in system3.ini

Now custom font files specified in system3.ini (as relative paths from the
game directory) can be loaded correctly.
This commit is contained in:
kichikuou
2021-06-06 22:08:07 +09:00
parent 14f4c38d85
commit 52eea935fe
+7 -2
View File
@@ -63,9 +63,14 @@ AGS::AGS(NACT* parent, const Config& config) : nact(parent), dirty(false)
// フォント
TTF_Init();
if (!config.font_file.empty()) {
rw_font = SDL_RWFromFile(config.font_file.c_str(), "rb");
if (!rw_font)
// We cannot use SDL_RWFromFile() here because it does not resolve
// relative paths using the current directory on Android.
FILE *fp = fopen(config.font_file.c_str(), "rb");
if (!fp)
parent->fatal("Cannot open font file %s", config.font_file.c_str());
rw_font = SDL_RWFromFP(fp, SDL_TRUE);
if (!rw_font)
parent->fatal("Cannot load font file %s: %s", config.font_file.c_str(), SDL_GetError());
} else {
rw_font = open_resource(FONT_RESOURCE_NAME, "fonts");
if (!rw_font)