From 52eea935feb7b3b0b66f4d85619adcb058451742 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sun, 6 Jun 2021 21:39:29 +0900 Subject: [PATCH] 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. --- src/sys/ags.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sys/ags.cpp b/src/sys/ags.cpp index 1fe4130..e83dc0b 100644 --- a/src/sys/ags.cpp +++ b/src/sys/ags.cpp @@ -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)