diff --git a/src/font.c b/src/font.c index 548f6be..7e6b591 100644 --- a/src/font.c +++ b/src/font.c @@ -80,7 +80,16 @@ void font_select(int type, int size) { TTF_Font *fs; fs = TTF_OpenFontIndex(this.name[type], size, this.face[type]); - +#ifdef __ANDROID__ + // If `this.name[type]` is a custom font file specified in .xys35rc, + // SDL_RWFromFile used by TTF_OpenFontIndex does not work because it + // does not resolve relative path with the current directory. On the + // other hand, we can't just use fopen because SDL_RWFromFile can open + // apk assets and the default fonts are stored as assets. + FILE *fp = fopen(this.name[type], "r"); + if (fp) + fs = TTF_OpenFontIndexRW(SDL_RWFromFP(fp, true), true, size, this.face[type]); +#endif if (fs == NULL) { WARNING("%s is not found:\n", this.name[type]); return;