mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-30 18:58:07 +03:00
Android: Allow specifying custom fonts in .xsys35rc
Now custom font files specified in .xsys35rc (as relative paths from the ZIP root) can be loaded correctly. This fixes #20 for Android.
This commit is contained in:
+10
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user