summaryrefslogtreecommitdiff
path: root/apps/plugins/text_viewer
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2011-09-24 13:19:34 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2011-09-24 13:19:34 +0000
commitaa0f4a4bbe370032d8166628f456709be1330118 (patch)
tree597c91fb16493881d7a281ef3c28e274a899022b /apps/plugins/text_viewer
parentf323300b82aa945dd4cadb20d8d7e23a6602ef49 (diff)
downloadrockbox-aa0f4a4bbe370032d8166628f456709be1330118.zip
rockbox-aa0f4a4bbe370032d8166628f456709be1330118.tar.gz
rockbox-aa0f4a4bbe370032d8166628f456709be1330118.tar.bz2
rockbox-aa0f4a4bbe370032d8166628f456709be1330118.tar.xz
FS#12273 - use buflib for font storage. thanks to the testers :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30589 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/text_viewer')
-rw-r--r--apps/plugins/text_viewer/tv_display.c18
-rw-r--r--apps/plugins/text_viewer/tv_preferences.c10
-rw-r--r--apps/plugins/text_viewer/tv_preferences.h4
-rw-r--r--apps/plugins/text_viewer/tv_settings.c2
-rw-r--r--apps/plugins/text_viewer/tv_text_processor.c2
5 files changed, 26 insertions, 10 deletions
diff --git a/apps/plugins/text_viewer/tv_display.c b/apps/plugins/text_viewer/tv_display.c
index d38f1b5..2cf240d 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)
int scrollbar_height = (show_scrollbar && preferences->horizontal_scrollbar)?
TV_SCROLLBAR_HEIGHT + 1 : 0;
- row_height = preferences->font->height;
+ row_height = rb->font_get(preferences->font_id)->height;
header.x = 0;
header.y = 0;
@@ -282,6 +282,7 @@ void tv_set_layout(bool show_scrollbar)
vp_text.y += vertical_scrollbar.y;
vp_text.width = horizontal_scrollbar.w;
vp_text.height = vertical_scrollbar.h;
+ vp_text.font = preferences->font_id;
#else
(void) show_scrollbar;
@@ -334,16 +335,20 @@ static void tv_change_viewport(void)
static bool tv_set_font(const unsigned char *font)
{
unsigned char path[MAX_PATH];
-
if (font != NULL && *font != '\0')
{
rb->snprintf(path, MAX_PATH, "%s/%s.fnt", FONT_DIR, font);
- if (rb->font_load(NULL, path) < 0)
+ if (preferences->font_id >= 0 &&
+ (preferences->font_id != rb->global_status->font_id[SCREEN_MAIN]))
+ rb->font_unload(preferences->font_id);
+ tv_change_fontid(rb->font_load(path));
+ if (preferences->font_id < 0)
{
rb->splash(HZ/2, "font load failed");
return false;
}
}
+ vp_text.font = preferences->font_id;
return true;
}
#endif
@@ -375,7 +380,7 @@ static int tv_change_preferences(const struct tv_preferences *oldp)
return (tv_set_preferences(&new_prefs))? TV_CALLBACK_STOP : TV_CALLBACK_ERROR;
}
- col_width = 2 * rb->font_get_width(preferences->font, ' ');
+ col_width = 2 * rb->font_get_width(rb->font_get(preferences->font_id), ' ');
font_changing = false;
}
#else
@@ -402,9 +407,10 @@ void tv_finalize_display(void)
{
#ifdef HAVE_LCD_BITMAP
/* restore font */
- if (rb->strcmp(rb->global_settings->font_file, preferences->font_name))
+ if (preferences->font_id >= 0 &&
+ (preferences->font_id != rb->global_status->font_id[SCREEN_MAIN]))
{
- tv_set_font(rb->global_settings->font_file);
+ rb->font_unload(preferences->font_id);
}
/* undo viewport */
diff --git a/apps/plugins/text_viewer/tv_preferences.c b/apps/plugins/text_viewer/tv_preferences.c
index 6d5c112..86719ae 100644
--- a/apps/plugins/text_viewer/tv_preferences.c
+++ b/apps/plugins/text_viewer/tv_preferences.c
@@ -114,7 +114,7 @@ void tv_set_default_preferences(struct tv_preferences *p)
p->footer_mode = true;
p->statusbar = true;
rb->strlcpy(p->font_name, rb->global_settings->font_file, MAX_PATH);
- p->font = rb->font_get(FONT_UI);
+ p->font_id = rb->global_status->font_id[SCREEN_MAIN];
#else
p->header_mode = false;
p->footer_mode = false;
@@ -133,3 +133,11 @@ void tv_add_preferences_change_listner(int (*listner)(const struct tv_preference
if (listner_count < TV_MAX_LISTNERS)
listners[listner_count++] = listner;
}
+
+void tv_change_fontid(int id)
+{
+ (void)id;
+#ifdef HAVE_LCD_BITMAP
+ prefs.font_id = id;
+#endif
+}
diff --git a/apps/plugins/text_viewer/tv_preferences.h b/apps/plugins/text_viewer/tv_preferences.h
index bb448b0..f3b2aeb 100644
--- a/apps/plugins/text_viewer/tv_preferences.h
+++ b/apps/plugins/text_viewer/tv_preferences.h
@@ -95,7 +95,7 @@ struct tv_preferences {
#ifdef HAVE_LCD_BITMAP
unsigned char font_name[MAX_PATH];
- struct font *font;
+ int font_id;
#endif
unsigned char file_name[MAX_PATH];
};
@@ -151,4 +151,6 @@ void tv_set_default_preferences(struct tv_preferences *p);
*/
void tv_add_preferences_change_listner(int (*listner)(const struct tv_preferences *oldp));
+
+void tv_change_fontid(int id);
#endif
diff --git a/apps/plugins/text_viewer/tv_settings.c b/apps/plugins/text_viewer/tv_settings.c
index 3ed1576..895f162 100644
--- a/apps/plugins/text_viewer/tv_settings.c
+++ b/apps/plugins/text_viewer/tv_settings.c
@@ -218,7 +218,7 @@ static bool tv_read_preferences(int pfd, int version, struct tv_preferences *pre
#ifdef HAVE_LCD_BITMAP
rb->strlcpy(prefs->font_name, buf + read_size - MAX_PATH, MAX_PATH);
- prefs->font = rb->font_get(FONT_UI);
+ prefs->font_id = rb->global_status->font_id[SCREEN_MAIN];
#endif
return true;
diff --git a/apps/plugins/text_viewer/tv_text_processor.c b/apps/plugins/text_viewer/tv_text_processor.c
index edb2ad0..d027a9a 100644
--- a/apps/plugins/text_viewer/tv_text_processor.c
+++ b/apps/plugins/text_viewer/tv_text_processor.c
@@ -95,7 +95,7 @@ static int tv_glyph_width(int ch)
if (rb->is_diacritic(ch, NULL))
return 0;
- return rb->font_get_width(preferences->font, ch);
+ return rb->font_get_width(rb->font_get(preferences->font_id), ch);
#else
return 1;
#endif