summaryrefslogtreecommitdiff
path: root/apps/plugins/text_viewer/tv_display.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/text_viewer/tv_display.c')
-rw-r--r--apps/plugins/text_viewer/tv_display.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/apps/plugins/text_viewer/tv_display.c b/apps/plugins/text_viewer/tv_display.c
index d38f1b514c..2cf240db0e 100644
--- a/apps/plugins/text_viewer/tv_display.c
+++ b/apps/plugins/text_viewer/tv_display.c
@@ -255,7 +255,7 @@ void tv_set_layout(bool show_scrollbar)
255 int scrollbar_height = (show_scrollbar && preferences->horizontal_scrollbar)? 255 int scrollbar_height = (show_scrollbar && preferences->horizontal_scrollbar)?
256 TV_SCROLLBAR_HEIGHT + 1 : 0; 256 TV_SCROLLBAR_HEIGHT + 1 : 0;
257 257
258 row_height = preferences->font->height; 258 row_height = rb->font_get(preferences->font_id)->height;
259 259
260 header.x = 0; 260 header.x = 0;
261 header.y = 0; 261 header.y = 0;
@@ -282,6 +282,7 @@ void tv_set_layout(bool show_scrollbar)
282 vp_text.y += vertical_scrollbar.y; 282 vp_text.y += vertical_scrollbar.y;
283 vp_text.width = horizontal_scrollbar.w; 283 vp_text.width = horizontal_scrollbar.w;
284 vp_text.height = vertical_scrollbar.h; 284 vp_text.height = vertical_scrollbar.h;
285 vp_text.font = preferences->font_id;
285#else 286#else
286 (void) show_scrollbar; 287 (void) show_scrollbar;
287 288
@@ -334,16 +335,20 @@ static void tv_change_viewport(void)
334static bool tv_set_font(const unsigned char *font) 335static bool tv_set_font(const unsigned char *font)
335{ 336{
336 unsigned char path[MAX_PATH]; 337 unsigned char path[MAX_PATH];
337
338 if (font != NULL && *font != '\0') 338 if (font != NULL && *font != '\0')
339 { 339 {
340 rb->snprintf(path, MAX_PATH, "%s/%s.fnt", FONT_DIR, font); 340 rb->snprintf(path, MAX_PATH, "%s/%s.fnt", FONT_DIR, font);
341 if (rb->font_load(NULL, path) < 0) 341 if (preferences->font_id >= 0 &&
342 (preferences->font_id != rb->global_status->font_id[SCREEN_MAIN]))
343 rb->font_unload(preferences->font_id);
344 tv_change_fontid(rb->font_load(path));
345 if (preferences->font_id < 0)
342 { 346 {
343 rb->splash(HZ/2, "font load failed"); 347 rb->splash(HZ/2, "font load failed");
344 return false; 348 return false;
345 } 349 }
346 } 350 }
351 vp_text.font = preferences->font_id;
347 return true; 352 return true;
348} 353}
349#endif 354#endif
@@ -375,7 +380,7 @@ static int tv_change_preferences(const struct tv_preferences *oldp)
375 380
376 return (tv_set_preferences(&new_prefs))? TV_CALLBACK_STOP : TV_CALLBACK_ERROR; 381 return (tv_set_preferences(&new_prefs))? TV_CALLBACK_STOP : TV_CALLBACK_ERROR;
377 } 382 }
378 col_width = 2 * rb->font_get_width(preferences->font, ' '); 383 col_width = 2 * rb->font_get_width(rb->font_get(preferences->font_id), ' ');
379 font_changing = false; 384 font_changing = false;
380 } 385 }
381#else 386#else
@@ -402,9 +407,10 @@ void tv_finalize_display(void)
402{ 407{
403#ifdef HAVE_LCD_BITMAP 408#ifdef HAVE_LCD_BITMAP
404 /* restore font */ 409 /* restore font */
405 if (rb->strcmp(rb->global_settings->font_file, preferences->font_name)) 410 if (preferences->font_id >= 0 &&
411 (preferences->font_id != rb->global_status->font_id[SCREEN_MAIN]))
406 { 412 {
407 tv_set_font(rb->global_settings->font_file); 413 rb->font_unload(preferences->font_id);
408 } 414 }
409 415
410 /* undo viewport */ 416 /* undo viewport */