1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jonathan Gordon 2011-09-24 13:19:34 +00:00
parent f323300b82
commit aa0f4a4bbe
37 changed files with 410 additions and 404 deletions

View file

@ -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 */

View file

@ -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
}

View file

@ -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

View file

@ -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;

View file

@ -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