diff options
-rw-r--r-- | apps/plugins/text_viewer/tv_menu.c | 4 | ||||
-rw-r--r-- | apps/plugins/text_viewer/tv_window.c | 19 |
2 files changed, 11 insertions, 12 deletions
diff --git a/apps/plugins/text_viewer/tv_menu.c b/apps/plugins/text_viewer/tv_menu.c index d9b5343490..eb92782385 100644 --- a/apps/plugins/text_viewer/tv_menu.c +++ b/apps/plugins/text_viewer/tv_menu.c @@ -254,6 +254,7 @@ static bool tv_font_setting(void) int new_font = 0; int old_font; bool res; + unsigned char font_path[MAX_PATH]; struct tree_context *tree; struct tree_context backup; @@ -266,7 +267,8 @@ static bool tv_font_setting(void) rb->strlcat(backup.currdir, "/", MAX_PATH); rb->strlcat(backup.currdir, dc[tree->selected_item].name, MAX_PATH); tree->dirfilter = &dirfilter; - rb->set_current_file(FONT_DIR"/"); + rb->snprintf(font_path, MAX_PATH, "%s/", FONT_DIR); + rb->set_current_file(font_path); count = tree->filesindir; struct opt_items names[count]; diff --git a/apps/plugins/text_viewer/tv_window.c b/apps/plugins/text_viewer/tv_window.c index 676aff40ab..36fbb9268c 100644 --- a/apps/plugins/text_viewer/tv_window.c +++ b/apps/plugins/text_viewer/tv_window.c @@ -278,11 +278,11 @@ bool tv_traverse_lines(void) static void tv_change_preferences(const struct tv_preferences *oldp) { #ifdef HAVE_LCD_BITMAP - static bool is_executing = false; + static bool font_changing = false; const unsigned char *font_str; - is_executing = true; - font_str = oldp? oldp->font_name: rb->global_settings->font_file; + font_str = (oldp && !font_changing)? oldp->font_name : rb->global_settings->font_file; + font_changing = true; /* change font */ if (rb->strcmp(font_str, prefs->font_name)) @@ -291,25 +291,22 @@ static void tv_change_preferences(const struct tv_preferences *oldp) { struct tv_preferences new_prefs = *prefs; - if (!tv_set_font(font_str) && oldp != NULL) - { - font_str = rb->global_settings->font_file; - tv_set_font(font_str); - } - rb->strlcpy(new_prefs.font_name, font_str, MAX_PATH); tv_set_preferences(&new_prefs); } } + else if (!oldp || font_changing) + tv_set_font(font_str); /* calculates display lines */ tv_check_header_and_footer(); display_lines = tv_calc_display_lines(); - if (!is_executing) + /* if font_changing == false, the remaining processes need not be executed. */ + if (!font_changing) return; - is_executing = false; + font_changing = false; #else (void)oldp; |