FS#13944 - FONT_UI loads the last loaded font not global_status.font_id
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Tue, 30 Jun 2026 13:32:07 -0400
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit d87755c535f5c8caea70bd2664ae60ee8d860825 Author: William Wilgus <[email protected]> Date: Tue Jun 30 02:54:17 2026 -0400 FS#13944 - FONT_UI loads the last loaded font not global_status.font_id FONT_UI scans from MAXFONTS-1 to 0 to maximize the chances of getting a loaded font but this may result in global_status.font_id being ignored even if set through setuifont this should take care of all the plugin woes dues to this by setting the lcd font to the ui font before loading the plugin and also making FONT_UI map to this font when font_get(FONT_UI) is called if the desired font is not loaded then fallback to the previous behavior Change-Id: I101d6f91910c17b08fca2b988a0a99c9e6899bee diff --git a/apps/plugin.c b/apps/plugin.c index 336a18ad3b..d06e9936e3 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -1012,6 +1012,8 @@ int plugin_load(const char* plugin, const void* parameter) if (!global_settings.talk_menu) talk_buffer_set_policy(TALK_BUFFER_LOOSE); + screen_helper_setfont(FONT_UI); + plugin_check_open_close__enter(); int rc = p_hdr->entry_point(parameter); /* run the loaded plugin */ diff --git a/apps/screen_access.c b/apps/screen_access.c index 65faf2d516..ed497fc9e4 100644 --- a/apps/screen_access.c +++ b/apps/screen_access.c @@ -57,9 +57,11 @@ static int screen_helper_getnblines(void) void screen_helper_setfont(int font) { - (void)font; if (font == FONT_UI) + { font = global_status.font_id[SCREEN_MAIN]; + set_ui_font(font); + } lcd_setfont(font); } @@ -71,6 +73,7 @@ static int screen_helper_getuifont(void) static void screen_helper_setuifont(int font) { global_status.font_id[SCREEN_MAIN] = font; + set_ui_font(font); } static void screen_helper_set_drawmode(int mode) diff --git a/firmware/export/font.h b/firmware/export/font.h index 10f43d6911..7040cbef2f 100644 --- a/firmware/export/font.h +++ b/firmware/export/font.h @@ -53,6 +53,7 @@ enum { /* SYSFONT, FONT_UI, FONT_UI_REMOTE + MAXUSERFONTS fonts in skins */ #define MAXFONTS (FONT_FIRSTUSERFONT + MAXUSERFONTS) #define FONT_UI MAXFONTS +#define FONT_LASTUSERFONT (MAXFONTS-1) /* * .fnt loadable font file format definition @@ -131,6 +132,8 @@ void font_disable_all(void); void font_enable_all(void); struct font* font_get(int font); +void set_ui_font(int font); /* when FONT_UI is supplied this font will be tried first */ + int font_measurestring(const unsigned char *str, size_t maxbytes, size_t maxwidth, int *w, int *h, int fontnum); int font_getstringnsize(const unsigned char *str, size_t maxbytes, int *w, int *h, int fontnumber); int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber); diff --git a/firmware/font.c b/firmware/font.c index 4d0edb77f8..9ea194038a 100644 --- a/firmware/font.c +++ b/firmware/font.c @@ -108,6 +108,7 @@ struct buflib_alloc_data { unsigned char buffer[]; }; static int buflib_allocations[MAXFONTS]; +static int ui_font = FONT_LASTUSERFONT; static int cache_fd; static struct font* cache_pf; @@ -709,9 +710,10 @@ void font_enable_all(void) */ struct font* font_get(int font) { + bool is_ui_font = (font == FONT_UI); struct font* pf; - if (font == FONT_UI) - font = MAXFONTS-1; + if (is_ui_font) + font = ui_font; if (font <= FONT_SYSFIXED || font >= MAXFONTS) return &sysfont; @@ -724,10 +726,30 @@ struct font* font_get(int font) return pf; } if (--font < 0) - return &sysfont; + { + if (is_ui_font && ui_font != FONT_LASTUSERFONT) + { + /* The users preferred UI font couldn't be loaded */ + ui_font = FONT_LASTUSERFONT; + font = ui_font; /* try from the top to find something loaded */ + } + else + return &sysfont; /* Nothing else is available */ + } } } +/* When FONT_UI is supplied to font_get this font will be tried first if it is + * not loaded then fall back to default of any loaded font wins */ +void set_ui_font(int font) +{ + /* Note: we don't allow setting FONT_SYSFIXED here */ + if (font > FONT_SYSFIXED && font < MAXFONTS) + ui_font = font; + else /* default (same as supplying FONT_UI) */ + ui_font = FONT_LASTUSERFONT; +} + /* * Reads an entry into cache entry */ -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs