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

@ -265,7 +265,7 @@ enum plugin_status plugin_start(const void* parameter)
{
int retval = 0;
rb->lcd_setfont(0);
rb->lcd_setfont(FONT_SYSFIXED);
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
rb->cpu_boost(true);

View file

@ -667,7 +667,7 @@ enum plugin_status plugin_start(const void* parameter)
rb->cpu_boost(true);
#endif
rb->lcd_setfont(0);
rb->lcd_setfont(FONT_SYSFIXED);
// We're using doom's memory management since it implements a proper free (and re-uses the memory)
// and now with prboom's code: realloc and calloc
@ -712,7 +712,7 @@ enum plugin_status plugin_start(const void* parameter)
Dhandle_ver( namemap[ result ] );
rb->lcd_setfont(0);
rb->lcd_setfont(FONT_SYSFIXED);
rb->lcd_clear_display();

View file

@ -433,6 +433,11 @@ RB_WRAP(font_getstringsize)
int fontnumber = luaL_checkint(L, 2);
int w, h;
if (fontnumber == FONT_UI)
fontnumber = rb->global_status->font_id[SCREEN_MAIN];
else
fontnumber = FONT_SYSFIXED;
int result = rb->font_getstringsize(str, &w, &h, fontnumber);
lua_pushinteger(L, result);
lua_pushinteger(L, w);

View file

@ -470,7 +470,7 @@ enum plugin_status plugin_start(const void* parameter)
rb->splash(HZ*2, " Play .MID file ");
return PLUGIN_OK;
}
rb->lcd_setfont(0);
rb->lcd_setfont(FONT_SYSFIXED);
#if defined(HAVE_ADJUSTABLE_CPU_FREQ)
rb->cpu_boost(true);

View file

@ -823,7 +823,7 @@ int playfile(char* filename)
retval = menureturn;
}
}
rb->lcd_setfont(0);
rb->lcd_setfont(FONT_SYSFIXED);
screenupdated = false;
break;
@ -877,7 +877,7 @@ enum plugin_status plugin_start(const void* parameter)
return PLUGIN_OK;
}
rb->lcd_setfont(0);
rb->lcd_setfont(FONT_SYSFIXED);
rb->pcm_play_stop();
#if INPUT_SRC_CAPS != 0

View file

@ -125,7 +125,7 @@ int do_user_menu(void) {
}
}
rb->lcd_setfont(0); /* Reset the font */
rb->lcd_setfont(FONT_SYSFIXED); /* Reset the font */
rb->lcd_clear_display(); /* Clear display for screen size changes */
/* Keep the RTC in sync */

View file

@ -409,7 +409,7 @@ static int gnuboy_main(const char *rom)
/* this is the plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
rb->lcd_setfont(0);
rb->lcd_setfont(FONT_SYSFIXED);
rb->lcd_clear_display();

View file

@ -1016,7 +1016,6 @@ static bool browse_fonts( char *dst, int dst_size )
size_t siz;
reset_font = true;
rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s", e->name );
rb->font_load(NULL, bbuf );
rb->font_getstringsize( e->name, &fw, &fh, FONT_UI );
if( fw > LCD_WIDTH ) fw = LCD_WIDTH;
siz = (sizeof(struct font_preview) + fw*fh*FB_DATA_SZ+3) & ~3;
@ -1083,7 +1082,7 @@ static bool browse_fonts( char *dst, int dst_size )
li = tree->filesindir-1;
if( reset_font )
{
rb->font_load(NULL, bbuf_s );
// fixme rb->font_load(NULL, bbuf_s );
reset_font = false;
}
if( lvi-fvi+1 < tree->filesindir )
@ -1636,6 +1635,7 @@ static void show_grid( bool update )
static void draw_text( int x, int y )
{
int selected = 0;
int current_font_id = rb->global_status->font_id[SCREEN_MAIN];
buffer->text.text[0] = '\0';
buffer->text.font[0] = '\0';
while( 1 )
@ -1648,9 +1648,12 @@ static void draw_text( int x, int y )
break;
case TEXT_MENU_FONT:
if( browse_fonts( buffer->text.font, MAX_PATH ) )
if (current_font_id != rb->global_status->font_id[SCREEN_MAIN])
rb->font_unload(current_font_id);
if(browse_fonts( buffer->text.font, MAX_PATH ) )
{
rb->font_load(NULL, buffer->text.font );
current_font_id = rb->font_load(buffer->text.font );
rb->lcd_setfont(current_font_id);
}
break;
@ -1704,7 +1707,9 @@ static void draw_text( int x, int y )
rb->snprintf( buffer->text.font, MAX_PATH,
FONT_DIR "/%s.fnt",
rb->global_settings->font_file );
rb->font_load(NULL, buffer->text.font );
if (current_font_id != rb->global_status->font_id[SCREEN_MAIN])
rb->font_unload(current_font_id);
rb->lcd_setfont(FONT_UI);
}
return;
}

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