forked from len0rd/rockbox
Text viewer: Handle font loading failures
When font load fails, revert by loading to the previous font or to the global settings font. Fixes FS#11185 - Text viewer returns div by 0 if font is missing, renamed or corrupted git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25544 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
00b18de831
commit
c3f131de06
1 changed files with 8 additions and 12 deletions
|
@ -1693,18 +1693,11 @@ static bool change_font(unsigned char *font)
|
|||
rb->snprintf(buf, MAX_PATH, "%s/%s.fnt", FONT_DIR, font);
|
||||
if (rb->font_load(NULL, buf) < 0) {
|
||||
rb->splash(HZ/2, "Font load failed.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void revert_font(void)
|
||||
{
|
||||
if (rb->strcmp(prefs.font, rb->global_settings->font_file))
|
||||
change_font(rb->global_settings->font_file);
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool viewer_init(void)
|
||||
|
@ -2190,10 +2183,12 @@ read_end:
|
|||
start_position = file_pos + screen_top_ptr - buffer;
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
/* load prefs font if it is different than the global settings font */
|
||||
if (rb->strcmp(prefs.font, rb->global_settings->font_file)) {
|
||||
if (!change_font(prefs.font)) {
|
||||
revert_font();
|
||||
return false;
|
||||
/* fallback by re-loading the global settings font */
|
||||
if (!change_font(rb->global_settings->font_file))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2715,9 +2710,10 @@ static bool font_setting(void)
|
|||
|
||||
if (new_font != old_font)
|
||||
{
|
||||
if (!change_font(prefs.font))
|
||||
{
|
||||
revert_font();
|
||||
/* load selected font */
|
||||
if (!change_font((unsigned char *)names[new_font].string)) {
|
||||
/* revert by re-loading the preferences font */
|
||||
change_font(prefs.font);
|
||||
return false;
|
||||
}
|
||||
rb->memset(prefs.font, 0, MAX_PATH);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue