diff options
| author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-02-14 06:26:16 +0000 |
|---|---|---|
| committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-02-14 06:26:16 +0000 |
| commit | 1c2aa35371aed8d895b3448dad865b913da57cfb (patch) | |
| tree | 8a790ad8efe5d0abd73eaf77adc854d336ce0ef4 /apps | |
| parent | ed21ab1c8c9b16ec62933313c3d36a93d9255f62 (diff) | |
| download | rockbox-1c2aa35371aed8d895b3448dad865b913da57cfb.zip rockbox-1c2aa35371aed8d895b3448dad865b913da57cfb.tar.gz rockbox-1c2aa35371aed8d895b3448dad865b913da57cfb.tar.bz2 rockbox-1c2aa35371aed8d895b3448dad865b913da57cfb.tar.xz | |
FS#10984 - multifont! 2 major additions:
1) seperate UI font for the remote and main displays
2) allow individual skins to load additional fonts for use in the skin (Uo to 7 extra in this first version) see CustomWPS for info on how to load a font in the skins.
Code should always use FONT_UI+screen_number to get the correct user font
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24644 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/SOURCES | 3 | ||||
| -rw-r--r-- | apps/filetree.c | 30 | ||||
| -rw-r--r-- | apps/gui/skin_engine/skin_fonts.c | 139 | ||||
| -rw-r--r-- | apps/gui/skin_engine/skin_fonts.h | 46 | ||||
| -rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 40 | ||||
| -rw-r--r-- | apps/gui/statusbar-skinned.c | 4 | ||||
| -rw-r--r-- | apps/gui/viewport.c | 16 | ||||
| -rw-r--r-- | apps/lang/english.lang | 34 | ||||
| -rw-r--r-- | apps/plugin.c | 24 | ||||
| -rw-r--r-- | apps/plugin.h | 39 | ||||
| -rw-r--r-- | apps/plugins/rockpaint.c | 10 | ||||
| -rw-r--r-- | apps/settings.c | 20 | ||||
| -rw-r--r-- | apps/settings.h | 3 | ||||
| -rw-r--r-- | apps/settings_list.c | 4 |
14 files changed, 357 insertions, 55 deletions
diff --git a/apps/SOURCES b/apps/SOURCES index 7580caa..cd7cde7 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -90,6 +90,9 @@ gui/viewport.c gui/skin_engine/skin_buffer.c gui/skin_engine/wps_debug.c gui/skin_engine/skin_display.c +#ifdef HAVE_LCD_BITMAP +gui/skin_engine/skin_fonts.c +#endif gui/skin_engine/skin_parser.c gui/skin_engine/skin_tokens.c diff --git a/apps/filetree.c b/apps/filetree.c index 6062080..c9c8b38 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -379,6 +379,32 @@ int ft_load(struct tree_context* c, const char* tempdir) return 0; } +#ifdef HAVE_LCD_BITMAP +static void ft_load_font(char *file) +{ +#if NB_SCREENS > 1 + MENUITEM_STRINGLIST(menu, ID2P(LANG_CUSTOM_FONT), NULL, + ID2P(LANG_MAIN_SCREEN), ID2P(LANG_REMOTE_SCREEN)) + switch (do_menu(&menu, NULL, NULL, false)) + { + case 0: /* main lcd */ + splash(0, ID2P(LANG_WAIT)); + font_load(NULL, file); + set_file(file, (char *)global_settings.font_file, MAX_FILENAME); + break; + case 1: /* remote */ + splash(0, ID2P(LANG_WAIT)); + font_load_remoteui(file); + set_file(file, (char *)global_settings.remote_font_file, MAX_FILENAME); + break; + } +#else + splash(0, ID2P(LANG_WAIT)); + font_load(NULL, file); + set_file(file, (char *)global_settings.font_file, MAX_FILENAME); +#endif +} +#endif int ft_enter(struct tree_context* c) { @@ -547,9 +573,7 @@ int ft_enter(struct tree_context* c) #ifdef HAVE_LCD_BITMAP case FILE_ATTR_FONT: - splash(0, ID2P(LANG_WAIT)); - font_load(buf); - set_file(buf, (char *)global_settings.font_file, MAX_FILENAME); + ft_load_font(buf); break; case FILE_ATTR_KBD: diff --git a/apps/gui/skin_engine/skin_fonts.c b/apps/gui/skin_engine/skin_fonts.c new file mode 100644 index 0000000..1d3ef84 --- /dev/null +++ b/apps/gui/skin_engine/skin_fonts.c @@ -0,0 +1,139 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: skin_tokens.c 24526 2010-02-05 23:58:53Z jdgordon $ + * + * Copyright (C) 2010 Jonathan Gordon + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include "file.h" +#include "settings.h" +#include "font.h" +#include "skin_buffer.h" +#include "skin_fonts.h" +#define FONT_SIZE 10000 + + +static struct skin_font { + struct font font; + int font_id; + char name[MAX_PATH]; + char *buffer; + int ref_count; /* how many times has this font been loaded? */ +} font_table[MAXUSERFONTS]; + +/* need this to know if we should be closing font fd's on the next init */ +static bool first_load = true; + +void skin_font_init(void) +{ + int i; + for(i=0;i<MAXUSERFONTS;i++) + { + if (!first_load) + font_unload(font_table[i].font_id); + font_table[i].font_id = -1; + font_table[i].name[0] = '\0'; + font_table[i].buffer = NULL; + font_table[i].ref_count = 0; + } +} + +/* load a font into the skin buffer. return the font id. */ +int skin_font_load(char* font_name) +{ + int i; + struct font *pf; + struct skin_font *font = NULL; + char filename[MAX_PATH]; + + if (!strcmp(font_name, global_settings.font_file)) + return FONT_UI; +#ifdef HAVE_REMOTE_LCD + if (!strcmp(font_name, global_settings.remote_font_file)) + return FONT_UI_REMOTE; +#endif + for(i=0;i<MAXUSERFONTS;i++) + { + if (font_table[i].font_id >= 0 && !strcmp(font_table[i].name, font_name)) + { + font_table[i].ref_count++; + return font_table[i].font_id; + } + else if (!font && font_table[i].font_id == -1) + { + font = &font_table[i]; + } + } + if (!font) + return -1; /* too many fonts loaded */ + + pf = &font->font; + if (!font->buffer) + { + pf->buffer_start = skin_buffer_alloc(FONT_SIZE); + if (!pf->buffer_start) + return -1; + font->buffer = pf->buffer_start; + } + else + { + pf->buffer_start = font->buffer; + } + pf->buffer_size = FONT_SIZE; + + snprintf(filename, MAX_PATH, FONT_DIR "/%s.fnt", font_name); + strcpy(font->name, font_name); + + pf->fd = -1; + font->font_id = font_load(pf, filename); + + if (font->font_id < 0) + return -1; + font->ref_count = 1; + + return font->font_id; +} + +/* unload a skin font. If a font has been loaded more than once it wont actually + * be unloaded untill all references have been unloaded */ +void skin_font_unload(int font_id) +{ + int i; + for(i=0;i<MAXUSERFONTS;i++) + { + if (font_table[i].font_id == font_id) + { + if (--font_table[i].ref_count == 0) + { + font_unload(font_id); + font_table[i].font_id = -1; + font_table[i].name[0] = '\0'; + } + return; + } + } +} + + + + + diff --git a/apps/gui/skin_engine/skin_fonts.h b/apps/gui/skin_engine/skin_fonts.h new file mode 100644 index 0000000..3b43012 --- /dev/null +++ b/apps/gui/skin_engine/skin_fonts.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: skin_tokens.c 24526 2010-02-05 23:58:53Z jdgordon $ + * + * Copyright (C) 2010 Jonathan Gordon + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include "file.h" +#include "settings.h" +#include "font.h" +#include "skin_buffer.h" + +#ifndef _SKINFONTS_H_ +#define _SKINFONTS_H_ + +#define MAXUSERFONTS (MAXFONTS - SYSTEMFONTCOUNT) + +void skin_font_init(void); + +/* load a font into the skin buffer. return the font id. */ +int skin_font_load(char* font_name); + +/* unload a skin font. If a font has been loaded more than once it wont actually + * be unloaded untill all references have been unloaded */ +void skin_font_unload(int font_id); + +#endif diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 4655bf0..034ff53 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -52,6 +52,7 @@ #include "skin_engine.h" #include "settings.h" #include "settings_list.h" +#include "skin_fonts.h" #ifdef HAVE_LCD_BITMAP #include "bmp.h" @@ -157,6 +158,8 @@ static int parse_image_display(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data); static int parse_image_load(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data); +static int parse_font_load(const char *wps_bufptr, + struct wps_token *token, struct wps_data *wps_data); #endif /*HAVE_LCD_BITMAP */ #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) static int parse_image_special(const char *wps_bufptr, @@ -353,6 +356,7 @@ static const struct wps_tag all_tags[] = { parse_image_display }, { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, + { WPS_NO_TOKEN, "Fl", 0, parse_font_load }, #ifdef HAVE_ALBUMART { WPS_NO_TOKEN, "Cl", 0, parse_albumart_load }, { WPS_TOKEN_ALBUMART_DISPLAY, "C", WPS_REFRESH_STATIC, parse_albumart_display }, @@ -688,6 +692,39 @@ static int parse_image_load(const char *wps_bufptr, return skip_end_of_line(wps_bufptr); } +static int font_ids[MAXUSERFONTS]; +static int parse_font_load(const char *wps_bufptr, + struct wps_token *token, struct wps_data *wps_data) +{ + (void)wps_data; (void)token; + const char *ptr = wps_bufptr; + int id; + char *filename, buf[MAX_PATH]; + + if (*ptr != '|') + return WPS_ERROR_INVALID_PARAM; + + ptr++; + + if (!(ptr = parse_list("ds", NULL, '|', ptr, &id, &filename))) + return WPS_ERROR_INVALID_PARAM; + + /* Check there is a terminating | */ + if (*ptr != '|') + return WPS_ERROR_INVALID_PARAM; + + if (id <= FONT_UI || id >= MAXFONTS-1) + return WPS_ERROR_INVALID_PARAM; + id -= SYSTEMFONTCOUNT; + + memcpy(buf, filename, ptr-filename); + buf[ptr-filename] = '\0'; + font_ids[id] = skin_font_load(buf); + + return font_ids[id] >= 0 ? skip_end_of_line(wps_bufptr) : WPS_ERROR_INVALID_PARAM; +} + + static int parse_viewport_display(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data) @@ -890,7 +927,8 @@ static int parse_viewport(const char *wps_bufptr, else vp->flags &= ~VP_FLAG_ALIGN_RIGHT; /* ignore right-to-left languages */ - + if (vp->font >= SYSTEMFONTCOUNT) + vp->font = font_ids[vp->font - SYSTEMFONTCOUNT]; struct skin_token_list *list = new_skin_token_list_item(NULL, skin_vp); if (!list) diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c index 9d447f6..fac6756 100644 --- a/apps/gui/statusbar-skinned.c +++ b/apps/gui/statusbar-skinned.c @@ -32,6 +32,7 @@ #include "statusbar.h" #include "statusbar-skinned.h" #include "debug.h" +#include "font.h" /* currently only one wps_state is needed */ @@ -183,7 +184,8 @@ void sb_create_from_settings(enum screen_type screen) default: height = screens[screen].lcdheight; } - len = snprintf(ptr, remaining, "%%ax%%Vi|0|%d|-|%d|1|-|-|\n", y, height); + len = snprintf(ptr, remaining, "%%ax%%Vi|0|%d|-|%d|%d|-|-|\n", + y, height, FONT_UI + screen); } sb_skin_data_load(screen, buf, false); } diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index eaee2cc..ee233b9 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c @@ -315,7 +315,7 @@ void viewport_set_fullscreen(struct viewport *vp, #ifndef __PCTOOL__ set_default_align_flags(vp); #endif - vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ + vp->font = FONT_UI + screen; /* default to UI to discourage SYSFONT use */ vp->drawmode = DRMODE_SOLID; #if LCD_DEPTH > 1 #ifdef HAVE_REMOTE_LCD @@ -453,11 +453,15 @@ const char* viewport_parse_viewport(struct viewport *vp, return NULL; } - /* Default to using the user font if the font was an invalid number or '-'*/ - if (((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI)) - || !LIST_VALUE_PARSED(set, PL_FONT) - ) - vp->font = FONT_UI; + /* Default to using the user font if the font was an invalid number or '-' + * font 1 is *always* the UI font for the current screen + * 2 is always the first extra font */ + if (!LIST_VALUE_PARSED(set, PL_FONT)) + vp->font = FONT_UI + screen; +#ifdef HAVE_REMOTE_LCD + else if (vp->font == FONT_UI && screen == SCREEN_REMOTE) + vp->font = FONT_UI_REMOTE; +#endif /* Set the defaults for fields not user-specified */ vp->drawmode = DRMODE_SOLID; diff --git a/apps/lang/english.lang b/apps/lang/english.lang index afb60e1..ecbd415 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -13315,3 +13315,37 @@ lcd_bitmap: "Remote Base Skin" </voice> </phrase> +<phrase> + id: LANG_MAIN_SCREEN + desc: in the main menu + user: core + <source> + *:none + remote: "Main Screen" + </source> + <dest> + *:none + remote: "Main Screen" + </dest> + <voice> + *:none + remote: "Main Screen" + </voice> +</phrase> +<phrase> + id: LANG_REMOTE_SCREEN + desc: in the main menu + user: core + <source> + *:none + remote: "Remote Screen" + </source> + <dest> + *:none + remote: "Remote Screen" + </dest> + <voice> + *:none + remote: "Remote Screen" + </voice> +</phrase> diff --git a/apps/plugin.c b/apps/plugin.c index 0d4d8ed..46ab6e6 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -247,6 +247,10 @@ static const struct plugin_api rockbox_api = { lcd_remote_bitmap, #endif viewport_set_defaults, +#ifdef HAVE_LCD_BITMAP + viewportmanager_theme_enable, + viewportmanager_theme_undo, +#endif /* list */ gui_synclist_init, @@ -292,6 +296,7 @@ static const struct plugin_api rockbox_api = { #endif /* HAVE_BUTTON_LIGHT */ /* file */ + open_utf8, #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE (open_func)open_wrapper, close_wrapper, @@ -325,6 +330,7 @@ static const struct plugin_api rockbox_api = { create_numbered_filename, file_exists, strip_extension, + crc_32, /* dir */ opendir, @@ -432,6 +438,7 @@ static const struct plugin_api rockbox_api = { atoi, strchr, strcat, + strlcat, memchr, memcmp, strcasestr, @@ -476,6 +483,7 @@ static const struct plugin_api rockbox_api = { pcm_get_peak_buffer, pcm_play_lock, pcm_play_unlock, + pcmbuf_beep, #ifdef HAVE_RECORDING &rec_freq_sampr[0], pcm_init_recording, @@ -588,6 +596,9 @@ static const struct plugin_api rockbox_api = { #endif /* misc */ +#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__) + &errno, +#endif srand, rand, (qsort_func)qsort, @@ -698,19 +709,6 @@ static const struct plugin_api rockbox_api = { appsversion, /* new stuff at the end, sort into place next time the API gets incompatible */ -#if (CONFIG_CODEC == SWCODEC) - pcmbuf_beep, -#endif - crc_32, - open_utf8, -#ifdef HAVE_LCD_BITMAP - viewportmanager_theme_enable, - viewportmanager_theme_undo, -#endif -#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__) - &errno, -#endif - strlcat, }; int plugin_load(const char* plugin, const void* parameter) diff --git a/apps/plugin.h b/apps/plugin.h index e5766c6..b1cfa30 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -135,12 +135,12 @@ void* plugin_get_buffer(size_t *buffer_size); #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 180 +#define PLUGIN_API_VERSION 181 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 180 +#define PLUGIN_MIN_API_VERSION 181 /* plugin return codes */ enum plugin_status { @@ -250,7 +250,7 @@ struct plugin_api { #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); + int (*font_load)(struct font*, const char *path); struct font* (*font_get)(int font); int (*font_getstringsize)(const unsigned char *str, int *w, int *h, int fontnumber); @@ -336,7 +336,12 @@ struct plugin_api { int width, int height); #endif void (*viewport_set_defaults)(struct viewport *vp, - const enum screen_type screen); + const enum screen_type screen); +#ifdef HAVE_LCD_BITMAP + void (*viewportmanager_theme_enable)(enum screen_type screen, bool enable, + struct viewport *viewport); + void (*viewportmanager_theme_undo)(enum screen_type screen, bool force_redraw); +#endif /* list */ void (*gui_synclist_init)(struct gui_synclist * lists, list_get_name callback_get_item_name, void * data, @@ -390,6 +395,7 @@ struct plugin_api { #endif /* HAVE_BUTTON_LIGHT */ /* file */ + int (*open_utf8)(const char* pathname, int flags); int (*open)(const char* pathname, int flags); int (*close)(int fd); ssize_t (*read)(int fd, void* buf, size_t count); @@ -416,6 +422,7 @@ struct plugin_api { int numberlen IF_CNFN_NUM_(, int *num)); bool (*file_exists)(const char *file); char* (*strip_extension)(char* buffer, int buffer_size, const char *filename); + unsigned (*crc_32)(const void *src, unsigned len, unsigned crc32); /* dir */ @@ -537,6 +544,7 @@ struct plugin_api { int (*atoi)(const char *str); char *(*strchr)(const char *s, int c); char *(*strcat)(char *s1, const char *s2); + size_t (*strlcat)(char *dst, const char *src, size_t length); void *(*memchr)(const void *s1, int c, size_t n); int (*memcmp)(const void *s1, const void *s2, size_t n); char *(*strcasestr) (const char* phaystack, const char* pneedle); @@ -583,6 +591,9 @@ struct plugin_api { const void* (*pcm_get_peak_buffer)(int *count); void (*pcm_play_lock)(void); void (*pcm_play_unlock)(void); + void (*pcmbuf_beep)(unsigned int frequency, + size_t duration, + int amplitude); #ifdef HAVE_RECORDING const unsigned long *rec_freq_sampr; void (*pcm_init_recording)(void); @@ -716,6 +727,9 @@ struct plugin_api { #endif /* misc */ +#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__) + int* __errno; +#endif void (*srand)(unsigned int seed); int (*rand)(void); void (*qsort)(void *base, size_t nmemb, size_t size, @@ -848,23 +862,6 @@ struct plugin_api { const char *appsversion; /* new stuff at the end, sort into place next time the API gets incompatible */ - -#if (CONFIG_CODEC == SWCODEC) - void (*pcmbuf_beep)(unsigned int frequency, - size_t duration, - int amplitude); -#endif - unsigned (*crc_32)(const void *src, unsigned len, unsigned crc32); - int (*open_utf8)(const char* pathname, int flags); -#ifdef HAVE_LCD_BITMAP - void (*viewportmanager_theme_enable)(enum screen_type screen, bool enable, - struct viewport *viewport); - void (*viewportmanager_theme_undo)(enum screen_type screen, bool force_redraw); -#endif -#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__) - int* __errno; -#endif - size_t (*strlcat)(char *dst, const char *src, size_t length); }; /* plugin header */ diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c index 96de7ab..ae28258 100644 --- a/apps/plugins/rockpaint.c +++ b/apps/plugins/rockpaint.c @@ -854,7 +854,7 @@ static bool browse_fonts( char *dst, int dst_size ) continue; rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s", de->d_name ); - rb->font_load( bbuf ); + rb->font_load(NULL, bbuf ); rb->font_getstringsize( de->d_name, &fw, &fh, FONT_UI ); if( nvih > 0 ) { @@ -887,12 +887,12 @@ static bool browse_fonts( char *dst, int dst_size ) { rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s", de->d_name ); - rb->font_load( bbuf ); + rb->font_load(NULL, bbuf ); rb->font_getstringsize( de->d_name, NULL, &fh, FONT_UI ); nvih = fh; } } - rb->font_load( buffer.text.old_font ); + rb->font_load(NULL, buffer.text.old_font ); rb->closedir( d ); } @@ -1526,7 +1526,7 @@ static void draw_text( int x, int y ) case TEXT_MENU_FONT: if( browse_fonts( buffer.text.font, MAX_PATH ) ) { - rb->font_load( buffer.text.font ); + rb->font_load(NULL, buffer.text.font ); } break; @@ -1583,7 +1583,7 @@ static void draw_text( int x, int y ) case TEXT_MENU_CANCEL: default: restore_screen(); - rb->font_load( buffer.text.old_font ); + rb->font_load(NULL, buffer.text.old_font ); return; } } diff --git a/apps/settings.c b/apps/settings.c index becb516..574aa27 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -68,6 +68,7 @@ #endif #include "wps.h" #include "skin_engine/skin_engine.h" +#include "skin_engine/skin_fonts.h" #include "viewport.h" #include "statusbar-skinned.h" @@ -740,6 +741,7 @@ void settings_apply_skins(void) /* re-initialize the skin buffer before we start reloading skins */ skin_buffer_init(); #ifdef HAVE_LCD_BITMAP + skin_font_init(); if ( global_settings.sbs_file[0] && global_settings.sbs_file[0] != 0xff ) { @@ -887,18 +889,26 @@ void settings_apply(bool read_disk) if (read_disk) { - #ifdef HAVE_LCD_BITMAP /* fonts need to be loaded before the WPS */ if ( global_settings.font_file[0]) { snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", global_settings.font_file); - if (font_load(buf) == NULL) - font_reset(); + if (font_load(NULL, buf) < 0) + font_reset(NULL); } else - font_reset(); - + font_reset(NULL); +#ifdef HAVE_REMOTE_LCD + if ( global_settings.remote_font_file[0]) { + snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", + global_settings.remote_font_file); + if (font_load_remoteui(buf) < 0) + font_load_remoteui(NULL); + } + else + font_load_remoteui(NULL); +#endif if ( global_settings.kbd_file[0]) { snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd", global_settings.kbd_file); diff --git a/apps/settings.h b/apps/settings.h index ea7138c..6a42ca3 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -681,6 +681,9 @@ struct user_settings unsigned char icon_file[MAX_FILENAME+1]; unsigned char viewers_icon_file[MAX_FILENAME+1]; unsigned char font_file[MAX_FILENAME+1]; /* last font */ +#ifdef HAVE_REMOTE_LCD + unsigned char remote_font_file[MAX_FILENAME+1]; /* last font */ +#endif unsigned char kbd_file[MAX_FILENAME+1]; /* last keyboard */ #endif /* HAVE_LCD_BITMAP */ diff --git a/apps/settings_list.c b/apps/settings_list.c index c5f9932..d2700b3 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -1432,6 +1432,10 @@ const struct settings_list settings[] = { TEXT_SETTING(F_THEMESETTING, font_file, "font", DEFAULT_FONTNAME, FONT_DIR "/", ".fnt"), #endif +#ifdef HAVE_REMOTE_LCD + TEXT_SETTING(F_THEMESETTING, remote_font_file, "remote font", + "", FONT_DIR "/", ".fnt"), +#endif TEXT_SETTING(F_THEMESETTING,wps_file, "wps", DEFAULT_WPSNAME, WPS_DIR "/", ".wps"), #ifdef HAVE_LCD_BITMAP |