diff -u -r rockbox_svn.orig/apps/filetree.c rockbox_svn/apps/filetree.c
--- rockbox_svn.orig/apps/filetree.c 2007-08-08 22:00:00.265625000 -0500
+++ rockbox_svn/apps/filetree.c 2007-09-30 07:08:04.078125000 -0500
@@ -496,8 +496,34 @@
#ifdef HAVE_LCD_BITMAP
case FILE_ATTR_FONT:
gui_syncsplash(0, ID2P(LANG_WAIT));
- font_load(buf);
- set_file(buf, (char *)global_settings.font_file, MAX_FILENAME);
+ /* If a font is chosen it overrides all theme settings */
+ font_load(buf, FONT_BROWSER);
+
+ /* set_file will change buf!!!
+ * so make a copy */
+ char buf_copy[MAX_PATH];
+ strcpy(buf_copy, buf);
+ set_file(buf_copy, (char *)global_settings.browserfont, MAX_FILENAME);
+
+ font_load(buf, FONT_WPS);
+ strcpy(buf_copy, buf);
+ set_file(buf_copy, (char *)global_settings.wpsfont, MAX_FILENAME);
+
+ font_load(buf, FONT_MENU);
+ strcpy(buf_copy, buf);
+ set_file(buf_copy, (char *)global_settings.menufont, MAX_FILENAME);
+
+#ifdef CONFIG_TUNER
+ font_load(buf, FONT_TUNER);
+ strcpy(buf_copy, buf);
+ set_file(buf_copy, (char *)global_settings.tunerfont, MAX_FILENAME);
+#endif
+#ifdef HAVE_RECORDING
+ font_load(buf, FONT_RECORD);
+ strcpy(buf_copy, buf);
+ set_file(buf_copy, (char *)global_settings.recordfont, MAX_FILENAME);
+#endif
+ /* dont set userfonts because of the buffer problem */
break;
case FILE_ATTR_KBD:
diff -u -r rockbox_svn.orig/apps/gui/buttonbar.c rockbox_svn/apps/gui/buttonbar.c
--- rockbox_svn.orig/apps/gui/buttonbar.c 2007-07-19 18:38:25.906250000 -0500
+++ rockbox_svn/apps/gui/buttonbar.c 2007-09-30 07:08:04.093750000 -0500
@@ -116,7 +116,8 @@
gui_buttonbar_draw_button(buttonbar, i);
display->update_rect(0, display->height - BUTTONBAR_HEIGHT,
display->width, BUTTONBAR_HEIGHT);
- display->setfont(FONT_UI);
+ // MWE ?
+ display->setfont(FONT_BROWSER);
}
bool gui_buttonbar_isset(struct gui_buttonbar * buttonbar)
diff -u -r rockbox_svn.orig/apps/gui/color_picker.c rockbox_svn/apps/gui/color_picker.c
--- rockbox_svn.orig/apps/gui/color_picker.c 2007-09-28 22:36:14.875000000 -0500
+++ rockbox_svn/apps/gui/color_picker.c 2007-09-30 07:08:04.093750000 -0500
@@ -268,6 +268,7 @@
} /* end for */
/* Draw color value in system font */
+ int oldFont=display->getcurfont();
display->setfont(FONT_SYSFIXED);
/* Format RGB: #rrggbb */
@@ -320,7 +321,7 @@
}
}
- display->setfont(FONT_UI);
+ display->setfont(oldFont);
display->update();
/* Be sure screen mode is reset */
diff -u -r rockbox_svn.orig/apps/gui/gwps-common.c rockbox_svn/apps/gui/gwps-common.c
--- rockbox_svn.orig/apps/gui/gwps-common.c 2007-09-30 07:14:13.125000000 -0500
+++ rockbox_svn/apps/gui/gwps-common.c 2007-09-30 07:08:04.125000000 -0500
@@ -461,7 +461,7 @@
struct wps_data *data = gwps->data;
struct screen *display = gwps->display;
struct wps_state *state = gwps->state;
- int h = font_get(FONT_UI)->height;
+ int h = font_get(FONT_WPS)->height;
int sb_y;
if (data->progress_top < 0)
@@ -2018,7 +2018,7 @@
/* the peakmeter should be alone on its line */
update_line = false;
- int h = font_get(FONT_UI)->height;
+ int h = font_get(FONT_WPS)->height;
int peak_meter_y = display->getymargin() + line * h;
/* The user might decide to have the peak meter in the last
diff -u -r rockbox_svn.orig/apps/gui/gwps.c rockbox_svn/apps/gui/gwps.c
--- rockbox_svn.orig/apps/gui/gwps.c 2007-09-30 07:14:03.031250000 -0500
+++ rockbox_svn/apps/gui/gwps.c 2007-09-30 07:08:04.140625000 -0500
@@ -91,6 +91,11 @@
}
#endif
+static void gui_wps_set_font(struct gui_wps *gwps)
+{
+ gwps->display->setfont(FONT_WPS);
+}
+
long gui_wps_show(void)
{
long button = 0;
@@ -104,6 +109,12 @@
wps_state_init();
+ /* Set WPS display font */
+ FOR_NB_SCREENS(i)
+ {
+ gui_wps_set_font(&gui_wps[i]);
+ }
+
#ifdef HAVE_LCD_CHARCELLS
status_set_audio(true);
status_set_param(false);
diff -u -r rockbox_svn.orig/apps/gui/list.c rockbox_svn/apps/gui/list.c
--- rockbox_svn.orig/apps/gui/list.c 2007-09-30 07:13:54.453125000 -0500
+++ rockbox_svn/apps/gui/list.c 2007-09-30 07:12:36.046875000 -0500
@@ -37,6 +37,8 @@
#include "sound.h"
#include "misc.h"
+#include "debug.h"
+
#ifdef HAVE_LCD_CHARCELLS
#define SCROLL_LIMIT 1
#else
@@ -49,6 +51,10 @@
#define FRAMEDROP_TRIGGER 6
#ifdef HAVE_LCD_BITMAP
+/* gui_list can have two contexts, MENU and BROWSER. Contexts are used to determine display font. */
+short gui_list_context = -1;
+#define GUI_LIST_CONTEXT_MENU 0
+#define GUI_LIST_CONTEXT_BRWSR 1
static int offset_step = 16; /* pixels per screen scroll step */
/* should lines scroll out of the screen */
static bool offset_out_of_view = false;
@@ -221,9 +227,22 @@
bool partial_draw = false;
#ifdef HAVE_LCD_BITMAP
- display->setfont(FONT_UI);
- gui_textarea_update_nblines(display);
+ switch (gui_list_context) /* Set appropriate font */
+ {
+ case GUI_LIST_CONTEXT_MENU:
+ gui_list->display->setfont(FONT_MENU);
+ gui_list->display->set_foreground(global_settings.fg_color);
+ break;
+ case GUI_LIST_CONTEXT_BRWSR:
+ gui_list->display->setfont(FONT_BROWSER);
+ gui_list->display->set_foreground(global_settings.fg_color);
+ break;
+ default:
+ debugf("gui_list_put_selection_in_screen(): unknown font context: %i\n", gui_list_context);
+ }
#endif
+ gui_textarea_update_nblines(display);
+
/* Speed up UI by drawing the changed contents only. */
if (gui_list == last_list_displayed[gui_list->display->screen_type]
&& gui_list->last_displayed_start_item == gui_list->start_item
@@ -307,7 +326,6 @@
/* Adjust the position of icon, cursor, text for the list */
#ifdef HAVE_LCD_BITMAP
- gui_textarea_update_nblines(display);
bool draw_scrollbar;
draw_scrollbar = (global_settings.scrollbar &&
@@ -693,6 +711,21 @@
{
if(gui_list->nb_items > 0)
{
+#ifdef HAVE_LCD_BITMAP
+ switch (gui_list_context) /* Set appropriate font */
+ {
+ case GUI_LIST_CONTEXT_MENU:
+ gui_list->display->setfont(FONT_MENU);
+ gui_list->display->set_foreground(global_settings.fg_color);
+ break;
+ case GUI_LIST_CONTEXT_BRWSR:
+ gui_list->display->setfont(FONT_BROWSER);
+ gui_list->display->set_foreground(global_settings.fg_color);
+ break;
+ default:
+ debugf("gui_list_put_selection_in_screen(): unknown font context: %i\n", gui_list_context);
+ }
+#endif
gui_textarea_update_nblines(gui_list->display);
int nb_lines = gui_list->display->nb_lines;
Only in rockbox_svn/apps/gui: list.c.orig
diff -u -r rockbox_svn.orig/apps/gui/list.h rockbox_svn/apps/gui/list.h
--- rockbox_svn.orig/apps/gui/list.h 2007-09-17 11:39:47.296875000 -0500
+++ rockbox_svn/apps/gui/list.h 2007-09-30 07:08:04.171875000 -0500
@@ -126,6 +126,13 @@
#define gui_list_set_nb_items(gui_list, nb) \
(gui_list)->nb_items = nb
+/* gui_list can have two contexts, LIST_MENU and LIST_BROWSER. Contexts are used to determine display font. */
+#ifdef HAVE_LCD_BITMAP
+extern short gui_list_context;
+#define GUI_LIST_CONTEXT_MENU 0
+#define GUI_LIST_CONTEXT_BRWSR 1
+#endif
+
/*
* Returns the numbers of items currently in the list
* - gui_list : the list structure
diff -u -r rockbox_svn.orig/apps/gui/quickscreen.c rockbox_svn/apps/gui/quickscreen.c
--- rockbox_svn.orig/apps/gui/quickscreen.c 2007-09-23 11:14:01.125000000 -0500
+++ rockbox_svn/apps/gui/quickscreen.c 2007-09-30 07:08:04.187500000 -0500
@@ -119,7 +119,6 @@
putsxy_bottom-font_h, 7, 8);
gui_textarea_update(display);
- display->setfont(FONT_UI);
}
/*
diff -u -r rockbox_svn.orig/apps/gui/splash.c rockbox_svn/apps/gui/splash.c
--- rockbox_svn.orig/apps/gui/splash.c 2007-08-08 21:59:56.703125000 -0500
+++ rockbox_svn/apps/gui/splash.c 2007-09-30 07:08:04.203125000 -0500
@@ -25,6 +25,7 @@
#include "lang.h"
#include "settings.h"
#include "talk.h"
+#include "font.h"
#ifndef MAX
#define MAX(a, b) (((a)>(b))?(a):(b))
@@ -57,10 +58,12 @@
int space_w, w, h;
#ifdef HAVE_LCD_BITMAP
int maxw = 0;
+ int oldFont=screen->getcurfont();
#if LCD_DEPTH > 1
unsigned prevfg = 0;
#endif
+ screen->setfont(FONT_MENU);
screen->getstringsize(" ", &space_w, &h);
#else /* HAVE_LCD_CHARCELLS */
@@ -75,9 +78,13 @@
/* break splash string into display lines, doing proper word wrap */
next = strtok_r(splash_buf, " ", &store);
- if (!next)
+ if (!next){
+#ifdef HAVE_LCD_BITMAP
+ screen->setfont(oldFont);
+#endif
return; /* nothing to display */
-
+ }
+
lines[0] = next;
while (true)
{
@@ -127,6 +134,7 @@
screen->stop_scroll();
#ifdef HAVE_LCD_BITMAP
+
/* If we center the display, then just clear the box we need and put
a nice little frame and put the text in there! */
y = (screen->height - y) / 2; /* height => y start position */
@@ -180,6 +188,7 @@
screen->set_foreground(prevfg);
screen->set_drawmode(DRMODE_SOLID);
}
+ screen->setfont(oldFont);
#endif
screen->update();
}
diff -u -r rockbox_svn.orig/apps/gui/statusbar.c rockbox_svn/apps/gui/statusbar.c
--- rockbox_svn.orig/apps/gui/statusbar.c 2007-07-19 18:38:26.062500000 -0500
+++ rockbox_svn/apps/gui/statusbar.c 2007-09-30 07:08:04.218750000 -0500
@@ -380,6 +380,7 @@
#if LCD_DEPTH > 1
unsigned int prevfg = 0;
#endif
+ int oldfont;
#if CONFIG_CHARGING
if (batt_charge_step >= 0)
@@ -404,16 +405,20 @@
#else /* all others */
if (global_settings.battery_display && (percent > -1)) {
#endif
- /* Numeric display */
- display->setfont(FONT_SYSFIXED);
+ /* Numeric display */
snprintf(buffer, sizeof(buffer), "%3d", percent);
+
+ /* remember to set back if font changed */
+ oldfont=display->getcurfont();
+
+ display->setfont(FONT_SYSFIXED);
display->getstringsize(buffer, &width, &height);
if (height <= STATUSBAR_HEIGHT)
display->putsxy(STATUSBAR_BATTERY_X_POS
+ STATUSBAR_BATTERY_WIDTH / 2
- width/2, STATUSBAR_Y_POS, buffer);
- display->setfont(FONT_UI);
-
+ /* set back previous font */
+ display->setfont(oldfont);
}
else {
/* draw battery */
@@ -439,12 +444,16 @@
}
if (percent == -1) {
+ /* remember to set back if font changed */
+ oldfont=display->getcurfont();
+
display->setfont(FONT_SYSFIXED);
display->putsxy(STATUSBAR_BATTERY_X_POS + STATUSBAR_BATTERY_WIDTH / 2
- 4, STATUSBAR_Y_POS, "?");
- display->setfont(FONT_UI);
+ /* set back previous font */
+ display->setfont(oldfont);
}
-}
+ }
/*
* Print volume gauge to status bar
@@ -487,8 +496,11 @@
/* display volume level numerical? */
if (type)
{
+ snprintf(buffer, sizeof(buffer), "%2d", volume);
+ /* remember to set back if font changed */
+ int oldFont=display->getcurfont();
+
display->setfont(FONT_SYSFIXED);
- snprintf(buffer, sizeof(buffer), "%2d", volume);
display->getstringsize(buffer, &width, &height);
if (height <= STATUSBAR_HEIGHT)
{
@@ -496,7 +508,7 @@
+ STATUSBAR_VOLUME_WIDTH / 2
- width/2, STATUSBAR_Y_POS, buffer);
}
- display->setfont(FONT_UI);
+ display->setfont(oldFont);
} else {
/* display volume bar */
vol = (volume - minvol) * 14 / (maxvol - minvol);
@@ -600,13 +612,16 @@
else {
strncpy(buffer, "--:--", sizeof buffer);
}
+ /* remember to set back if font changed */
+ int oldfont=display->getcurfont();
+
display->setfont(FONT_SYSFIXED);
display->getstringsize(buffer, &width, &height);
if (height <= STATUSBAR_HEIGHT) {
display->putsxy(STATUSBAR_TIME_X_END(display->width) - width,
STATUSBAR_Y_POS, buffer);
}
- display->setfont(FONT_UI);
+ display->setfont(oldfont);
}
#endif
@@ -709,6 +724,9 @@
static void gui_statusbar_icon_recording_info(struct screen * display)
{
+ /* remember to set back if font changed */
+ int oldfont=display->getcurfont();
+
#if CONFIG_CODEC != SWCODEC
char buffer[3];
int width, height;
@@ -771,6 +789,7 @@
STATUSBAR_RECCHANNELS_X_POS, STATUSBAR_Y_POS,
STATUSBAR_RECCHANNELS_WIDTH, STATUSBAR_HEIGHT);
}
+ display->setfont(oldfont);
}
#endif /* HAVE_RECORDING */
diff -u -r rockbox_svn.orig/apps/gui/yesno.c rockbox_svn/apps/gui/yesno.c
--- rockbox_svn.orig/apps/gui/yesno.c 2007-08-18 00:36:35.093750000 -0500
+++ rockbox_svn/apps/gui/yesno.c 2007-09-30 07:08:04.234375000 -0500
@@ -24,6 +24,7 @@
#include "lang.h"
#include "action.h"
#include "talk.h"
+#include "font.h"
/*
* Initializes the yesno asker
@@ -136,8 +137,13 @@
can speak them, and unwrap the actual language strings. */
extract_talk_ids(main_message, voice_ids,
sizeof(voice_ids)/sizeof(voice_ids[0]));
+ int old_font[NB_SCREENS];
FOR_NB_SCREENS(i)
{
+#ifdef HAVE_LCD_BITMAP
+ old_font[i]=screens[i].getcurfont();
+ screens[i].setfont(FONT_MENU);
+#endif
gui_yesno_init(&(yn[i]), main_message, yes_message, no_message);
gui_yesno_set_display(&(yn[i]), &(screens[i]));
gui_yesno_draw(&(yn[i]));
@@ -162,8 +168,15 @@
/* ignore some SYS events that can happen */
continue;
default:
- if(default_event_handler(button) == SYS_USB_CONNECTED)
+ if(default_event_handler(button) == SYS_USB_CONNECTED){
+#ifdef HAVE_LCD_BITMAP
+ FOR_NB_SCREENS(i)
+ {
+ screens[i].setfont(old_font[i]);
+ }
+#endif
return(YESNO_USB);
+ }
result = YESNO_NO;
}
}
@@ -182,5 +195,13 @@
}
if(result_displayed)
sleep(HZ);
+
+#ifdef HAVE_LCD_BITMAP
+ FOR_NB_SCREENS(i)
+ {
+ screens[i].setfont(old_font[i]);
+ }
+#endif
+
return(result);
}
diff -u -r rockbox_svn.orig/apps/plugin.c rockbox_svn/apps/plugin.c
--- rockbox_svn.orig/apps/plugin.c 2007-09-30 07:13:54.546875000 -0500
+++ rockbox_svn/apps/plugin.c 2007-09-30 07:08:04.250000000 -0500
@@ -93,6 +93,7 @@
lcd_set_drawmode,
lcd_get_drawmode,
lcd_setfont,
+ lcd_getcurfont,
lcd_drawpixel,
lcd_drawline,
lcd_hline,
@@ -146,6 +147,7 @@
lcd_remote_set_drawmode,
lcd_remote_get_drawmode,
lcd_remote_setfont,
+ lcd_remote_getcurfont,
lcd_remote_getstringsize,
lcd_remote_drawpixel,
lcd_remote_drawline,
diff -u -r rockbox_svn.orig/apps/plugin.h rockbox_svn/apps/plugin.h
--- rockbox_svn.orig/apps/plugin.h 2007-09-30 07:14:13.171875000 -0500
+++ rockbox_svn/apps/plugin.h 2007-09-30 07:08:04.265625000 -0500
@@ -157,6 +157,7 @@
void (*lcd_set_drawmode)(int mode);
int (*lcd_get_drawmode)(void);
void (*lcd_setfont)(int font);
+ int (*lcd_getcurfont)(void);
void (*lcd_drawpixel)(int x, int y);
void (*lcd_drawline)(int x1, int y1, int x2, int y2);
void (*lcd_hline)(int x1, int x2, int y);
@@ -187,8 +188,8 @@
int width, int height);
#endif
unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
- const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
- struct font* (*font_load)(const char *path);
+ const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code, int font );
+ struct font* (*font_load)(const char *path, int font);
void (*lcd_puts_style)(int x, int y, const unsigned char *str, int style);
void (*lcd_puts_scroll_style)(int x, int y, const unsigned char* string,
int style);
@@ -203,7 +204,7 @@
struct font* (*font_get)(int font);
int (*font_getstringsize)(const unsigned char *str, int *w, int *h,
int fontnumber);
- int (*font_get_width)(struct font* pf, unsigned short char_code);
+ int (*font_get_width)(struct font* pf, unsigned short char_code, int font);
void (*screen_clear_area)(struct screen * display, int xstart, int ystart,
int width, int height);
#endif
@@ -225,6 +226,7 @@
void (*lcd_remote_set_drawmode)(int mode);
int (*lcd_remote_get_drawmode)(void);
void (*lcd_remote_setfont)(int font);
+ int (*lcd_remote_getcurfont)(void);
int (*lcd_remote_getstringsize)(const unsigned char *str, int *w, int *h);
void (*lcd_remote_drawpixel)(int x, int y);
void (*lcd_remote_drawline)(int x1, int y1, int x2, int y2);
diff -u -r rockbox_svn.orig/apps/plugins/bounce.c rockbox_svn/apps/plugins/bounce.c
--- rockbox_svn.orig/apps/plugins/bounce.c 2007-09-23 11:13:59.625000000 -0500
+++ rockbox_svn/apps/plugins/bounce.c 2007-09-30 07:08:04.281250000 -0500
@@ -538,7 +538,7 @@
} while(h > 0);
rb->lcd_set_drawmode(DRMODE_SOLID);
- rb->lcd_setfont(FONT_UI);
+ rb->lcd_setfont(FONT_PLUGIN);
return (h == 0) ? PLUGIN_OK : PLUGIN_USB_CONNECTED;
}
diff -u -r rockbox_svn.orig/apps/plugins/brickmania.c rockbox_svn/apps/plugins/brickmania.c
--- rockbox_svn.orig/apps/plugins/brickmania.c 2007-08-18 00:36:34.281250000 -0500
+++ rockbox_svn/apps/plugins/brickmania.c 2007-09-30 07:08:04.296875000 -0500
@@ -2039,7 +2039,7 @@
configfile_save(HIGH_SCORE,config,1,0);
/* Restore user's original backlight setting */
- rb->lcd_setfont(FONT_UI);
+ rb->lcd_setfont(FONT_PLUGIN);
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
diff -u -r rockbox_svn.orig/apps/plugins/bubbles.c rockbox_svn/apps/plugins/bubbles.c
--- rockbox_svn.orig/apps/plugins/bubbles.c 2007-09-28 22:36:14.578125000 -0500
+++ rockbox_svn/apps/plugins/bubbles.c 2007-09-30 07:08:04.328125000 -0500
@@ -2664,7 +2664,7 @@
break;
case BB_USB:
- rb->lcd_setfont(FONT_UI);
+ rb->lcd_setfont(FONT_PLUGIN);
return PLUGIN_USB_CONNECTED;
case BB_QUIT:
@@ -2680,7 +2680,7 @@
}
}
- rb->lcd_setfont(FONT_UI);
+ rb->lcd_setfont(FONT_PLUGIN);
return PLUGIN_OK;
}
Only in rockbox_svn/apps/plugins: bubbles.c.orig
diff -u -r rockbox_svn.orig/apps/plugins/credits.c rockbox_svn/apps/plugins/credits.c
--- rockbox_svn.orig/apps/plugins/credits.c 2007-09-07 21:26:20.734375000 -0500
+++ rockbox_svn/apps/plugins/credits.c 2007-09-30 07:08:04.343750000 -0500
@@ -148,7 +148,7 @@
/* control if scrolling is automatic (with animation) or manual */
bool manual_scroll = false;
- rb->lcd_setfont(FONT_UI);
+ rb->lcd_setfont(FONT_PLUGIN);
rb->lcd_clear_display();
rb->lcd_update();
diff -u -r rockbox_svn.orig/apps/plugins/jewels.c rockbox_svn/apps/plugins/jewels.c
--- rockbox_svn.orig/apps/plugins/jewels.c 2007-09-23 11:14:00.140625000 -0500
+++ rockbox_svn/apps/plugins/jewels.c 2007-09-30 07:08:04.359375000 -0500
@@ -1832,7 +1832,7 @@
break;
case BJ_USB:
- rb->lcd_setfont(FONT_UI);
+ rb->lcd_setfont(FONT_PLUGIN);
return PLUGIN_USB_CONNECTED;
case BJ_QUIT:
@@ -1862,7 +1862,7 @@
}
}
- rb->lcd_setfont(FONT_UI);
+ rb->lcd_setfont(FONT_PLUGIN);
return PLUGIN_OK;
}
diff -u -r rockbox_svn.orig/apps/plugins/jpeg.c rockbox_svn/apps/plugins/jpeg.c
--- rockbox_svn.orig/apps/plugins/jpeg.c 2007-09-23 11:13:59.703125000 -0500
+++ rockbox_svn/apps/plugins/jpeg.c 2007-09-30 07:08:04.375000000 -0500
@@ -3054,7 +3054,7 @@
rb->lcd_puts(0,3,"Left/Right: Skip File.");
rb->lcd_puts(0,4,"Off: Quit.");
rb->lcd_update();
- rb->lcd_setfont(FONT_UI);
+ rb->lcd_setfont(FONT_PLUGIN);
rb->button_clear_queue();
diff -u -r rockbox_svn.orig/apps/plugins/mp3_encoder.c rockbox_svn/apps/plugins/mp3_encoder.c
--- rockbox_svn.orig/apps/plugins/mp3_encoder.c 2007-09-23 11:13:58.921875000 -0500
+++ rockbox_svn/apps/plugins/mp3_encoder.c 2007-09-30 07:08:04.406250000 -0500
@@ -2478,7 +2478,7 @@
rb->sleep(5*HZ);
}
- rb->lcd_setfont(FONT_UI);
+ rb->lcd_setfont(FONT_PLUGIN);
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
rb->cpu_boost(false);
#endif
diff -u -r rockbox_svn.orig/apps/plugins/rockblox.c rockbox_svn/apps/plugins/rockblox.c
--- rockbox_svn.orig/apps/plugins/rockblox.c 2007-09-23 11:13:59.437500000 -0500
+++ rockbox_svn/apps/plugins/rockblox.c 2007-09-30 07:08:04.421875000 -0500
@@ -1061,7 +1061,7 @@
ret = rockblox_loop ();
#ifdef HAVE_LCD_BITMAP
- rb->lcd_setfont (FONT_UI);
+ rb->lcd_setfont (FONT_BROWSER);
#else
pgfx_release();
#endif
diff -u -r rockbox_svn.orig/apps/plugins/rockpaint.c rockbox_svn/apps/plugins/rockpaint.c
--- rockbox_svn.orig/apps/plugins/rockpaint.c 2007-09-30 07:14:13.218750000 -0500
+++ rockbox_svn/apps/plugins/rockpaint.c 2007-09-30 07:08:04.453125000 -0500
@@ -402,10 +402,13 @@
{
unsigned short ch;
unsigned short *ucs;
-
- struct font *pf = rb->font_get( FONT_UI );
- if( !pf ) pf = rb->font_get( FONT_SYSFIXED );
-
+ int curfont=FONT_PLUGIN;
+
+ struct font *pf = rb->font_get( FONT_PLUGIN );
+ if( !pf ) {
+ pf = rb->font_get( FONT_SYSFIXED );
+ curfont=FONT_SYSFIXED;
+ }
ucs = rb->bidi_l2v( str, 1 );
while( (ch = *ucs++) != 0 && x < buf_width )
@@ -414,7 +417,7 @@
const unsigned char *bits;
/* get proportional width and glyph bits */
- width = rb->font_get_width( pf, ch );
+ width = rb->font_get_width( pf, ch, curfont );
if( ofs > width )
{
@@ -422,7 +425,7 @@
continue;
}
- bits = rb->font_get_bits( pf, ch );
+ bits = rb->font_get_bits( pf, ch, curfont );
buffer_mono_bitmap_part( buf, buf_width, buf_height, bits, ofs, 0, width, x, y, width - ofs, pf->height);
@@ -843,7 +846,7 @@
rb->snprintf( old_font, MAX_PATH,
FONT_DIR "/%s.fnt",
- rb->global_settings->font_file );
+ rb->global_settings->browserfont );
while( 1 )
{
@@ -897,8 +900,8 @@
continue;
rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s",
de->d_name );
- rb->font_load( bbuf );
- rb->font_getstringsize( de->d_name, &fw, &fh, FONT_UI );
+ rb->font_load( bbuf, FONT_PLUGIN );
+ rb->font_getstringsize( de->d_name, &fw, &fh, FONT_PLUGIN );
if( nvih > 0 )
{
nvih -= fh;
@@ -932,12 +935,12 @@
{
rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s",
de->d_name );
- rb->font_load( bbuf );
- rb->font_getstringsize( de->d_name, NULL, &fh, FONT_UI );
+ rb->font_load( bbuf, FONT_PLUGIN );
+ rb->font_getstringsize( de->d_name, NULL, &fh, FONT_PLUGIN );
nvih = fh;
}
}
- rb->font_load( old_font );
+ rb->font_load( old_font, FONT_PLUGIN );
rb->closedir( d );
}
@@ -1083,7 +1086,7 @@
rb->lcd_putsxy( left + 117, top + 60, str );
rb->snprintf( str, 6, "%d", blue );
rb->lcd_putsxy( left + 117, top + 70, str );
- rb->lcd_setfont( FONT_UI );
+ rb->lcd_setfont( FONT_PLUGIN );
#define CURSOR( l ) \
rb->lcd_bitmap_transparent_part( rockpaint_hsvrgb, 1, 1, 16, left+l+1, top+20, 6, 58 ); \
@@ -1479,7 +1482,7 @@
buffer.text.text[0] = '\0';
rb->snprintf( buffer.text.old_font, MAX_PATH,
FONT_DIR "/%s.fnt",
- rb->global_settings->font_file );
+ rb->global_settings->browserfont );
while( 1 )
{
int m = TEXT_MENU_TEXT;
@@ -1493,7 +1496,7 @@
case TEXT_MENU_FONT:
if( browse_fonts( buffer.text.font, MAX_PATH ) )
{
- rb->font_load( buffer.text.font );
+ rb->font_load( buffer.text.font, FONT_PLUGIN );
}
break;
@@ -1545,7 +1548,7 @@
buffer.text.text );
case TEXT_MENU_CANCEL:
restore_screen();
- rb->font_load( buffer.text.old_font );
+ rb->font_load( buffer.text.old_font, FONT_PLUGIN );
return;
}
}
@@ -2305,7 +2308,7 @@
rb->lcd_setfont( FONT_SYSFIXED );
rb->lcd_putsxy( TB_MENU_LEFT, TOP+TB_MENU_TOP, "Menu" );
- rb->lcd_setfont( FONT_UI );
+ rb->lcd_setfont( FONT_PLUGIN );
#undef TOP
if( update ) rb->lcd_update();
diff -u -r rockbox_svn.orig/apps/plugins/spacerocks.c rockbox_svn/apps/plugins/spacerocks.c
--- rockbox_svn.orig/apps/plugins/spacerocks.c 2007-09-23 11:13:59.781250000 -0500
+++ rockbox_svn/apps/plugins/spacerocks.c 2007-09-30 07:08:04.468750000 -0500
@@ -1960,7 +1960,7 @@
iohiscore();
retval = start_game();
iohiscore();
- rb->lcd_setfont(FONT_UI);
+ rb->lcd_setfont(FONT_PLUGIN);
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
return retval;
diff -u -r rockbox_svn.orig/apps/plugins/stopwatch.c rockbox_svn/apps/plugins/stopwatch.c
--- rockbox_svn.orig/apps/plugins/stopwatch.c 2007-09-23 11:14:00.046875000 -0500
+++ rockbox_svn/apps/plugins/stopwatch.c 2007-09-30 07:08:04.484375000 -0500
@@ -188,7 +188,7 @@
#ifdef HAVE_LCD_BITMAP
int h;
- rb->lcd_setfont(FONT_UI);
+ rb->lcd_setfont(FONT_PLUGIN);
rb->lcd_getstringsize("M", NULL, &h);
lines = (LCD_HEIGHT / h) - (LAP_Y);
#else
diff -u -r rockbox_svn.orig/apps/plugins/viewer.c rockbox_svn/apps/plugins/viewer.c
--- rockbox_svn.orig/apps/plugins/viewer.c 2007-09-30 07:13:54.609375000 -0500
+++ rockbox_svn/apps/plugins/viewer.c 2007-09-30 07:08:04.500000000 -0500
@@ -306,7 +306,7 @@
ch = ' ';
#ifdef HAVE_LCD_BITMAP
- return rb->font_get_width(pf, ch);
+ return rb->font_get_width(pf, ch, FONT_BROWSER);
#else
return 1;
#endif
@@ -1006,8 +1006,9 @@
static bool viewer_init(void)
{
#ifdef HAVE_LCD_BITMAP
-
- pf = rb->font_get(FONT_UI);
+ // MWE
+ rb->lcd_setfont(FONT_BROWSER);
+ pf = rb->font_get(FONT_BROWSER);
display_lines = LCD_HEIGHT / pf->height;
draw_columns = display_columns = LCD_WIDTH;
diff -u -r rockbox_svn.orig/apps/plugins/xobox.c rockbox_svn/apps/plugins/xobox.c
--- rockbox_svn.orig/apps/plugins/xobox.c 2007-09-23 11:13:59.000000000 -0500
+++ rockbox_svn/apps/plugins/xobox.c 2007-09-30 07:08:04.531250000 -0500
@@ -947,7 +947,7 @@
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
- rb->lcd_setfont (FONT_UI);
+ rb->lcd_setfont (FONT_PLUGIN);
return ret;
}
diff -u -r rockbox_svn.orig/apps/plugins/zxbox/zxbox_keyb.c rockbox_svn/apps/plugins/zxbox/zxbox_keyb.c
--- rockbox_svn.orig/apps/plugins/zxbox/zxbox_keyb.c 2007-09-23 11:13:44.640625000 -0500
+++ rockbox_svn/apps/plugins/zxbox/zxbox_keyb.c 2007-09-30 07:08:04.546875000 -0500
@@ -198,13 +198,13 @@
rb->screens[l]->setfont(param[l].curfont);
/* find max width of keyboard glyphs */
for (i=0; ifont_get_width(param[l].font, param[l].kbd_buf[i]);
+ w = rb->font_get_width(param[l].font, param[l].kbd_buf[i], FONT_PLUGIN);
if (w > param[l].font_w)
param[l].font_w = w;
}
/* Since we're going to be adding spaces, make sure that we check
* their width too */
- w = rb->font_get_width( param[l].font, ' ' );
+ w = rb->font_get_width( param[l].font, ' ', FONT_PLUGIN );
if( w > param[l].font_w )
param[l].font_w = w;
}
@@ -256,7 +256,7 @@
text_w = param[l].font_w;
while (*utf8) {
utf8 = (unsigned char*)rb->utf8decode(utf8, &ch);
- w = rb->font_get_width(param[l].font, ch);
+ w = rb->font_get_width(param[l].font, ch, FONT_SYSFIXED);
if (w > text_w)
text_w = w;
}
@@ -387,7 +387,7 @@
case KBD_ABORT:
FOR_NB_SCREENS(l)
- rb->screens[l]->setfont(FONT_UI);
+ rb->screens[l]->setfont(FONT_SYSFIXED);
return -1;
break;
@@ -506,6 +506,6 @@
}
}
FOR_NB_SCREENS(l)
- rb->screens[l]->setfont(FONT_UI);
+ rb->screens[l]->setfont(FONT_SYSFIXED);
return 0;
}
diff -u -r rockbox_svn.orig/apps/recorder/keyboard.c rockbox_svn/apps/recorder/keyboard.c
--- rockbox_svn.orig/apps/recorder/keyboard.c 2007-08-26 17:53:52.953125000 -0500
+++ rockbox_svn/apps/recorder/keyboard.c 2007-09-30 07:08:04.562500000 -0500
@@ -356,7 +356,7 @@
}
else
{
- pm->curfont = FONT_UI;
+ pm->curfont = FONT_MENU;
}
}
@@ -382,14 +382,14 @@
/* find max width of keyboard glyphs */
for (i = 0; i < pm->nchars; i++)
{
- w = font_get_width(pm->font, pm->kbd_buf[i]);
+ w = font_get_width(pm->font, pm->kbd_buf[i], param[l].curfont);
if ( w > pm->font_w )
pm->font_w = w;
}
/* Since we're going to be adding spaces, make sure that we check
* their width too */
- w = font_get_width( pm->font, ' ' );
+ w = font_get_width( pm->font, ' ', param[l].curfont );
if ( w > pm->font_w )
pm->font_w = w;
}
@@ -457,7 +457,7 @@
while (*utf8)
{
- int w = font_get_width(pm->font, ch);
+ int w = font_get_width(pm->font, ch, param[l].curfont);
utf8 = (unsigned char*)utf8decode(utf8, &ch);
if (w > text_w)
@@ -749,8 +749,6 @@
switch ( button )
{
case ACTION_KBD_ABORT:
- FOR_NB_SCREENS(l)
- screens[l].setfont(FONT_UI);
#ifdef HAS_BUTTONBAR
global_settings.buttonbar=buttonbar_config;
diff -u -r rockbox_svn.orig/apps/recorder/radio.c rockbox_svn/apps/recorder/radio.c
--- rockbox_svn.orig/apps/recorder/radio.c 2007-09-17 11:39:42.546875000 -0500
+++ rockbox_svn/apps/recorder/radio.c 2007-09-30 07:08:04.578125000 -0500
@@ -433,13 +433,14 @@
global_settings.statusbar = true;
FOR_NB_SCREENS(i)
{
+ screens[i].setfont(FONT_TUNER);
gui_textarea_clear(&screens[i]);
screen_set_xmargin(&screens[i],0);
}
gui_syncstatusbar_draw(&statusbars,true);
- fh = font_get(FONT_UI)->height;
+ fh = font_get(FONT_TUNER)->height;
/* Adjust for font size, trying to center the information vertically */
if(fh < 10)
@@ -840,7 +841,7 @@
int freq;
FOR_NB_SCREENS(i)
- screens[i].setfont(FONT_UI);
+ screens[i].setfont(FONT_TUNER);
snprintf(buf, 128, curr_preset >= 0 ? "%d. %s" : " ",
curr_preset + 1, presets[curr_preset].name);
diff -u -r rockbox_svn.orig/apps/recorder/recording.c rockbox_svn/apps/recorder/recording.c
--- rockbox_svn.orig/apps/recorder/recording.c 2007-09-30 07:13:54.625000000 -0500
+++ rockbox_svn/apps/recorder/recording.c 2007-09-30 07:08:04.609375000 -0500
@@ -938,7 +938,7 @@
FOR_NB_SCREENS(i)
{
- screens[i].setfont(FONT_SYSFIXED);
+ screens[i].setfont(FONT_RECORD);
screens[i].getstringsize("M", &w, &h);
screens[i].setmargins(global_settings.cursor_style ? 0 : w, screens[i].width, 8);
filename_offset[i] = ((screens[i].height >= 80) ? 1 : 0);
@@ -1339,7 +1339,7 @@
FOR_NB_SCREENS(i)
{
- screens[i].setfont(FONT_SYSFIXED);
+ screens[i].setfont(FONT_RECORD);
screens[i].setmargins(
global_settings.cursor_style ? 0 : w, screens[i].width, 8);
}
@@ -1419,7 +1419,7 @@
#endif
FOR_NB_SCREENS(i)
- screens[i].setfont(FONT_SYSFIXED);
+ screens[i].setfont(FONT_RECORD);
seconds = audio_recorded_time() / HZ;
@@ -1883,9 +1883,6 @@
rec_status &= ~RCSTAT_IN_RECSCREEN;
sound_settings_apply();
- FOR_NB_SCREENS(i)
- screens[i].setfont(FONT_UI);
-
/* if the directory was created or recording happened, make sure the
browser is updated */
if (rec_status & (RCSTAT_CREATED_DIRECTORY | RCSTAT_HAVE_RECORDED))
@@ -1922,7 +1919,7 @@
FOR_NB_SCREENS(i)
{
- screens[i].setfont(FONT_SYSFIXED);
+ screens[i].setfont(FONT_RECORD);
screens[i].getstringsize("A",&w,&h);
}
@@ -2035,8 +2032,6 @@
set_gain();
settings_save();
- FOR_NB_SCREENS(i)
- screens[i].setfont(FONT_UI);
return false;
}
@@ -2057,7 +2052,7 @@
FOR_NB_SCREENS(i)
{
- screens[i].setfont(FONT_SYSFIXED);
+ screens[i].setfont(FONT_RECORD);
screens[i].getstringsize("A",&w,&h);
}
@@ -2132,8 +2127,6 @@
set_gain();
settings_save();
- FOR_NB_SCREENS(i)
- screens[i].setfont(FONT_UI);
return false;
}
Only in rockbox_svn/apps/recorder: recording.c.orig
diff -u -r rockbox_svn.orig/apps/root_menu.c rockbox_svn/apps/root_menu.c
--- rockbox_svn.orig/apps/root_menu.c 2007-08-08 22:00:00.484375000 -0500
+++ rockbox_svn/apps/root_menu.c 2007-09-30 07:08:04.625000000 -0500
@@ -486,7 +486,11 @@
return GO_TO_PREVIOUS;
}
void root_menu(void)
-{
+{
+#ifdef HAVE_LCD_BITMAP
+ gui_list_context = GUI_LIST_CONTEXT_MENU; /* Set menu font */
+#endif
+
int previous_browser = GO_TO_FILEBROWSER;
int previous_music = GO_TO_WPS;
int next_screen = GO_TO_ROOT;
@@ -529,7 +533,10 @@
case MENU_SELECTED_EXIT:
/* fall through */
case GO_TO_ROOT:
- if (last_screen != GO_TO_ROOT)
+#ifdef HAVE_LCD_BITMAP
+ gui_list_context = GUI_LIST_CONTEXT_MENU; /* Set menu font */
+#endif
+ if (last_screen != GO_TO_ROOT)
selected = get_selection(last_screen);
next_screen = do_menu(&root_menu_, &selected);
if (next_screen != GO_TO_PREVIOUS)
diff -u -r rockbox_svn.orig/apps/screen_access.c rockbox_svn/apps/screen_access.c
--- rockbox_svn.orig/apps/screen_access.c 2007-09-30 07:13:54.656250000 -0500
+++ rockbox_svn/apps/screen_access.c 2007-09-30 07:08:04.640625000 -0500
@@ -57,6 +57,7 @@
.getstringsize=&lcd_getstringsize,
#ifdef HAVE_LCD_BITMAP
.setfont=&lcd_setfont,
+ .getcurfont=&lcd_getcurfont,
.mono_bitmap=&lcd_mono_bitmap,
.mono_bitmap_part=&lcd_mono_bitmap_part,
.set_drawmode=&lcd_set_drawmode,
@@ -141,6 +142,7 @@
.getstringsize=&lcd_remote_getstringsize,
#if 1 /* all remote LCDs are bitmapped so far */
.setfont=&lcd_remote_setfont,
+ .getcurfont=&lcd_remote_getcurfont,
.mono_bitmap=&lcd_remote_mono_bitmap,
.mono_bitmap_part=&lcd_remote_mono_bitmap_part,
.bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
@@ -215,9 +217,6 @@
int i;
FOR_NB_SCREENS(i)
{
-#ifdef HAVE_LCD_BITMAP
- ((struct screen*)&screens[i])->setfont(FONT_UI);
-#endif
gui_textarea_update_nblines(&screens[i]);
}
}
Only in rockbox_svn/apps: screen_access.c.orig
diff -u -r rockbox_svn.orig/apps/screen_access.h rockbox_svn/apps/screen_access.h
--- rockbox_svn.orig/apps/screen_access.h 2007-09-30 07:13:54.671875000 -0500
+++ rockbox_svn/apps/screen_access.h 2007-09-30 07:08:04.656250000 -0500
@@ -78,6 +78,7 @@
int (*getstringsize)(const unsigned char *str, int *w, int *h);
#if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD) /* always bitmap */
void (*setfont)(int newfont);
+ int (*getcurfont)(void);
void (*scroll_step)(int pixels);
void (*puts_style_offset)(int x, int y, const unsigned char *str,
diff -u -r rockbox_svn.orig/apps/screens.c rockbox_svn/apps/screens.c
--- rockbox_svn.orig/apps/screens.c 2007-09-30 07:13:54.687500000 -0500
+++ rockbox_svn/apps/screens.c 2007-09-30 07:08:04.671875000 -0500
@@ -623,7 +623,6 @@
#if CONFIG_CODEC == SWCODEC
pcmbuf_set_low_latency(false);
#endif
- lcd_setfont(FONT_UI);
return 0;
}
#endif /* HAVE_PITCHSCREEN */
diff -u -r rockbox_svn.orig/apps/settings.c rockbox_svn/apps/settings.c
--- rockbox_svn.orig/apps/settings.c 2007-09-28 22:36:16.671875000 -0500
+++ rockbox_svn/apps/settings.c 2007-09-30 07:08:04.703125000 -0500
@@ -268,6 +268,32 @@
return false;
}
+/** reset some settings when loading a wps file
+ * to keep backward compatibility **/
+void theme_settings_reset(void)
+{
+ /* multifont settings */
+ global_settings.font_file[0] = '\0';
+ global_settings.browserfont[0] = '\0';
+ global_settings.wpsfont[0] = '\0';
+ global_settings.menufont[0] = '\0';
+#ifdef CONFIG_TUNER
+ global_settings.tunerfont[0] = '\0';
+#endif
+#ifdef HAVE_RECORDING
+ global_settings.recordfont[0] = '\0';
+#endif
+ /* reset rpws setting */
+#ifdef HAVE_REMOTE_LCD
+ global_settings.rwps_file[0]='\0';
+#endif
+ /* reset color settings */
+#ifdef HAVE_LCD_COLOR
+ global_settings.fg_color=LCD_DEFAULT_FG;
+ global_settings.bg_color=LCD_DEFAULT_BG;
+#endif
+}
+
bool settings_load_config(const char* file, bool apply)
{
int fd;
@@ -278,6 +304,11 @@
fd = open(file, O_RDONLY);
if (fd < 0)
return false;
+
+ /* if loading a theme reset some settings for backward compatibility */
+ if(strncmp(file, THEME_DIR, strlen(THEME_DIR))==0){
+ theme_settings_reset();
+ }
while (read_line(fd, line, sizeof line) > 0)
{
@@ -666,7 +697,9 @@
#if CONFIG_CODEC == SWCODEC
int i;
#endif
-
+ /** backward comp **/
+ bool useMultifont=false;
+
DEBUGF( "settings_apply()\n" );
sound_settings_apply();
@@ -797,14 +830,154 @@
#endif
#ifdef HAVE_LCD_BITMAP
- if ( global_settings.font_file[0]) {
+ /* Load all the fonts */
+ if ( global_settings.browserfont[0] &&
+ global_settings.browserfont[0] != 0xff ) {
+ useMultifont=true;
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.browserfont);
+ font_load(buf, FONT_BROWSER);
+ }
+ else
+ font_reset(FONT_BROWSER);
+
+ if ( global_settings.wpsfont[0] &&
+ global_settings.wpsfont[0] != 0xff ) {
+ useMultifont=true;
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.wpsfont);
+ font_load(buf, FONT_WPS);
+ }
+ else
+ font_reset(FONT_WPS);
+
+ if ( global_settings.menufont[0] &&
+ global_settings.menufont[0] != 0xff ) {
+ useMultifont=true;
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.menufont);
+ font_load(buf, FONT_MENU);
+ }
+ else
+ font_reset(FONT_MENU);
+
+#ifdef CONFIG_TUNER
+ if ( global_settings.tunerfont[0] &&
+ global_settings.tunerfont[0] != 0xff ) {
+ useMultifont=true;
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.tunerfont);
+ font_load(buf, FONT_TUNER);
+ }
+ else
+ font_reset(FONT_TUNER);
+#endif /* CONFIG_TUNER */
+
+#ifdef HAVE_RECORDING
+ if ( global_settings.recordfont[0] &&
+ global_settings.recordfont[0] != 0xff ) {
+ useMultifont=true;
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.recordfont);
+ font_load(buf, FONT_RECORD);
+ }
+ else
+ font_reset(FONT_RECORD);
+#endif /* HAVE_RECORDING */
+
+ /** backward comp **/
+ if(!useMultifont){
+ if ( global_settings.font_file[0] &&
+ global_settings.font_file[0] != 0xff ) {
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.font_file);
+ font_load(buf, FONT_BROWSER);
+ font_load(buf, FONT_WPS);
+ font_load(buf, FONT_MENU);
+#ifdef CONFIG_TUNER
+ font_load(buf, FONT_TUNER);
+#endif
+#ifdef HAVE_RECORDING
+ font_load(buf, FONT_RECORD);
+#endif
+ }
+ else {
+ font_reset(FONT_BROWSER);
+ font_reset(FONT_WPS);
+ font_reset(FONT_MENU);
+#ifdef CONFIG_TUNER
+ font_reset(FONT_TUNER);
+#endif
+#ifdef HAVE_RECORDING
+ font_reset(FONT_RECORD);
+#endif
+ }
+ }
+
+ /* Load all user fonts */
+ if ( global_settings.userfont1[0] &&
+ global_settings.userfont1[0] != 0xff ) {
snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
- global_settings.font_file);
- font_load(buf);
+ global_settings.userfont1);
+ font_load(buf, FONT_USER1);
}
else
- font_reset();
-
+ font_reset(FONT_USER1);
+
+ if ( global_settings.userfont2[0] &&
+ global_settings.userfont2[0] != 0xff ) {
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.userfont2);
+ font_load(buf, FONT_USER2);
+ }
+ else
+ font_reset(FONT_USER2);
+
+ if ( global_settings.userfont3[0] &&
+ global_settings.userfont3[0] != 0xff ) {
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.userfont3);
+ font_load(buf, FONT_USER3);
+ }
+ else
+ font_reset(FONT_USER3);
+
+ if ( global_settings.userfont4[0] &&
+ global_settings.userfont4[0] != 0xff ) {
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.userfont4);
+ font_load(buf, FONT_USER4);
+ }
+ else
+ font_reset(FONT_USER4);
+
+ if ( global_settings.userfont5[0] &&
+ global_settings.userfont5[0] != 0xff ) {
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.userfont5);
+ font_load(buf, FONT_USER5);
+ }
+ else
+ font_reset(FONT_USER5);
+
+ if ( global_settings.userfont6[0] &&
+ global_settings.userfont6[0] != 0xff ) {
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.userfont6);
+ font_load(buf, FONT_USER6);
+ }
+ else
+ font_reset(FONT_USER6);
+
+ if ( global_settings.userfont7[0] &&
+ global_settings.userfont7[0] != 0xff ) {
+ snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
+ global_settings.userfont7);
+ font_load(buf, FONT_USER7);
+ }
+ else
+ font_reset(FONT_USER7);
+
if ( global_settings.kbd_file[0]) {
snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd",
global_settings.kbd_file);
@@ -921,6 +1094,13 @@
#if defined (HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
enc_global_settings_reset();
#endif
+ global_settings.userfont1[0] = '\0';
+ global_settings.userfont2[0] = '\0';
+ global_settings.userfont3[0] = '\0';
+ global_settings.userfont4[0] = '\0';
+ global_settings.userfont5[0] = '\0';
+ global_settings.userfont6[0] = '\0';
+ global_settings.userfont7[0] = '\0';
}
/** Changing setting values **/
@@ -995,14 +1175,15 @@
void set_file(char* filename, char* setting, int maxlen)
{
- char* fptr = strrchr(filename,'/');
+ char *fptr = strrchr(filename,'/');
int len;
int extlen = 0;
- char* ptr;
+ char *ptr, *oldptr;
if (!fptr)
return;
+ oldptr = fptr;
*fptr = 0;
fptr++;
Only in rockbox_svn/apps: settings.c.orig
diff -u -r rockbox_svn.orig/apps/settings.h rockbox_svn/apps/settings.h
--- rockbox_svn.orig/apps/settings.h 2007-09-30 07:13:36.515625000 -0500
+++ rockbox_svn/apps/settings.h 2007-09-30 07:08:04.718750000 -0500
@@ -433,7 +433,26 @@
#if CONFIG_TUNER
unsigned char fmr_file[MAX_FILENAME+1]; /* last fmr preset */
#endif
- unsigned char font_file[MAX_FILENAME+1]; /* last font */
+ unsigned char font_file[MAX_FILENAME+1]; /* backward comp */
+
+ unsigned char browserfont[MAX_FILENAME+1]; /* UI fonts */
+ unsigned char wpsfont[MAX_FILENAME+1];
+ unsigned char menufont[MAX_FILENAME+1];
+#ifdef CONFIG_TUNER
+ unsigned char tunerfont[MAX_FILENAME+1];
+#endif
+#ifdef HAVE_RECORDING
+ unsigned char recordfont[MAX_FILENAME+1];
+#endif
+
+ unsigned char userfont1[MAX_FILENAME+1];
+ unsigned char userfont2[MAX_FILENAME+1];
+ unsigned char userfont3[MAX_FILENAME+1];
+ unsigned char userfont4[MAX_FILENAME+1];
+ unsigned char userfont5[MAX_FILENAME+1];
+ unsigned char userfont6[MAX_FILENAME+1];
+ unsigned char userfont7[MAX_FILENAME+1];
+
unsigned char wps_file[MAX_FILENAME+1]; /* last wps */
unsigned char lang_file[MAX_FILENAME+1]; /* last language */
Only in rockbox_svn/apps: settings.h.orig
diff -u -r rockbox_svn.orig/apps/settings_list.c rockbox_svn/apps/settings_list.c
--- rockbox_svn.orig/apps/settings_list.c 2007-09-30 07:13:36.546875000 -0500
+++ rockbox_svn/apps/settings_list.c 2007-09-30 07:08:04.734375000 -0500
@@ -558,6 +558,13 @@
false, "force fm mono", toggle_mono_mode),
SYSTEM_SETTING(NVRAM(4),last_frequency,0),
#endif
+ FILENAME_SETTING(F_THEMESETTING,userfont1,"userfont1","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+ FILENAME_SETTING(F_THEMESETTING,userfont2,"userfont2","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+ FILENAME_SETTING(F_THEMESETTING,userfont3,"userfont3","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+ FILENAME_SETTING(F_THEMESETTING,userfont4,"userfont4","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+ FILENAME_SETTING(F_THEMESETTING,userfont5,"userfont5","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+ FILENAME_SETTING(F_THEMESETTING,userfont6,"userfont6","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+ FILENAME_SETTING(F_THEMESETTING,userfont7,"userfont7","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
#if BATTERY_TYPES_COUNT > 1
CHOICE_SETTING(0, battery_type, LANG_BATTERY_TYPE, 0,
@@ -1214,8 +1221,20 @@
FILENAME_SETTING(0, fmr_file, "fmr",
"", FMPRESET_PATH "/", ".fmr", MAX_FILENAME+1),
#endif
- FILENAME_SETTING(F_THEMESETTING, font_file, "font",
- "", FONT_DIR "/", ".fnt", MAX_FILENAME+1),
+
+ /** backward comp **/
+ FILENAME_SETTING(F_THEMESETTING,font_file,"font","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+
+ FILENAME_SETTING(F_THEMESETTING,browserfont,"browserfont","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+ FILENAME_SETTING(F_THEMESETTING,wpsfont,"wpsfont","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+ FILENAME_SETTING(F_THEMESETTING,menufont,"menufont","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+#ifdef HAVE_RECORDING
+ FILENAME_SETTING(F_THEMESETTING,recordfont,"recordfont","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+#endif
+#ifdef CONFIG_TUNER
+ FILENAME_SETTING(F_THEMESETTING,tunerfont,"tunerfont","",FONT_DIR "/",".fnt",MAX_FILENAME+1),
+#endif
+
FILENAME_SETTING(F_THEMESETTING,wps_file, "wps",
"", WPS_DIR "/", ".wps", MAX_FILENAME+1),
FILENAME_SETTING(0,lang_file,"lang","",LANG_DIR "/",".lng",MAX_FILENAME+1),
Only in rockbox_svn/apps: settings_list.c.orig
diff -u -r rockbox_svn.orig/apps/tree.c rockbox_svn/apps/tree.c
--- rockbox_svn.orig/apps/tree.c 2007-09-17 11:39:48.093750000 -0500
+++ rockbox_svn/apps/tree.c 2007-09-30 07:08:04.765625000 -0500
@@ -241,7 +241,11 @@
gui_sync_wps_screen_init();
check_rockboxdir();
-
+
+#ifdef HAVE_LCD_BITMAP
+ gui_list_context = GUI_LIST_CONTEXT_BRWSR; /* Set browser font */
+#endif
+
strcpy(tc.currdir, "/");
#ifdef HAVE_LCD_CHARCELLS
@@ -1100,6 +1104,10 @@
int *last_filter = tc.dirfilter;
tc.dirfilter = &dirfilter;
+#ifdef HAVE_LCD_BITMAP
+ gui_list_context = GUI_LIST_CONTEXT_BRWSR; /* Set browser font */
+#endif
+
reload_dir = true;
if (dirfilter >= NUM_FILTER_MODES)
{
@@ -1127,6 +1135,11 @@
ret_val = dirbrowse();
}
tc.dirfilter = last_filter;
+
+#ifdef HAVE_LCD_BITMAP
+ gui_list_context = GUI_LIST_CONTEXT_MENU; /* Set menu font */
+#endif
+
return ret_val;
}
diff -u -r rockbox_svn.orig/firmware/drivers/lcd-16bit.c rockbox_svn/firmware/drivers/lcd-16bit.c
--- rockbox_svn.orig/firmware/drivers/lcd-16bit.c 2007-09-30 07:13:54.718750000 -0500
+++ rockbox_svn/firmware/drivers/lcd-16bit.c 2007-09-30 07:08:04.781250000 -0500
@@ -159,6 +159,11 @@
curfont = newfont;
}
+int lcd_getcurfont()
+{
+ return curfont;
+}
+
int lcd_getstringsize(const unsigned char *str, int *w, int *h)
{
return font_getstringsize(str, w, h, curfont);
@@ -797,7 +802,7 @@
const unsigned char *bits;
/* get proportional width and glyph bits */
- width = font_get_width(pf,ch);
+ width = font_get_width(pf,ch,curfont);
if (ofs > width)
{
@@ -805,7 +810,7 @@
continue;
}
- bits = font_get_bits(pf, ch);
+ bits = font_get_bits(pf, ch, curfont);
lcd_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, pf->height);
diff -u -r rockbox_svn.orig/firmware/drivers/lcd-2bit-horz.c rockbox_svn/firmware/drivers/lcd-2bit-horz.c
--- rockbox_svn.orig/firmware/drivers/lcd-2bit-horz.c 2007-09-30 07:13:54.750000000 -0500
+++ rockbox_svn/firmware/drivers/lcd-2bit-horz.c 2007-09-30 07:08:04.796875000 -0500
@@ -129,6 +129,11 @@
curfont = newfont;
}
+int lcd_getcurfont()
+{
+ return curfont;
+}
+
int lcd_getstringsize(const unsigned char *str, int *w, int *h)
{
return font_getstringsize(str, w, h, curfont);
@@ -798,7 +803,7 @@
const unsigned char *bits;
/* get proportional width and glyph bits */
- width = font_get_width(pf,ch);
+ width = font_get_width(pf,ch,curfont);
if (ofs > width)
{
@@ -806,7 +811,7 @@
continue;
}
- bits = font_get_bits(pf, ch);
+ bits = font_get_bits(pf, ch, curfont);
lcd_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs,
pf->height);
diff -u -r rockbox_svn.orig/firmware/drivers/lcd-2bit-vert.c rockbox_svn/firmware/drivers/lcd-2bit-vert.c
--- rockbox_svn.orig/firmware/drivers/lcd-2bit-vert.c 2007-09-30 07:13:54.765625000 -0500
+++ rockbox_svn/firmware/drivers/lcd-2bit-vert.c 2007-09-30 07:08:04.812500000 -0500
@@ -133,6 +133,11 @@
curfont = newfont;
}
+int lcd_getcurfont()
+{
+ return curfont;
+}
+
int lcd_getstringsize(const unsigned char *str, int *w, int *h)
{
return font_getstringsize(str, w, h, curfont);
@@ -935,7 +940,7 @@
const unsigned char *bits;
/* get proportional width and glyph bits */
- width = font_get_width(pf,ch);
+ width = font_get_width(pf,ch, curfont);
if (ofs > width)
{
@@ -943,7 +948,7 @@
continue;
}
- bits = font_get_bits(pf, ch);
+ bits = font_get_bits(pf, ch, curfont);
lcd_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs,
pf->height);
diff -u -r rockbox_svn.orig/firmware/drivers/lcd-remote-1bit-v.c rockbox_svn/firmware/drivers/lcd-remote-1bit-v.c
--- rockbox_svn.orig/firmware/drivers/lcd-remote-1bit-v.c 2007-09-30 07:13:54.781250000 -0500
+++ rockbox_svn/firmware/drivers/lcd-remote-1bit-v.c 2007-09-30 07:08:04.828125000 -0500
@@ -83,6 +83,11 @@
curfont = newfont;
}
+int lcd_remote_getcurfont(void)
+{
+ return curfont;
+}
+
int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h)
{
return font_getstringsize(str, w, h, curfont);
@@ -596,7 +601,7 @@
const unsigned char *bits;
/* get proportional width and glyph bits */
- width = font_get_width(pf, ch);
+ width = font_get_width(pf, ch, curfont);
if (ofs > width)
{
@@ -604,7 +609,7 @@
continue;
}
- bits = font_get_bits(pf, ch);
+ bits = font_get_bits(pf, ch, curfont);
lcd_remote_bitmap_part(bits, ofs, 0, width, x, y, width - ofs,
pf->height);
diff -u -r rockbox_svn.orig/firmware/drivers/lcd-remote-2bit-vi.c rockbox_svn/firmware/drivers/lcd-remote-2bit-vi.c
--- rockbox_svn.orig/firmware/drivers/lcd-remote-2bit-vi.c 2007-09-30 07:13:54.796875000 -0500
+++ rockbox_svn/firmware/drivers/lcd-remote-2bit-vi.c 2007-09-30 07:08:04.843750000 -0500
@@ -122,7 +122,7 @@
{
return rightmargin;
}
-
+
int lcd_remote_getymargin(void)
{
return ymargin;
@@ -133,6 +133,11 @@
curfont = newfont;
}
+int lcd_remote_getcurfont(void)
+{
+ return curfont;
+}
+
int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h)
{
return font_getstringsize(str, w, h, curfont);
@@ -934,7 +939,7 @@
const unsigned char *bits;
/* get proportional width and glyph bits */
- width = font_get_width(pf, ch);
+ width = font_get_width(pf, ch, curfont);
if (ofs > width)
{
@@ -942,7 +947,7 @@
continue;
}
- bits = font_get_bits(pf, ch);
+ bits = font_get_bits(pf, ch, curfont);
lcd_remote_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs,
pf->height);
diff -u -r rockbox_svn.orig/firmware/export/font.h rockbox_svn/firmware/export/font.h
--- rockbox_svn.orig/firmware/export/font.h 2007-09-15 00:52:12.359375000 -0500
+++ rockbox_svn/firmware/export/font.h 2007-09-30 07:08:04.859375000 -0500
@@ -46,7 +46,23 @@
#define FONT_HEADER_SIZE 36
#endif
-#define GLYPH_CACHE_FILE "/.rockbox/.glyphcache"
+
+#define GLYPH_CACHE_FILE_BRWSR "/.rockbox/.glyphcache-brwsr"
+#define GLYPH_CACHE_FILE_WPS "/.rockbox/.glyphcache-wps"
+#define GLYPH_CACHE_FILE_MENU "/.rockbox/.glyphcache-menu"
+#ifdef CONFIG_TUNER
+#define GLYPH_CACHE_FILE_TUNER "/.rockbox/.glyphcache-tuner"
+#endif
+#ifdef HAVE_RECORDING
+#define GLYPH_CACHE_FILE_RECORD "/.rockbox/.glyphcache-record"
+#endif
+#define GLYPH_CACHE_FILE_USER1 "/.rockbox/.glyphcache-user1"
+#define GLYPH_CACHE_FILE_USER2 "/.rockbox/.glyphcache-user2"
+#define GLYPH_CACHE_FILE_USER3 "/.rockbox/.glyphcache-user3"
+#define GLYPH_CACHE_FILE_USER4 "/.rockbox/.glyphcache-user4"
+#define GLYPH_CACHE_FILE_USER5 "/.rockbox/.glyphcache-user5"
+#define GLYPH_CACHE_FILE_USER6 "/.rockbox/.glyphcache-user6"
+#define GLYPH_CACHE_FILE_USER7 "/.rockbox/.glyphcache-user7"
/*
* Fonts are specified by number, and used for display
@@ -60,10 +76,29 @@
*/
enum {
FONT_SYSFIXED, /* system fixed pitch font*/
- FONT_UI, /* system porportional font*/
+ FONT_BROWSER, /* Browser font */
+ FONT_WPS, /* WPS font */
+ FONT_MENU, /* Settings/menu font */
+#ifdef CONFIG_TUNER
+ FONT_TUNER, /* FM/radio font */
+#endif
+#ifdef HAVE_RECORDING
+ FONT_RECORD, /* Recording font */
+#endif
+ FONT_USER1, /* User custom fonts for use in wps */
+ FONT_USER2, /* User custom fonts for use in wps */
+ FONT_USER3, /* User custom fonts for use in wps */
+ FONT_USER4, /* User custom fonts for use in wps */
+ FONT_USER5, /* User custom fonts for use in wps */
+ FONT_USER6, /* User custom fonts for use in wps */
+ FONT_USER7, /* User custom fonts for use in wps */
MAXFONTS
};
+/* FIXME: Hack to keep things compiling for now */
+#define FONT_PLUGIN FONT_SYSFIXED
+#define FONT_UI FONT_SYSFIXED
+
/*
* .fnt loadable font file format definition
*
@@ -106,13 +141,13 @@
/* font routines*/
void font_init(void);
-struct font* font_load(const char *path);
+struct font* font_load(const char *path, int font);
struct font* font_get(int font);
-void font_reset(void);
-int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber);
-int font_get_width(struct font* ft, unsigned short ch);
-const unsigned char * font_get_bits(struct font* ft, unsigned short ch);
-void glyph_cache_save(void);
+void font_reset(int font);
+int font_getstringsize(const unsigned char *str, int *w, int *h, int font);
+int font_get_width(struct font* ft, unsigned short ch, int font);
+const unsigned char * font_get_bits(struct font* ft, unsigned short ch, int font);
+void glyph_cache_save(int font);
#else /* HAVE_LCD_BITMAP */
diff -u -r rockbox_svn.orig/firmware/export/lcd-remote.h rockbox_svn/firmware/export/lcd-remote.h
--- rockbox_svn.orig/firmware/export/lcd-remote.h 2007-09-30 07:13:54.812500000 -0500
+++ rockbox_svn/firmware/export/lcd-remote.h 2007-09-30 07:08:04.875000000 -0500
@@ -143,6 +143,8 @@
extern int lcd_remote_getrightmargin(void);
extern int lcd_remote_getymargin(void);
extern void lcd_remote_setfont(int font);
+extern int lcd_remote_getcurfont(void);
+extern void lcd_remote_setfont(int font);
extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h);
/* low level drawing function pointer arrays */
diff -u -r rockbox_svn.orig/firmware/export/lcd.h rockbox_svn/firmware/export/lcd.h
--- rockbox_svn.orig/firmware/export/lcd.h 2007-09-30 07:13:54.843750000 -0500
+++ rockbox_svn/firmware/export/lcd.h 2007-09-30 07:08:04.890625000 -0500
@@ -327,6 +327,7 @@
extern void lcd_set_drawmode(int mode);
extern int lcd_get_drawmode(void);
extern void lcd_setfont(int font);
+extern int lcd_getcurfont(void);
extern void lcd_puts_style_offset(int x, int y, const unsigned char *str,
int style, int offset);
Only in rockbox_svn/firmware/export: lcd.h.orig
diff -u -r rockbox_svn.orig/firmware/font.c rockbox_svn/firmware/font.c
--- rockbox_svn.orig/firmware/font.c 2007-07-19 18:44:30.281250000 -0500
+++ rockbox_svn/firmware/font.c 2007-09-30 07:08:04.921875000 -0500
@@ -46,33 +46,81 @@
/* compiled-in font */
extern struct font sysfont;
-/* structure filled in by font_load */
-static struct font font_ui;
+/* font structures filled in by font_load */
+static struct font browserfont;
+static struct font wpsfont;
+static struct font menufont;
+#ifdef CONFIG_TUNER
+static struct font tunerfont;
+#endif
+#ifdef HAVE_RECORDING
+static struct font recordfont;
+#endif
+static struct font userfont1;
+static struct font userfont2;
+static struct font userfont3;
+static struct font userfont4;
+static struct font userfont5;
+static struct font userfont6;
+static struct font userfont7;
/* system font table, in order of FONT_xxx definition */
-static struct font* const sysfonts[MAXFONTS] = { &sysfont, &font_ui };
+static struct font* sysfonts[MAXFONTS] = {
+ &sysfont,
+ &browserfont,
+ &wpsfont,
+ &menufont,
+#ifdef CONFIG_TUNER
+ &tunerfont,
+#endif
+#ifdef HAVE_RECORDING
+ &recordfont,
+#endif
+ &userfont1,
+ &userfont2,
+ &userfont3,
+ &userfont4,
+ &userfont5,
+ &userfont6,
+ &userfont7
+ };
/* static buffer allocation structures */
-static unsigned char mbuf[MAX_FONT_SIZE];
-static unsigned char *freeptr = mbuf;
-static unsigned char *fileptr;
-static unsigned char *eofptr;
+static unsigned char font_membuf[MAXCACHEFONTS][MAX_FONT_SIZE]; /* Sysfont is compiled-in, no need for buffer */
/* Font cache structures */
-static struct font_cache font_cache_ui;
-static int fnt_file = -1; /* >=0 if font is cached */
-uint32_t file_width_offset; /* offset to file width data */
-uint32_t file_offset_offset; /* offset to file offset data */
-static void cache_create(int maxwidth, int height);
-static int long_offset = 0;
-static int glyph_file;
+static struct font_cache sys_font_cache[MAXCACHEFONTS];
+static struct font_file_info fntfile[MAXCACHEFONTS];
+static void cache_create(int maxwidth, int height, int font);
+static void font_cache_init(void);
/* End Font cache structures */
-static void glyph_cache_load(void);
+static void glyph_cache_load(int font);
+/* Zero out all font structures */
void font_init(void)
{
- memset(&font_ui, 0, sizeof(struct font));
+ int i = FONT_BROWSER; /* Skip sysfont */
+
+ while (i < MAXFONTS)
+ {
+ memset(sysfonts[i], 0, sizeof(struct font));
+ i++;
+ }
+
+ font_cache_init();
+}
+
+void font_cache_init(void)
+{
+ int i = 0;
+
+ while (i < MAXCACHEFONTS)
+ {
+ fntfile[i].font_fd = -1;
+ i++;
+ }
+ return;
}
/* Check if we have x bytes left in the file buffer */
@@ -82,126 +130,147 @@
the file buffer. Bounds-checking must be done in the calling
function.
*/
-
-static short readshort(void)
+
+static short readshort(unsigned short *sp, int font)
{
unsigned short s;
- s = *fileptr++ & 0xff;
- s |= (*fileptr++ << 8);
- return s;
+ s = *fntfile[font].fileptr++ & 0xff;
+ *sp = (*fntfile[font].fileptr++ << 8) | s;
+ return (fntfile[font].fileptr <= fntfile[font].eofptr);
}
-static int32_t readlong(void)
+static int32_t readlong(uint32_t *lp, int font)
{
uint32_t l;
- l = *fileptr++ & 0xff;
- l |= *fileptr++ << 8;
- l |= ((uint32_t)(*fileptr++)) << 16;
- l |= ((uint32_t)(*fileptr++)) << 24;
- return l;
+ l = *fntfile[font].fileptr++ & 0xff;
+ l |= *fntfile[font].fileptr++ << 8;
+ l |= ((uint32_t)(*fntfile[font].fileptr++)) << 16;
+ l |= ((uint32_t)(*fntfile[font].fileptr++)) << 24;
+ *lp = l;
+ return (fntfile[font].fileptr <= fntfile[font].eofptr);
}
/* read count bytes*/
-static void readstr(char *buf, int count)
+static int readstr(char *buf, int count, int font)
{
- while (count--)
- *buf++ = *fileptr++;
+ int n = count;
+
+ while (--n >= 0)
+ *buf++ = *fntfile[font].fileptr++;
+
+ return (fntfile[font].fileptr <= fntfile[font].eofptr)? count: 0;
}
-void font_reset(void)
+void font_reset(int font)
{
- memset(&font_ui, 0, sizeof(struct font));
+ memset(sysfonts[font], 0, sizeof(struct font));
}
-static struct font* font_load_header(struct font *pf)
+static struct font* font_load_header(struct font *pf, int font)
{
char version[4+1];
-
- /* Check we have enough data */
- if (!HAVEBYTES(28))
- return NULL;
+ unsigned short maxwidth, height, ascent, pad;
+ uint32_t firstchar, defaultchar, size;
+ uint32_t nbits;
/* read magic and version #*/
memset(version, 0, sizeof(version));
- readstr(version, 4);
+ if (readstr(version, 4, font) != 4)
+ return NULL;
if (strcmp(version, VERSION) != 0)
return NULL;
/* font info*/
- pf->maxwidth = readshort();
- pf->height = readshort();
- pf->ascent = readshort();
- fileptr += 2; /* Skip padding */
- pf->firstchar = readlong();
- pf->defaultchar = readlong();
- pf->size = readlong();
+ if (!readshort(&maxwidth, font))
+ return NULL;
+ pf->maxwidth = maxwidth;
+
+ if (!readshort(&height, font))
+ return NULL;
+ pf->height = height;
+
+ if (!readshort(&ascent, font))
+ return NULL;
+ pf->ascent = ascent;
+
+ if (!readshort(&pad, font))
+ return NULL;
+
+ if (!readlong(&firstchar, font))
+ return NULL;
+ pf->firstchar = firstchar;
+
+ if (!readlong(&defaultchar, font))
+ return NULL;
+ pf->defaultchar = defaultchar;
+
+ if (!readlong(&size, font))
+ return NULL;
+ pf->size = size;
/* get variable font data sizes*/
/* # words of bitmap_t*/
- pf->bits_size = readlong();
+ if (!readlong(&nbits, font))
+ return NULL;
+ pf->bits_size = nbits;
return pf;
}
/* Load memory font */
-static struct font* font_load_in_memory(struct font* pf)
+static struct font* font_load_in_memory(struct font* pf, int font)
{
int32_t i, noffset, nwidth;
- if (!HAVEBYTES(4))
- return NULL;
-
/* # longs of offset*/
- noffset = readlong();
+ if (!readlong(&noffset, font))
+ return NULL;
/* # bytes of width*/
- nwidth = readlong();
+ if (!readlong(&nwidth, font))
+ return NULL;
/* variable font data*/
- pf->bits = (unsigned char *)fileptr;
- fileptr += pf->bits_size*sizeof(unsigned char);
+ pf->bits = (unsigned char *)fntfile[font].fileptr;
+ fntfile[font].fileptr += pf->bits_size*sizeof(unsigned char);
if ( pf->bits_size < 0xFFDB )
{
/* pad to 16-bit boundary */
- fileptr = (unsigned char *)(((intptr_t)fileptr + 1) & ~1);
+ fntfile[font].fileptr = (unsigned char *)(((intptr_t)fntfile[font].fileptr + 1) & ~1);
}
else
{
/* pad to 32-bit boundary*/
- fileptr = (unsigned char *)(((intptr_t)fileptr + 3) & ~3);
+ fntfile[font].fileptr = (unsigned char *)(((intptr_t)fntfile[font].fileptr + 3) & ~3);
}
if (noffset)
{
if ( pf->bits_size < 0xFFDB )
{
- long_offset = 0;
- pf->offset = (unsigned short *)fileptr;
-
- /* Check we have sufficient buffer */
- if (!HAVEBYTES(noffset * sizeof(short)))
- return NULL;
-
+ fntfile[font].long_offset = 0;
+ pf->offset = (unsigned short *)fntfile[font].fileptr;
for (i=0; ioffset))[i] = (unsigned short)readshort();
+ unsigned short offset;
+ if (!readshort(&offset, font))
+ return NULL;
+ ((unsigned short*)(pf->offset))[i] = (unsigned short)offset;
}
}
else
{
- long_offset = 1;
- pf->offset = (unsigned short *)fileptr;
-
- /* Check we have sufficient buffer */
- if (!HAVEBYTES(noffset * sizeof(int32_t)))
- return NULL;
-
+ fntfile[font].long_offset = 1;
+ pf->offset = (unsigned short *)fntfile[font].fileptr;
for (i=0; ioffset))[i] = (uint32_t)readlong();
+ uint32_t offset;
+ if (!readlong(&offset, font))
+ return NULL;
+ ((uint32_t*)(pf->offset))[i] = (uint32_t)offset;
}
}
}
@@ -209,140 +278,140 @@
pf->offset = NULL;
if (nwidth) {
- pf->width = (unsigned char *)fileptr;
- fileptr += nwidth*sizeof(unsigned char);
+ pf->width = (unsigned char *)fntfile[font].fileptr;
+ fntfile[font].fileptr += nwidth*sizeof(unsigned char);
}
else
pf->width = NULL;
- if (fileptr > eofptr)
+ if (fntfile[font].fileptr > fntfile[font].eofptr)
return NULL;
return pf; /* success!*/
}
/* Load cached font */
-static struct font* font_load_cached(struct font* pf)
+static struct font* font_load_cached(struct font* pf, int font)
{
uint32_t noffset, nwidth;
- unsigned char* oldfileptr = fileptr;
-
- if (!HAVEBYTES(2 * sizeof(int32_t)))
- return NULL;
+ unsigned char* oldfileptr = fntfile[font].fileptr;
/* # longs of offset*/
- noffset = readlong();
+ if (!readlong(&noffset, font))
+ return NULL;
/* # bytes of width*/
- nwidth = readlong();
+ if (!readlong(&nwidth, font))
+ return NULL;
/* We are now at the bitmap data, this is fixed at 36.. */
pf->bits = NULL;
/* Calculate offset to offset data */
- fileptr += pf->bits_size * sizeof(unsigned char);
+ fntfile[font].fileptr += pf->bits_size * sizeof(unsigned char);
if ( pf->bits_size < 0xFFDB )
{
- long_offset = 0;
+ fntfile[font].long_offset = 0;
/* pad to 16-bit boundary */
- fileptr = (unsigned char *)(((intptr_t)fileptr + 1) & ~1);
+ fntfile[font].fileptr = (unsigned char *)(((intptr_t)fntfile[font].fileptr + 1) & ~1);
}
else
{
- long_offset = 1;
+ fntfile[font].long_offset = 1;
/* pad to 32-bit boundary*/
- fileptr = (unsigned char *)(((intptr_t)fileptr + 3) & ~3);
+ fntfile[font].fileptr = (unsigned char *)(((intptr_t)fntfile[font].fileptr + 3) & ~3);
}
if (noffset)
- file_offset_offset = (uint32_t)(fileptr - freeptr);
+ fntfile[font].file_offset_offset = (uint32_t)(fntfile[font].fileptr - fntfile[font].freeptr);
else
- file_offset_offset = 0;
+ fntfile[font].file_offset_offset = 0;
/* Calculate offset to widths data */
if ( pf->bits_size < 0xFFDB )
- fileptr += noffset * sizeof(unsigned short);
+ fntfile[font].fileptr += noffset * sizeof(unsigned short);
else
- fileptr += noffset * sizeof(uint32_t);
+ fntfile[font].fileptr += noffset * sizeof(uint32_t);
if (nwidth)
- file_width_offset = (uint32_t)(fileptr - freeptr);
+ fntfile[font].file_width_offset = (uint32_t)(fntfile[font].fileptr - fntfile[font].freeptr);
else
- file_width_offset = 0;
+ fntfile[font].file_width_offset = 0;
- fileptr = oldfileptr;
+ fntfile[font].fileptr = oldfileptr;
/* Create the cache */
- cache_create(pf->maxwidth, pf->height);
+ cache_create(pf->maxwidth, pf->height, font);
return pf;
}
/* read and load font into incore font structure*/
-struct font* font_load(const char *path)
+struct font* font_load(const char *path, int _font)
{
int size;
- struct font* pf = &font_ui;
+ int font = _font - 1; /* cache index vs global font index */
+ struct font* pf = sysfonts[_font];
/* save loaded glyphs */
- glyph_cache_save();
+ glyph_cache_save(font);
/* Close font file handle */
- if (fnt_file >= 0)
- close(fnt_file);
+ if (fntfile[font].font_fd >= 0)
+ close(fntfile[font].font_fd);
/* open and read entire font file*/
- fnt_file = open(path, O_RDONLY|O_BINARY);
+ fntfile[font].font_fd = open(path, O_RDONLY|O_BINARY);
- if (fnt_file < 0) {
+ if (fntfile[font].font_fd < 0) {
DEBUGF("Can't open font: %s\n", path);
return NULL;
}
/* Check file size */
- size = filesize(fnt_file);
+ size = filesize(fntfile[font].font_fd);
- font_reset();
+ font_reset(_font);
/* currently, font loading replaces earlier font allocation*/
- freeptr = (unsigned char *)(((int)mbuf + 3) & ~3);
- fileptr = freeptr;
+ fntfile[font].freeptr = (unsigned char *)(((int)font_membuf[font] + 3) & ~3);
+ fntfile[font].fileptr = fntfile[font].freeptr;
if (size > MAX_FONT_SIZE)
{
- read(fnt_file, fileptr, FONT_HEADER_SIZE);
- eofptr = fileptr + FONT_HEADER_SIZE;
+ read(fntfile[font].font_fd, fntfile[font].fileptr, FONT_HEADER_SIZE);
+ fntfile[font].eofptr = fntfile[font].fileptr + FONT_HEADER_SIZE;
- if (!font_load_header(pf))
+ if (!font_load_header(pf, font))
{
DEBUGF("Failed font header load");
return NULL;
}
- if (!font_load_cached(pf))
+ if (!font_load_cached(pf, font))
{
DEBUGF("Failed font cache load");
return NULL;
}
- glyph_cache_load();
+ glyph_cache_load(font);
}
else
{
- read(fnt_file, fileptr, MAX_FONT_SIZE);
- eofptr = fileptr + size;
- close(fnt_file);
- fnt_file = -1;
+ read(fntfile[font].font_fd, fntfile[font].fileptr, MAX_FONT_SIZE);
+ fntfile[font].eofptr = fntfile[font].fileptr + size;
+ close(fntfile[font].font_fd);
+ fntfile[font].font_fd = -1;
- if (!font_load_header(pf))
+ if (!font_load_header(pf, font))
{
DEBUGF("Failed font header load");
return NULL;
}
- if (!font_load_in_memory(pf))
+ if (!font_load_in_memory(pf, font))
{
DEBUGF("Failed mem load");
return NULL;
@@ -359,13 +428,25 @@
/*
* Return a pointer to an incore font structure.
* If the requested font isn't loaded/compiled-in,
- * decrement the font number and try again.
+ * (decrement the font number and try again)
+ * MWE return sysfont instead
+ *
*/
-struct font* font_get(int font)
+struct font *font_get(int font)
{
- struct font* pf;
+ struct font *pf;
+
+ if (font >= MAXFONTS){
+ return &sysfont;
+ }
+
+ pf = sysfonts[font];
+ if (pf && pf->height)
+ return pf;
+
+ return &sysfont;
- if (font >= MAXFONTS)
+/* if (font >= MAXFONTS)
font = 0;
while (1) {
@@ -374,14 +455,14 @@
return pf;
if (--font < 0)
panicf("No font!");
- }
+ }*/
}
/*
* Returns the stringsize of a given string.
*/
-int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber)
+int font_getstringsize(const unsigned char *str, int *w, int *h, int font)
{
- struct font* pf = font_get(fontnumber);
+ struct font* pf = font_get(font);
unsigned short ch;
int width = 0;
@@ -389,7 +470,7 @@
{
/* get proportional width and glyph bits*/
- width += font_get_width(pf,ch);
+ width += font_get_width(pf, ch, font);
}
if ( w )
*w = width;
@@ -402,17 +483,17 @@
* Reads an entry into cache entry
*/
static void
-load_cache_entry(struct font_cache_entry* p, void* callback_data)
+load_cache_entry(struct font_cache_entry* p, void* callback_data, int font)
{
struct font* pf = callback_data;
unsigned short char_code = p->_char_code;
unsigned char tmp[2];
- if (file_width_offset)
+ if (fntfile[font].file_width_offset)
{
- int width_offset = file_width_offset + char_code;
- lseek(fnt_file, width_offset, SEEK_SET);
- read(fnt_file, &(p->width), 1);
+ int width_offset = fntfile[font].file_width_offset + char_code;
+ lseek(fntfile[font].font_fd, width_offset, SEEK_SET);
+ read(fntfile[font].font_fd, &(p->width), 1);
}
else
{
@@ -421,14 +502,14 @@
int32_t bitmap_offset = 0;
- if (file_offset_offset)
+ if (fntfile[font].file_offset_offset)
{
- int32_t offset = file_offset_offset + char_code * (long_offset ? sizeof(int32_t) : sizeof(short));
- lseek(fnt_file, offset, SEEK_SET);
- read (fnt_file, tmp, 2);
+ int32_t offset = fntfile[font].file_offset_offset + char_code * (fntfile[font].long_offset ? sizeof(int32_t) : sizeof(short));
+ lseek(fntfile[font].font_fd, offset, SEEK_SET);
+ read (fntfile[font].font_fd, tmp, 2);
bitmap_offset = tmp[0] | (tmp[1] << 8);
- if (long_offset) {
- read (fnt_file, tmp, 2);
+ if (fntfile[font].long_offset) {
+ read (fntfile[font].font_fd, tmp, 2);
bitmap_offset |= (tmp[0] << 16) | (tmp[1] << 24);
}
}
@@ -438,125 +519,213 @@
}
int32_t file_offset = FONT_HEADER_SIZE + bitmap_offset;
- lseek(fnt_file, file_offset, SEEK_SET);
+ lseek(fntfile[font].font_fd, file_offset, SEEK_SET);
int src_bytes = p->width * ((pf->height + 7) / 8);
- read(fnt_file, p->bitmap, src_bytes);
+ read(fntfile[font].font_fd, p->bitmap, src_bytes);
}
/*
* Converts cbuf into a font cache
*/
-static void cache_create(int maxwidth, int height)
+static void cache_create(int maxwidth, int height, int font)
{
/* maximum size of rotated bitmap */
int bitmap_size = maxwidth * ((height + 7) / 8);
/* Initialise cache */
- font_cache_create(&font_cache_ui, mbuf, MAX_FONT_SIZE, bitmap_size);
+ font_cache_create(&sys_font_cache[font], &font_membuf[font], MAX_FONT_SIZE, bitmap_size);
}
/*
* Returns width of character
*/
-int font_get_width(struct font* pf, unsigned short char_code)
+int font_get_width(struct font* pf, unsigned short char_code, int font)
{
/* check input range*/
if (char_code < pf->firstchar || char_code >= pf->firstchar+pf->size)
char_code = pf->defaultchar;
char_code -= pf->firstchar;
-
- return (fnt_file >= 0 && pf != &sysfont)?
- font_cache_get(&font_cache_ui,char_code,load_cache_entry,pf)->width:
- pf->width? pf->width[char_code]: pf->maxwidth;
+
+ if (pf == &sysfont || fntfile[font-1].font_fd < 0) /* sysfont or loaded into mem */
+ {
+ if (pf->width)
+ return pf->width[char_code];
+ else
+ return pf->maxwidth;
+ }
+ else /* cached */
+ return font_cache_get(&sys_font_cache[font-1], char_code, load_cache_entry, pf, font-1)->width;
}
-const unsigned char* font_get_bits(struct font* pf, unsigned short char_code)
+const unsigned char* font_get_bits(struct font* pf, unsigned short char_code, int font)
{
const unsigned char* bits;
/* check input range*/
if (char_code < pf->firstchar || char_code >= pf->firstchar+pf->size)
char_code = pf->defaultchar;
- char_code -= pf->firstchar;
-
- if (fnt_file >= 0 && pf != &sysfont)
- {
- bits =
- (unsigned char*)font_cache_get(&font_cache_ui,char_code,load_cache_entry,pf)->bitmap;
+ char_code -= pf->firstchar;
+
+ if (font <= 0 || fntfile[font-1].font_fd < 0) /* sysfont */
+ bits = pf->bits + (pf->offset?pf->offset[char_code]:(((pf->height + 7) / 8) * pf->maxwidth * char_code));
+ else
+ bits = (unsigned char*)font_cache_get(&sys_font_cache[font-1], char_code, load_cache_entry, pf, font-1)->bitmap;
+
+ return bits;
}
- else
+
+static void glyph_file_write(void* data, int font)
{
- bits = pf->bits + (pf->offset?
- pf->offset[char_code]:
- (((pf->height + 7) / 8) * pf->maxwidth * char_code));
- }
-
- return bits;
-}
-
-static void glyph_file_write(void* data)
-{
- struct font_cache_entry* p = data;
- struct font* pf = &font_ui;
- unsigned short ch;
- unsigned char tmp[2];
-
- ch = p->_char_code + pf->firstchar;
-
- if (ch != 0xffff && glyph_file >= 0) {
- tmp[0] = ch >> 8;
- tmp[1] = ch & 0xff;
- if (write(glyph_file, tmp, 2) != 2) {
- close(glyph_file);
- glyph_file = -1;
+ struct font_cache_entry* p = data;
+ struct font* pf = sysfonts[font];
+ unsigned short ch;
+ unsigned char tmp[2];
+
+ ch = p->_char_code + pf->firstchar;
+
+ if (p->_char_code != 0xffff && fntfile[font].glyph_fd >= 0) {
+ tmp[0] = p->_char_code >> 8;
+ tmp[1] = p->_char_code & 0xff;
+
+ if (write(fntfile[font].glyph_fd, tmp, 2) != 2) {
+ close(fntfile[font].glyph_fd);
+ fntfile[font].glyph_fd = -1;
+ }
}
+ return;
}
- return;
-}
-
-/* save the char codes of the loaded glyphs to a file */
-void glyph_cache_save(void)
-{
-
- if (fnt_file >= 0) {
-
- glyph_file = creat(GLYPH_CACHE_FILE);
-
- if (glyph_file < 0) return;
-
- lru_traverse(&font_cache_ui._lru, glyph_file_write);
-
- if (glyph_file >= 0)
- close(glyph_file);
+
+ /* save the char codes of the loaded glyphs to a file */
+void glyph_cache_save(int font)
+ {
+
+ if (fntfile[font].font_fd >= 0) {
+
+ switch (font)
+ {
+ case 0:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_BRWSR);
+ break;
+ case 1:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_WPS);
+ break;
+ case 2:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_MENU);
+ break;
+#ifdef CONFIG_TUNER
+ case 3:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_TUNER);
+ break;
+#endif
+#ifdef HAVE_RECORDING
+ case 4:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_RECORD);
+ break;
+#endif
+ case 5:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_USER1);
+ break;
+ case 6:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_USER2);
+ break;
+ case 7:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_USER3);
+ break;
+ case 8:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_USER4);
+ break;
+ case 9:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_USER5);
+ break;
+ case 10:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_USER6);
+ break;
+ case 11:
+ fntfile[font].glyph_fd = creat(GLYPH_CACHE_FILE_USER7);
+ break;
+ default:
+ return;
+ }
+
+ if (fntfile[font].glyph_fd < 0) return;
+
+ lru_traverse(&sys_font_cache[font]._lru, glyph_file_write, font);
+
+ if (fntfile[font].glyph_fd >= 0)
+ close(fntfile[font].glyph_fd);
+ }
+ return;
}
- return;
-}
-
-static void glyph_cache_load(void)
-{
- if (fnt_file >= 0) {
-
+
+static void glyph_cache_load(int font)
+ {
+ if (fntfile[font].font_fd >= 0) {
+
int fd;
unsigned char tmp[2];
unsigned short ch;
- struct font* pf = &font_ui;
-
- fd = open(GLYPH_CACHE_FILE, O_RDONLY|O_BINARY);
-
+ struct font* pf = sysfonts[font];
+
+ switch (font)
+ {
+ case 0:
+ fd = open(GLYPH_CACHE_FILE_BRWSR, O_RDONLY|O_BINARY);
+ break;
+ case 1:
+ fd = open(GLYPH_CACHE_FILE_WPS, O_RDONLY|O_BINARY);
+ break;
+ case 2:
+ fd = open(GLYPH_CACHE_FILE_MENU, O_RDONLY|O_BINARY);
+ break;
+#ifdef CONFIG_TUNER
+ case 3:
+ fd = open(GLYPH_CACHE_FILE_TUNER, O_RDONLY|O_BINARY);
+ break;
+#endif
+#ifdef HAVE_RECORDING
+ case 4:
+ fd = open(GLYPH_CACHE_FILE_RECORD, O_RDONLY|O_BINARY);
+ break;
+#endif
+ case 5:
+ fd = open(GLYPH_CACHE_FILE_USER1, O_RDONLY|O_BINARY);
+ break;
+ case 6:
+ fd = open(GLYPH_CACHE_FILE_USER2, O_RDONLY|O_BINARY);
+ break;
+ case 7:
+ fd = open(GLYPH_CACHE_FILE_USER3, O_RDONLY|O_BINARY);
+ break;
+ case 8:
+ fd = open(GLYPH_CACHE_FILE_USER4, O_RDONLY|O_BINARY);
+ break;
+ case 9:
+ fd = open(GLYPH_CACHE_FILE_USER5, O_RDONLY|O_BINARY);
+ break;
+ case 10:
+ fd = open(GLYPH_CACHE_FILE_USER6, O_RDONLY|O_BINARY);
+ break;
+ case 11:
+ fd = open(GLYPH_CACHE_FILE_USER7, O_RDONLY|O_BINARY);
+ break;
+ default:
+ return;
+ }
+
if (fd >= 0) {
while (read(fd, tmp, 2) == 2) {
ch = (tmp[0] << 8) | tmp[1];
- font_get_bits(pf, ch);
+ font_get_bits(pf, ch, font);
}
-
+
close(fd);
} else {
/* load latin1 chars into cache */
ch = 256;
while (ch-- > 32)
- font_get_bits(pf, ch);
+ font_get_bits(pf, ch, font);
}
}
return;
diff -u -r rockbox_svn.orig/firmware/font_cache.c rockbox_svn/firmware/font_cache.c
--- rockbox_svn.orig/firmware/font_cache.c 2007-07-19 18:44:30.578125000 -0500
+++ rockbox_svn/firmware/font_cache.c 2007-09-30 07:08:04.937500000 -0500
@@ -23,8 +23,9 @@
/*******************************************************************************
* font_cache_lru_init
******************************************************************************/
-void font_cache_lru_init(void* data)
+void font_cache_lru_init(void* data, int font)
{
+ font = 0; /* Kill gcc warning */
struct font_cache_entry* p = data;
p->_char_code = 0xffff; /* assume invalid char */
}
@@ -60,7 +61,7 @@
lru_create(&fcache->_lru, lru_buf, cache_size, font_cache_entry_size);
/* initialise cache */
- lru_traverse(&fcache->_lru, font_cache_lru_init);
+ lru_traverse(&fcache->_lru, font_cache_lru_init, NULL); /* font parameter not needed for callback */
short i;
for (i = 0; i < cache_size; i++)
fcache->_index[i] = i; /* small cheat here */
@@ -158,8 +159,8 @@
struct font_cache_entry* font_cache_get(
struct font_cache* fcache,
unsigned short char_code,
- void (*callback) (struct font_cache_entry* p, void *callback_data),
- void *callback_data)
+ void (*callback) (struct font_cache_entry* p, void *callback_data, int font),
+ void *callback_data, int font)
{
int insertion_point = font_cache_insertion_point(fcache, char_code);
if (insertion_point >= 0)
@@ -207,7 +208,7 @@
fcache->_size++;
p->_char_code = char_code;
- callback(p, callback_data);
+ callback(p, callback_data, font);
return p;
}
diff -u -r rockbox_svn.orig/firmware/include/font_cache.h rockbox_svn/firmware/include/font_cache.h
--- rockbox_svn.orig/firmware/include/font_cache.h 2007-07-19 18:43:56.015625000 -0500
+++ rockbox_svn/firmware/include/font_cache.h 2007-09-30 07:08:04.953125000 -0500
@@ -21,6 +21,10 @@
/*******************************************************************************
*
******************************************************************************/
+
+/* Maximum loadable/cacheable fonts. Exclude sysfont since it's compiled in */
+#define MAXCACHEFONTS MAXFONTS-1
+
struct font_cache
{
struct lru _lru;
@@ -36,6 +40,19 @@
unsigned char bitmap[1]; /* place holder */
};
+/* Per-font internal cache struct */
+struct font_file_info
+{
+ unsigned long file_width_offset; /* offset to file width data */
+ unsigned long file_offset_offset; /* offset to file offset data */
+ int long_offset;
+ int glyph_fd;
+ unsigned char *freeptr;
+ unsigned char *fileptr;
+ unsigned char *eofptr;
+ int font_fd; /* >=0 if font is cached */
+};
+
/* void (*f) (void*, struct font_cache_entry*); */
/* Create an auto sized font cache from buf */
void font_cache_create(
@@ -44,5 +61,5 @@
struct font_cache_entry* font_cache_get(
struct font_cache* fcache,
unsigned short char_code,
- void (*callback) (struct font_cache_entry* p, void *callback_data),
- void *callback_data);
+ void (*callback) (struct font_cache_entry* p, void *callback_data, int font),
+ void *callback_data, int font);
diff -u -r rockbox_svn.orig/firmware/include/lru.h rockbox_svn/firmware/include/lru.h
--- rockbox_svn.orig/firmware/include/lru.h 2007-07-19 18:43:56.265625000 -0500
+++ rockbox_svn/firmware/include/lru.h 2007-09-30 07:08:04.953125000 -0500
@@ -40,7 +40,7 @@
/* Data */
void *lru_data(struct lru* pl, short handle);
/* Traverse lru-wise */
-void lru_traverse(struct lru* pl, void (*callback)(void* data));
+void lru_traverse(struct lru* pl, void (*callback)(void* data, int font), int font);
#endif /* LRU_H */
diff -u -r rockbox_svn.orig/firmware/lru.c rockbox_svn/firmware/lru.c
--- rockbox_svn.orig/firmware/lru.c 2007-07-19 18:44:30.828125000 -0500
+++ rockbox_svn/firmware/lru.c 2007-09-30 07:08:04.968750000 -0500
@@ -57,7 +57,7 @@
/*******************************************************************************
* lru_traverse
******************************************************************************/
-void lru_traverse(struct lru* pl, void (*callback)(void* data))
+void lru_traverse(struct lru* pl, void (*callback)(void* data, int font), int font)
{
short i;
struct lru_node* slot;
@@ -66,7 +66,7 @@
for (i = 0; i < pl->_size; i++)
{
slot = lru_node_p(pl, loc);
- callback(slot->data);
+ callback(slot->data, font);
loc = slot->_next;
}
}
diff -u -r rockbox_svn.orig/firmware/powermgmt.c rockbox_svn/firmware/powermgmt.c
--- rockbox_svn.orig/firmware/powermgmt.c 2007-09-29 22:51:23.937500000 -0500
+++ rockbox_svn/firmware/powermgmt.c 2007-09-30 07:08:04.984375000 -0500
@@ -1156,7 +1156,12 @@
audio_stop();
if (battery_level_safe()) { /* do not save on critical battery */
#ifdef HAVE_LCD_BITMAP
- glyph_cache_save();
+ int i = FONT_BROWSER; /* Skip sysfont, even though glyph_cache_save() would ignore it */
+ while (i < MAXFONTS)
+ {
+ glyph_cache_save(i);
+ i++;
+ }
#endif
if(ata_disk_is_active())
ata_spindown(1);
diff -u -r rockbox_svn.orig/tools/convbdf.c rockbox_svn/tools/convbdf.c
--- rockbox_svn.orig/tools/convbdf.c 2007-07-31 11:16:03.281250000 -0500
+++ rockbox_svn/tools/convbdf.c 2007-09-30 07:08:05.000000000 -0500
@@ -354,7 +354,7 @@
continue;
}
if (isprefix(buf, "COPYRIGHT ")) { /* not required*/
- if (sscanf(buf, "COPYRIGHT \"%[^\"]", copyright) != 1) {
+ if (sscanf(buf, "COPYRIGHT \"%s\"", copyright) != 1) {
fprintf(stderr, "Error: bad 'COPYRIGHT'\n");
return 0;
}