summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-02-14 06:26:16 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-02-14 06:26:16 +0000
commit1c2aa35371aed8d895b3448dad865b913da57cfb (patch)
tree8a790ad8efe5d0abd73eaf77adc854d336ce0ef4
parented21ab1c8c9b16ec62933313c3d36a93d9255f62 (diff)
downloadrockbox-1c2aa35371aed8d895b3448dad865b913da57cfb.tar.gz
rockbox-1c2aa35371aed8d895b3448dad865b913da57cfb.zip
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
-rw-r--r--apps/SOURCES3
-rw-r--r--apps/filetree.c30
-rw-r--r--apps/gui/skin_engine/skin_fonts.c139
-rw-r--r--apps/gui/skin_engine/skin_fonts.h46
-rw-r--r--apps/gui/skin_engine/skin_parser.c40
-rw-r--r--apps/gui/statusbar-skinned.c4
-rw-r--r--apps/gui/viewport.c16
-rw-r--r--apps/lang/english.lang34
-rw-r--r--apps/plugin.c24
-rw-r--r--apps/plugin.h39
-rw-r--r--apps/plugins/rockpaint.c10
-rw-r--r--apps/settings.c20
-rw-r--r--apps/settings.h3
-rw-r--r--apps/settings_list.c4
-rw-r--r--firmware/export/font.h35
-rw-r--r--firmware/font.c369
-rw-r--r--firmware/powermgmt.c2
-rw-r--r--tools/checkwps/SOURCES3
-rw-r--r--tools/checkwps/checkwps.c16
-rw-r--r--tools/convbdf.c11
20 files changed, 643 insertions, 205 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index 7580caabc9..cd7cde7639 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -90,6 +90,9 @@ gui/viewport.c
90gui/skin_engine/skin_buffer.c 90gui/skin_engine/skin_buffer.c
91gui/skin_engine/wps_debug.c 91gui/skin_engine/wps_debug.c
92gui/skin_engine/skin_display.c 92gui/skin_engine/skin_display.c
93#ifdef HAVE_LCD_BITMAP
94gui/skin_engine/skin_fonts.c
95#endif
93gui/skin_engine/skin_parser.c 96gui/skin_engine/skin_parser.c
94gui/skin_engine/skin_tokens.c 97gui/skin_engine/skin_tokens.c
95 98
diff --git a/apps/filetree.c b/apps/filetree.c
index 6062080baa..c9c8b3810a 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -379,6 +379,32 @@ int ft_load(struct tree_context* c, const char* tempdir)
379 379
380 return 0; 380 return 0;
381} 381}
382#ifdef HAVE_LCD_BITMAP
383static void ft_load_font(char *file)
384{
385#if NB_SCREENS > 1
386 MENUITEM_STRINGLIST(menu, ID2P(LANG_CUSTOM_FONT), NULL,
387 ID2P(LANG_MAIN_SCREEN), ID2P(LANG_REMOTE_SCREEN))
388 switch (do_menu(&menu, NULL, NULL, false))
389 {
390 case 0: /* main lcd */
391 splash(0, ID2P(LANG_WAIT));
392 font_load(NULL, file);
393 set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
394 break;
395 case 1: /* remote */
396 splash(0, ID2P(LANG_WAIT));
397 font_load_remoteui(file);
398 set_file(file, (char *)global_settings.remote_font_file, MAX_FILENAME);
399 break;
400 }
401#else
402 splash(0, ID2P(LANG_WAIT));
403 font_load(NULL, file);
404 set_file(file, (char *)global_settings.font_file, MAX_FILENAME);
405#endif
406}
407#endif
382 408
383int ft_enter(struct tree_context* c) 409int ft_enter(struct tree_context* c)
384{ 410{
@@ -547,9 +573,7 @@ int ft_enter(struct tree_context* c)
547 573
548#ifdef HAVE_LCD_BITMAP 574#ifdef HAVE_LCD_BITMAP
549 case FILE_ATTR_FONT: 575 case FILE_ATTR_FONT:
550 splash(0, ID2P(LANG_WAIT)); 576 ft_load_font(buf);
551 font_load(buf);
552 set_file(buf, (char *)global_settings.font_file, MAX_FILENAME);
553 break; 577 break;
554 578
555 case FILE_ATTR_KBD: 579 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 0000000000..1d3ef84271
--- /dev/null
+++ b/apps/gui/skin_engine/skin_fonts.c
@@ -0,0 +1,139 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: skin_tokens.c 24526 2010-02-05 23:58:53Z jdgordon $
9 *
10 * Copyright (C) 2010 Jonathan Gordon
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include <stdio.h>
24#include <string.h>
25#include <stdlib.h>
26
27#include "file.h"
28#include "settings.h"
29#include "font.h"
30#include "skin_buffer.h"
31#include "skin_fonts.h"
32#define FONT_SIZE 10000
33
34
35static struct skin_font {
36 struct font font;
37 int font_id;
38 char name[MAX_PATH];
39 char *buffer;
40 int ref_count; /* how many times has this font been loaded? */
41} font_table[MAXUSERFONTS];
42
43/* need this to know if we should be closing font fd's on the next init */
44static bool first_load = true;
45
46void skin_font_init(void)
47{
48 int i;
49 for(i=0;i<MAXUSERFONTS;i++)
50 {
51 if (!first_load)
52 font_unload(font_table[i].font_id);
53 font_table[i].font_id = -1;
54 font_table[i].name[0] = '\0';
55 font_table[i].buffer = NULL;
56 font_table[i].ref_count = 0;
57 }
58}
59
60/* load a font into the skin buffer. return the font id. */
61int skin_font_load(char* font_name)
62{
63 int i;
64 struct font *pf;
65 struct skin_font *font = NULL;
66 char filename[MAX_PATH];
67
68 if (!strcmp(font_name, global_settings.font_file))
69 return FONT_UI;
70#ifdef HAVE_REMOTE_LCD
71 if (!strcmp(font_name, global_settings.remote_font_file))
72 return FONT_UI_REMOTE;
73#endif
74 for(i=0;i<MAXUSERFONTS;i++)
75 {
76 if (font_table[i].font_id >= 0 && !strcmp(font_table[i].name, font_name))
77 {
78 font_table[i].ref_count++;
79 return font_table[i].font_id;
80 }
81 else if (!font && font_table[i].font_id == -1)
82 {
83 font = &font_table[i];
84 }
85 }
86 if (!font)
87 return -1; /* too many fonts loaded */
88
89 pf = &font->font;
90 if (!font->buffer)
91 {
92 pf->buffer_start = skin_buffer_alloc(FONT_SIZE);
93 if (!pf->buffer_start)
94 return -1;
95 font->buffer = pf->buffer_start;
96 }
97 else
98 {
99 pf->buffer_start = font->buffer;
100 }
101 pf->buffer_size = FONT_SIZE;
102
103 snprintf(filename, MAX_PATH, FONT_DIR "/%s.fnt", font_name);
104 strcpy(font->name, font_name);
105
106 pf->fd = -1;
107 font->font_id = font_load(pf, filename);
108
109 if (font->font_id < 0)
110 return -1;
111 font->ref_count = 1;
112
113 return font->font_id;
114}
115
116/* unload a skin font. If a font has been loaded more than once it wont actually
117 * be unloaded untill all references have been unloaded */
118void skin_font_unload(int font_id)
119{
120 int i;
121 for(i=0;i<MAXUSERFONTS;i++)
122 {
123 if (font_table[i].font_id == font_id)
124 {
125 if (--font_table[i].ref_count == 0)
126 {
127 font_unload(font_id);
128 font_table[i].font_id = -1;
129 font_table[i].name[0] = '\0';
130 }
131 return;
132 }
133 }
134}
135
136
137
138
139
diff --git a/apps/gui/skin_engine/skin_fonts.h b/apps/gui/skin_engine/skin_fonts.h
new file mode 100644
index 0000000000..3b43012de3
--- /dev/null
+++ b/apps/gui/skin_engine/skin_fonts.h
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: skin_tokens.c 24526 2010-02-05 23:58:53Z jdgordon $
9 *
10 * Copyright (C) 2010 Jonathan Gordon
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include <stdio.h>
24#include <string.h>
25#include <stdlib.h>
26
27#include "file.h"
28#include "settings.h"
29#include "font.h"
30#include "skin_buffer.h"
31
32#ifndef _SKINFONTS_H_
33#define _SKINFONTS_H_
34
35#define MAXUSERFONTS (MAXFONTS - SYSTEMFONTCOUNT)
36
37void skin_font_init(void);
38
39/* load a font into the skin buffer. return the font id. */
40int skin_font_load(char* font_name);
41
42/* unload a skin font. If a font has been loaded more than once it wont actually
43 * be unloaded untill all references have been unloaded */
44void skin_font_unload(int font_id);
45
46#endif
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 4655bf0dff..034ff532f0 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -52,6 +52,7 @@
52#include "skin_engine.h" 52#include "skin_engine.h"
53#include "settings.h" 53#include "settings.h"
54#include "settings_list.h" 54#include "settings_list.h"
55#include "skin_fonts.h"
55 56
56#ifdef HAVE_LCD_BITMAP 57#ifdef HAVE_LCD_BITMAP
57#include "bmp.h" 58#include "bmp.h"
@@ -157,6 +158,8 @@ static int parse_image_display(const char *wps_bufptr,
157 struct wps_token *token, struct wps_data *wps_data); 158 struct wps_token *token, struct wps_data *wps_data);
158static int parse_image_load(const char *wps_bufptr, 159static int parse_image_load(const char *wps_bufptr,
159 struct wps_token *token, struct wps_data *wps_data); 160 struct wps_token *token, struct wps_data *wps_data);
161static int parse_font_load(const char *wps_bufptr,
162 struct wps_token *token, struct wps_data *wps_data);
160#endif /*HAVE_LCD_BITMAP */ 163#endif /*HAVE_LCD_BITMAP */
161#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) 164#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
162static int parse_image_special(const char *wps_bufptr, 165static int parse_image_special(const char *wps_bufptr,
@@ -353,6 +356,7 @@ static const struct wps_tag all_tags[] = {
353 parse_image_display }, 356 parse_image_display },
354 357
355 { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, 358 { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load },
359 { WPS_NO_TOKEN, "Fl", 0, parse_font_load },
356#ifdef HAVE_ALBUMART 360#ifdef HAVE_ALBUMART
357 { WPS_NO_TOKEN, "Cl", 0, parse_albumart_load }, 361 { WPS_NO_TOKEN, "Cl", 0, parse_albumart_load },
358 { WPS_TOKEN_ALBUMART_DISPLAY, "C", WPS_REFRESH_STATIC, parse_albumart_display }, 362 { WPS_TOKEN_ALBUMART_DISPLAY, "C", WPS_REFRESH_STATIC, parse_albumart_display },
@@ -688,6 +692,39 @@ static int parse_image_load(const char *wps_bufptr,
688 return skip_end_of_line(wps_bufptr); 692 return skip_end_of_line(wps_bufptr);
689} 693}
690 694
695static int font_ids[MAXUSERFONTS];
696static int parse_font_load(const char *wps_bufptr,
697 struct wps_token *token, struct wps_data *wps_data)
698{
699 (void)wps_data; (void)token;
700 const char *ptr = wps_bufptr;
701 int id;
702 char *filename, buf[MAX_PATH];
703
704 if (*ptr != '|')
705 return WPS_ERROR_INVALID_PARAM;
706
707 ptr++;
708
709 if (!(ptr = parse_list("ds", NULL, '|', ptr, &id, &filename)))
710 return WPS_ERROR_INVALID_PARAM;
711
712 /* Check there is a terminating | */
713 if (*ptr != '|')
714 return WPS_ERROR_INVALID_PARAM;
715
716 if (id <= FONT_UI || id >= MAXFONTS-1)
717 return WPS_ERROR_INVALID_PARAM;
718 id -= SYSTEMFONTCOUNT;
719
720 memcpy(buf, filename, ptr-filename);
721 buf[ptr-filename] = '\0';
722 font_ids[id] = skin_font_load(buf);
723
724 return font_ids[id] >= 0 ? skip_end_of_line(wps_bufptr) : WPS_ERROR_INVALID_PARAM;
725}
726
727
691static int parse_viewport_display(const char *wps_bufptr, 728static int parse_viewport_display(const char *wps_bufptr,
692 struct wps_token *token, 729 struct wps_token *token,
693 struct wps_data *wps_data) 730 struct wps_data *wps_data)
@@ -890,7 +927,8 @@ static int parse_viewport(const char *wps_bufptr,
890 else 927 else
891 vp->flags &= ~VP_FLAG_ALIGN_RIGHT; /* ignore right-to-left languages */ 928 vp->flags &= ~VP_FLAG_ALIGN_RIGHT; /* ignore right-to-left languages */
892 929
893 930 if (vp->font >= SYSTEMFONTCOUNT)
931 vp->font = font_ids[vp->font - SYSTEMFONTCOUNT];
894 932
895 struct skin_token_list *list = new_skin_token_list_item(NULL, skin_vp); 933 struct skin_token_list *list = new_skin_token_list_item(NULL, skin_vp);
896 if (!list) 934 if (!list)
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
index 9d447f62db..fac6756aec 100644
--- a/apps/gui/statusbar-skinned.c
+++ b/apps/gui/statusbar-skinned.c
@@ -32,6 +32,7 @@
32#include "statusbar.h" 32#include "statusbar.h"
33#include "statusbar-skinned.h" 33#include "statusbar-skinned.h"
34#include "debug.h" 34#include "debug.h"
35#include "font.h"
35 36
36 37
37/* currently only one wps_state is needed */ 38/* currently only one wps_state is needed */
@@ -183,7 +184,8 @@ void sb_create_from_settings(enum screen_type screen)
183 default: 184 default:
184 height = screens[screen].lcdheight; 185 height = screens[screen].lcdheight;
185 } 186 }
186 len = snprintf(ptr, remaining, "%%ax%%Vi|0|%d|-|%d|1|-|-|\n", y, height); 187 len = snprintf(ptr, remaining, "%%ax%%Vi|0|%d|-|%d|%d|-|-|\n",
188 y, height, FONT_UI + screen);
187 } 189 }
188 sb_skin_data_load(screen, buf, false); 190 sb_skin_data_load(screen, buf, false);
189} 191}
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index eaee2cc8a5..ee233b9c46 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -315,7 +315,7 @@ void viewport_set_fullscreen(struct viewport *vp,
315#ifndef __PCTOOL__ 315#ifndef __PCTOOL__
316 set_default_align_flags(vp); 316 set_default_align_flags(vp);
317#endif 317#endif
318 vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ 318 vp->font = FONT_UI + screen; /* default to UI to discourage SYSFONT use */
319 vp->drawmode = DRMODE_SOLID; 319 vp->drawmode = DRMODE_SOLID;
320#if LCD_DEPTH > 1 320#if LCD_DEPTH > 1
321#ifdef HAVE_REMOTE_LCD 321#ifdef HAVE_REMOTE_LCD
@@ -453,11 +453,15 @@ const char* viewport_parse_viewport(struct viewport *vp,
453 return NULL; 453 return NULL;
454 } 454 }
455 455
456 /* Default to using the user font if the font was an invalid number or '-'*/ 456 /* Default to using the user font if the font was an invalid number or '-'
457 if (((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI)) 457 * font 1 is *always* the UI font for the current screen
458 || !LIST_VALUE_PARSED(set, PL_FONT) 458 * 2 is always the first extra font */
459 ) 459 if (!LIST_VALUE_PARSED(set, PL_FONT))
460 vp->font = FONT_UI; 460 vp->font = FONT_UI + screen;
461#ifdef HAVE_REMOTE_LCD
462 else if (vp->font == FONT_UI && screen == SCREEN_REMOTE)
463 vp->font = FONT_UI_REMOTE;
464#endif
461 465
462 /* Set the defaults for fields not user-specified */ 466 /* Set the defaults for fields not user-specified */
463 vp->drawmode = DRMODE_SOLID; 467 vp->drawmode = DRMODE_SOLID;
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index afb60e107c..ecbd41505d 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -13315,3 +13315,37 @@
13315 lcd_bitmap: "Remote Base Skin" 13315 lcd_bitmap: "Remote Base Skin"
13316 </voice> 13316 </voice>
13317</phrase> 13317</phrase>
13318<phrase>
13319 id: LANG_MAIN_SCREEN
13320 desc: in the main menu
13321 user: core
13322 <source>
13323 *:none
13324 remote: "Main Screen"
13325 </source>
13326 <dest>
13327 *:none
13328 remote: "Main Screen"
13329 </dest>
13330 <voice>
13331 *:none
13332 remote: "Main Screen"
13333 </voice>
13334</phrase>
13335<phrase>
13336 id: LANG_REMOTE_SCREEN
13337 desc: in the main menu
13338 user: core
13339 <source>
13340 *:none
13341 remote: "Remote Screen"
13342 </source>
13343 <dest>
13344 *:none
13345 remote: "Remote Screen"
13346 </dest>
13347 <voice>
13348 *:none
13349 remote: "Remote Screen"
13350 </voice>
13351</phrase>
diff --git a/apps/plugin.c b/apps/plugin.c
index 0d4d8ed0f6..46ab6e6429 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -247,6 +247,10 @@ static const struct plugin_api rockbox_api = {
247 lcd_remote_bitmap, 247 lcd_remote_bitmap,
248#endif 248#endif
249 viewport_set_defaults, 249 viewport_set_defaults,
250#ifdef HAVE_LCD_BITMAP
251 viewportmanager_theme_enable,
252 viewportmanager_theme_undo,
253#endif
250 254
251 /* list */ 255 /* list */
252 gui_synclist_init, 256 gui_synclist_init,
@@ -292,6 +296,7 @@ static const struct plugin_api rockbox_api = {
292#endif /* HAVE_BUTTON_LIGHT */ 296#endif /* HAVE_BUTTON_LIGHT */
293 297
294 /* file */ 298 /* file */
299 open_utf8,
295#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE 300#ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE
296 (open_func)open_wrapper, 301 (open_func)open_wrapper,
297 close_wrapper, 302 close_wrapper,
@@ -325,6 +330,7 @@ static const struct plugin_api rockbox_api = {
325 create_numbered_filename, 330 create_numbered_filename,
326 file_exists, 331 file_exists,
327 strip_extension, 332 strip_extension,
333 crc_32,
328 334
329 /* dir */ 335 /* dir */
330 opendir, 336 opendir,
@@ -432,6 +438,7 @@ static const struct plugin_api rockbox_api = {
432 atoi, 438 atoi,
433 strchr, 439 strchr,
434 strcat, 440 strcat,
441 strlcat,
435 memchr, 442 memchr,
436 memcmp, 443 memcmp,
437 strcasestr, 444 strcasestr,
@@ -476,6 +483,7 @@ static const struct plugin_api rockbox_api = {
476 pcm_get_peak_buffer, 483 pcm_get_peak_buffer,
477 pcm_play_lock, 484 pcm_play_lock,
478 pcm_play_unlock, 485 pcm_play_unlock,
486 pcmbuf_beep,
479#ifdef HAVE_RECORDING 487#ifdef HAVE_RECORDING
480 &rec_freq_sampr[0], 488 &rec_freq_sampr[0],
481 pcm_init_recording, 489 pcm_init_recording,
@@ -588,6 +596,9 @@ static const struct plugin_api rockbox_api = {
588#endif 596#endif
589 597
590 /* misc */ 598 /* misc */
599#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
600 &errno,
601#endif
591 srand, 602 srand,
592 rand, 603 rand,
593 (qsort_func)qsort, 604 (qsort_func)qsort,
@@ -698,19 +709,6 @@ static const struct plugin_api rockbox_api = {
698 appsversion, 709 appsversion,
699 /* new stuff at the end, sort into place next time 710 /* new stuff at the end, sort into place next time
700 the API gets incompatible */ 711 the API gets incompatible */
701#if (CONFIG_CODEC == SWCODEC)
702 pcmbuf_beep,
703#endif
704 crc_32,
705 open_utf8,
706#ifdef HAVE_LCD_BITMAP
707 viewportmanager_theme_enable,
708 viewportmanager_theme_undo,
709#endif
710#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
711 &errno,
712#endif
713 strlcat,
714}; 712};
715 713
716int plugin_load(const char* plugin, const void* parameter) 714int plugin_load(const char* plugin, const void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index e5766c68b5..b1cfa30b87 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -135,12 +135,12 @@ void* plugin_get_buffer(size_t *buffer_size);
135#define PLUGIN_MAGIC 0x526F634B /* RocK */ 135#define PLUGIN_MAGIC 0x526F634B /* RocK */
136 136
137/* increase this every time the api struct changes */ 137/* increase this every time the api struct changes */
138#define PLUGIN_API_VERSION 180 138#define PLUGIN_API_VERSION 181
139 139
140/* update this to latest version if a change to the api struct breaks 140/* update this to latest version if a change to the api struct breaks
141 backwards compatibility (and please take the opportunity to sort in any 141 backwards compatibility (and please take the opportunity to sort in any
142 new function which are "waiting" at the end of the function table) */ 142 new function which are "waiting" at the end of the function table) */
143#define PLUGIN_MIN_API_VERSION 180 143#define PLUGIN_MIN_API_VERSION 181
144 144
145/* plugin return codes */ 145/* plugin return codes */
146enum plugin_status { 146enum plugin_status {
@@ -250,7 +250,7 @@ struct plugin_api {
250#endif 250#endif
251 unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation ); 251 unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );
252 const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code ); 252 const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code );
253 struct font* (*font_load)(const char *path); 253 int (*font_load)(struct font*, const char *path);
254 struct font* (*font_get)(int font); 254 struct font* (*font_get)(int font);
255 int (*font_getstringsize)(const unsigned char *str, int *w, int *h, 255 int (*font_getstringsize)(const unsigned char *str, int *w, int *h,
256 int fontnumber); 256 int fontnumber);
@@ -336,7 +336,12 @@ struct plugin_api {
336 int width, int height); 336 int width, int height);
337#endif 337#endif
338 void (*viewport_set_defaults)(struct viewport *vp, 338 void (*viewport_set_defaults)(struct viewport *vp,
339 const enum screen_type screen); 339 const enum screen_type screen);
340#ifdef HAVE_LCD_BITMAP
341 void (*viewportmanager_theme_enable)(enum screen_type screen, bool enable,
342 struct viewport *viewport);
343 void (*viewportmanager_theme_undo)(enum screen_type screen, bool force_redraw);
344#endif
340 /* list */ 345 /* list */
341 void (*gui_synclist_init)(struct gui_synclist * lists, 346 void (*gui_synclist_init)(struct gui_synclist * lists,
342 list_get_name callback_get_item_name, void * data, 347 list_get_name callback_get_item_name, void * data,
@@ -390,6 +395,7 @@ struct plugin_api {
390#endif /* HAVE_BUTTON_LIGHT */ 395#endif /* HAVE_BUTTON_LIGHT */
391 396
392 /* file */ 397 /* file */
398 int (*open_utf8)(const char* pathname, int flags);
393 int (*open)(const char* pathname, int flags); 399 int (*open)(const char* pathname, int flags);
394 int (*close)(int fd); 400 int (*close)(int fd);
395 ssize_t (*read)(int fd, void* buf, size_t count); 401 ssize_t (*read)(int fd, void* buf, size_t count);
@@ -416,6 +422,7 @@ struct plugin_api {
416 int numberlen IF_CNFN_NUM_(, int *num)); 422 int numberlen IF_CNFN_NUM_(, int *num));
417 bool (*file_exists)(const char *file); 423 bool (*file_exists)(const char *file);
418 char* (*strip_extension)(char* buffer, int buffer_size, const char *filename); 424 char* (*strip_extension)(char* buffer, int buffer_size, const char *filename);
425 unsigned (*crc_32)(const void *src, unsigned len, unsigned crc32);
419 426
420 427
421 /* dir */ 428 /* dir */
@@ -537,6 +544,7 @@ struct plugin_api {
537 int (*atoi)(const char *str); 544 int (*atoi)(const char *str);
538 char *(*strchr)(const char *s, int c); 545 char *(*strchr)(const char *s, int c);
539 char *(*strcat)(char *s1, const char *s2); 546 char *(*strcat)(char *s1, const char *s2);
547 size_t (*strlcat)(char *dst, const char *src, size_t length);
540 void *(*memchr)(const void *s1, int c, size_t n); 548 void *(*memchr)(const void *s1, int c, size_t n);
541 int (*memcmp)(const void *s1, const void *s2, size_t n); 549 int (*memcmp)(const void *s1, const void *s2, size_t n);
542 char *(*strcasestr) (const char* phaystack, const char* pneedle); 550 char *(*strcasestr) (const char* phaystack, const char* pneedle);
@@ -583,6 +591,9 @@ struct plugin_api {
583 const void* (*pcm_get_peak_buffer)(int *count); 591 const void* (*pcm_get_peak_buffer)(int *count);
584 void (*pcm_play_lock)(void); 592 void (*pcm_play_lock)(void);
585 void (*pcm_play_unlock)(void); 593 void (*pcm_play_unlock)(void);
594 void (*pcmbuf_beep)(unsigned int frequency,
595 size_t duration,
596 int amplitude);
586#ifdef HAVE_RECORDING 597#ifdef HAVE_RECORDING
587 const unsigned long *rec_freq_sampr; 598 const unsigned long *rec_freq_sampr;
588 void (*pcm_init_recording)(void); 599 void (*pcm_init_recording)(void);
@@ -716,6 +727,9 @@ struct plugin_api {
716#endif 727#endif
717 728
718 /* misc */ 729 /* misc */
730#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
731 int* __errno;
732#endif
719 void (*srand)(unsigned int seed); 733 void (*srand)(unsigned int seed);
720 int (*rand)(void); 734 int (*rand)(void);
721 void (*qsort)(void *base, size_t nmemb, size_t size, 735 void (*qsort)(void *base, size_t nmemb, size_t size,
@@ -848,23 +862,6 @@ struct plugin_api {
848 const char *appsversion; 862 const char *appsversion;
849 /* new stuff at the end, sort into place next time 863 /* new stuff at the end, sort into place next time
850 the API gets incompatible */ 864 the API gets incompatible */
851
852#if (CONFIG_CODEC == SWCODEC)
853 void (*pcmbuf_beep)(unsigned int frequency,
854 size_t duration,
855 int amplitude);
856#endif
857 unsigned (*crc_32)(const void *src, unsigned len, unsigned crc32);
858 int (*open_utf8)(const char* pathname, int flags);
859#ifdef HAVE_LCD_BITMAP
860 void (*viewportmanager_theme_enable)(enum screen_type screen, bool enable,
861 struct viewport *viewport);
862 void (*viewportmanager_theme_undo)(enum screen_type screen, bool force_redraw);
863#endif
864#if !defined(SIMULATOR) || defined(__MINGW32__) || defined(__CYGWIN__)
865 int* __errno;
866#endif
867 size_t (*strlcat)(char *dst, const char *src, size_t length);
868}; 865};
869 866
870/* plugin header */ 867/* plugin header */
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index 96de7abab1..ae28258e3b 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -854,7 +854,7 @@ static bool browse_fonts( char *dst, int dst_size )
854 continue; 854 continue;
855 rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s", 855 rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s",
856 de->d_name ); 856 de->d_name );
857 rb->font_load( bbuf ); 857 rb->font_load(NULL, bbuf );
858 rb->font_getstringsize( de->d_name, &fw, &fh, FONT_UI ); 858 rb->font_getstringsize( de->d_name, &fw, &fh, FONT_UI );
859 if( nvih > 0 ) 859 if( nvih > 0 )
860 { 860 {
@@ -887,12 +887,12 @@ static bool browse_fonts( char *dst, int dst_size )
887 { 887 {
888 rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s", 888 rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s",
889 de->d_name ); 889 de->d_name );
890 rb->font_load( bbuf ); 890 rb->font_load(NULL, bbuf );
891 rb->font_getstringsize( de->d_name, NULL, &fh, FONT_UI ); 891 rb->font_getstringsize( de->d_name, NULL, &fh, FONT_UI );
892 nvih = fh; 892 nvih = fh;
893 } 893 }
894 } 894 }
895 rb->font_load( buffer.text.old_font ); 895 rb->font_load(NULL, buffer.text.old_font );
896 rb->closedir( d ); 896 rb->closedir( d );
897 } 897 }
898 898
@@ -1526,7 +1526,7 @@ static void draw_text( int x, int y )
1526 case TEXT_MENU_FONT: 1526 case TEXT_MENU_FONT:
1527 if( browse_fonts( buffer.text.font, MAX_PATH ) ) 1527 if( browse_fonts( buffer.text.font, MAX_PATH ) )
1528 { 1528 {
1529 rb->font_load( buffer.text.font ); 1529 rb->font_load(NULL, buffer.text.font );
1530 } 1530 }
1531 break; 1531 break;
1532 1532
@@ -1583,7 +1583,7 @@ static void draw_text( int x, int y )
1583 case TEXT_MENU_CANCEL: 1583 case TEXT_MENU_CANCEL:
1584 default: 1584 default:
1585 restore_screen(); 1585 restore_screen();
1586 rb->font_load( buffer.text.old_font ); 1586 rb->font_load(NULL, buffer.text.old_font );
1587 return; 1587 return;
1588 } 1588 }
1589 } 1589 }
diff --git a/apps/settings.c b/apps/settings.c
index becb516a81..574aa27159 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -68,6 +68,7 @@
68#endif 68#endif
69#include "wps.h" 69#include "wps.h"
70#include "skin_engine/skin_engine.h" 70#include "skin_engine/skin_engine.h"
71#include "skin_engine/skin_fonts.h"
71#include "viewport.h" 72#include "viewport.h"
72#include "statusbar-skinned.h" 73#include "statusbar-skinned.h"
73 74
@@ -740,6 +741,7 @@ void settings_apply_skins(void)
740 /* re-initialize the skin buffer before we start reloading skins */ 741 /* re-initialize the skin buffer before we start reloading skins */
741 skin_buffer_init(); 742 skin_buffer_init();
742#ifdef HAVE_LCD_BITMAP 743#ifdef HAVE_LCD_BITMAP
744 skin_font_init();
743 if ( global_settings.sbs_file[0] && 745 if ( global_settings.sbs_file[0] &&
744 global_settings.sbs_file[0] != 0xff ) 746 global_settings.sbs_file[0] != 0xff )
745 { 747 {
@@ -887,18 +889,26 @@ void settings_apply(bool read_disk)
887 889
888 if (read_disk) 890 if (read_disk)
889 { 891 {
890
891#ifdef HAVE_LCD_BITMAP 892#ifdef HAVE_LCD_BITMAP
892 /* fonts need to be loaded before the WPS */ 893 /* fonts need to be loaded before the WPS */
893 if ( global_settings.font_file[0]) { 894 if ( global_settings.font_file[0]) {
894 snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", 895 snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
895 global_settings.font_file); 896 global_settings.font_file);
896 if (font_load(buf) == NULL) 897 if (font_load(NULL, buf) < 0)
897 font_reset(); 898 font_reset(NULL);
898 } 899 }
899 else 900 else
900 font_reset(); 901 font_reset(NULL);
901 902#ifdef HAVE_REMOTE_LCD
903 if ( global_settings.remote_font_file[0]) {
904 snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
905 global_settings.remote_font_file);
906 if (font_load_remoteui(buf) < 0)
907 font_load_remoteui(NULL);
908 }
909 else
910 font_load_remoteui(NULL);
911#endif
902 if ( global_settings.kbd_file[0]) { 912 if ( global_settings.kbd_file[0]) {
903 snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd", 913 snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd",
904 global_settings.kbd_file); 914 global_settings.kbd_file);
diff --git a/apps/settings.h b/apps/settings.h
index ea7138c8b0..6a42ca3c0c 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -681,6 +681,9 @@ struct user_settings
681 unsigned char icon_file[MAX_FILENAME+1]; 681 unsigned char icon_file[MAX_FILENAME+1];
682 unsigned char viewers_icon_file[MAX_FILENAME+1]; 682 unsigned char viewers_icon_file[MAX_FILENAME+1];
683 unsigned char font_file[MAX_FILENAME+1]; /* last font */ 683 unsigned char font_file[MAX_FILENAME+1]; /* last font */
684#ifdef HAVE_REMOTE_LCD
685 unsigned char remote_font_file[MAX_FILENAME+1]; /* last font */
686#endif
684 unsigned char kbd_file[MAX_FILENAME+1]; /* last keyboard */ 687 unsigned char kbd_file[MAX_FILENAME+1]; /* last keyboard */
685#endif /* HAVE_LCD_BITMAP */ 688#endif /* HAVE_LCD_BITMAP */
686 689
diff --git a/apps/settings_list.c b/apps/settings_list.c
index c5f9932125..d2700b39c4 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -1432,6 +1432,10 @@ const struct settings_list settings[] = {
1432 TEXT_SETTING(F_THEMESETTING, font_file, "font", 1432 TEXT_SETTING(F_THEMESETTING, font_file, "font",
1433 DEFAULT_FONTNAME, FONT_DIR "/", ".fnt"), 1433 DEFAULT_FONTNAME, FONT_DIR "/", ".fnt"),
1434#endif 1434#endif
1435#ifdef HAVE_REMOTE_LCD
1436 TEXT_SETTING(F_THEMESETTING, remote_font_file, "remote font",
1437 "", FONT_DIR "/", ".fnt"),
1438#endif
1435 TEXT_SETTING(F_THEMESETTING,wps_file, "wps", 1439 TEXT_SETTING(F_THEMESETTING,wps_file, "wps",
1436 DEFAULT_WPSNAME, WPS_DIR "/", ".wps"), 1440 DEFAULT_WPSNAME, WPS_DIR "/", ".wps"),
1437#ifdef HAVE_LCD_BITMAP 1441#ifdef HAVE_LCD_BITMAP
diff --git a/firmware/export/font.h b/firmware/export/font.h
index 0fe6c30f2c..e9bf086423 100644
--- a/firmware/export/font.h
+++ b/firmware/export/font.h
@@ -30,6 +30,7 @@
30 30
31#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) 31#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
32#ifndef __PCTOOL__ 32#ifndef __PCTOOL__
33#include "font_cache.h"
33#include "sysfont.h" 34#include "sysfont.h"
34#endif 35#endif
35 36
@@ -47,9 +48,14 @@
47enum { 48enum {
48 FONT_SYSFIXED, /* system fixed pitch font*/ 49 FONT_SYSFIXED, /* system fixed pitch font*/
49 FONT_UI, /* system porportional font*/ 50 FONT_UI, /* system porportional font*/
50 MAXFONTS 51#ifdef HAVE_REMOTE_LCD
52 FONT_UI_REMOTE, /* UI font for remote LCD */
53#endif
54 SYSTEMFONTCOUNT /* Number of fonts reserved for the system and ui */
51}; 55};
52 56
57#define MAXFONTS 10
58
53/* 59/*
54 * .fnt loadable font file format definition 60 * .fnt loadable font file format definition
55 * 61 *
@@ -89,17 +95,38 @@ struct font {
89 const unsigned char *width; /* character widths or NULL if fixed*/ 95 const unsigned char *width; /* character widths or NULL if fixed*/
90 int defaultchar; /* default char (not glyph index)*/ 96 int defaultchar; /* default char (not glyph index)*/
91 int32_t bits_size; /* # bytes of glyph bits*/ 97 int32_t bits_size; /* # bytes of glyph bits*/
98
99 /* file, buffer and cache management */
100 int fd; /* fd for the font file. >= 0 if cached */
101 unsigned char *buffer_start; /* buffer to store the font in */
102 unsigned char *buffer_position; /* position in the buffer */
103 unsigned char *buffer_end; /* end of the buffer */
104 int buffer_size; /* size of the buffer in bytes */
105#ifndef __PCTOOL__
106 struct font_cache cache;
107 uint32_t file_width_offset; /* offset to file width data */
108 uint32_t file_offset_offset; /* offset to file offset data */
109 int long_offset;
110#endif
111
92}; 112};
93 113
94/* font routines*/ 114/* font routines*/
95void font_init(void); 115void font_init(void);
96struct font* font_load(const char *path); 116#ifdef HAVE_REMOTE_LCD
117/* Load a font into the special remote ui font slot */
118int font_load_remoteui(const char* path);
119#endif
120int font_load(struct font* pf, const char *path);
121void font_unload(int font_id);
122
97struct font* font_get(int font); 123struct font* font_get(int font);
98void font_reset(void); 124
125void font_reset(struct font *pf);
99int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber); 126int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber);
100int font_get_width(struct font* ft, unsigned short ch); 127int font_get_width(struct font* ft, unsigned short ch);
101const unsigned char * font_get_bits(struct font* ft, unsigned short ch); 128const unsigned char * font_get_bits(struct font* ft, unsigned short ch);
102void glyph_cache_save(void); 129void glyph_cache_save(struct font* pf);
103 130
104#else /* HAVE_LCD_BITMAP */ 131#else /* HAVE_LCD_BITMAP */
105 132
diff --git a/firmware/font.c b/firmware/font.c
index a8734e93a1..52c6ffae6a 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -75,64 +75,77 @@ extern struct font sysfont;
75 75
76/* structure filled in by font_load */ 76/* structure filled in by font_load */
77static struct font font_ui; 77static struct font font_ui;
78/* static buffer allocation structures */
79static unsigned char main_buf[MAX_FONT_SIZE];
80#ifdef HAVE_REMOTE_LCD
81#define REMOTE_FONT_SIZE 10000
82static struct font remote_font_ui;
83static unsigned char remote_buf[REMOTE_FONT_SIZE];
84#endif
78 85
79/* system font table, in order of FONT_xxx definition */ 86/* system font table, in order of FONT_xxx definition */
80static struct font* const sysfonts[MAXFONTS] = { &sysfont, &font_ui }; 87static struct font* sysfonts[MAXFONTS] = { &sysfont, &font_ui, NULL};
81 88
82/* static buffer allocation structures */
83static unsigned char mbuf[MAX_FONT_SIZE];
84static unsigned char *freeptr = mbuf;
85static unsigned char *fileptr;
86static unsigned char *eofptr;
87 89
88/* Font cache structures */ 90/* Font cache structures */
89static struct font_cache font_cache_ui; 91static void cache_create(struct font* pf, int maxwidth, int height);
90static int fnt_file = -1; /* >=0 if font is cached */ 92static void glyph_cache_load(struct font* pf);
91static uint32_t file_width_offset; /* offset to file width data */
92static uint32_t file_offset_offset; /* offset to file offset data */
93static void cache_create(int maxwidth, int height);
94static int long_offset = 0;
95static int glyph_file;
96/* End Font cache structures */ 93/* End Font cache structures */
97 94
98static void glyph_cache_load(void);
99
100void font_init(void) 95void font_init(void)
101{ 96{
102 memset(&font_ui, 0, sizeof(struct font)); 97 int i = SYSTEMFONTCOUNT;
98 while (i<MAXFONTS)
99 sysfonts[i++] = NULL;
100 font_reset(NULL);
103} 101}
104 102
105/* Check if we have x bytes left in the file buffer */ 103/* Check if we have x bytes left in the file buffer */
106#define HAVEBYTES(x) (fileptr + (x) <= eofptr) 104#define HAVEBYTES(x) (pf->buffer_position + (x) <= pf->buffer_end)
107 105
108/* Helper functions to read big-endian unaligned short or long from 106/* Helper functions to read big-endian unaligned short or long from
109 the file buffer. Bounds-checking must be done in the calling 107 the file buffer. Bounds-checking must be done in the calling
110 function. 108 function.
111 */ 109 */
112 110
113static short readshort(void) 111static short readshort(struct font *pf)
114{ 112{
115 unsigned short s; 113 unsigned short s;
116 114
117 s = *fileptr++ & 0xff; 115 s = *pf->buffer_position++ & 0xff;
118 s |= (*fileptr++ << 8); 116 s |= (*pf->buffer_position++ << 8);
119 return s; 117 return s;
120} 118}
121 119
122static int32_t readlong(void) 120static int32_t readlong(struct font *pf)
123{ 121{
124 uint32_t l; 122 uint32_t l;
125 123
126 l = *fileptr++ & 0xff; 124 l = *pf->buffer_position++ & 0xff;
127 l |= *fileptr++ << 8; 125 l |= *pf->buffer_position++ << 8;
128 l |= ((uint32_t)(*fileptr++)) << 16; 126 l |= ((uint32_t)(*pf->buffer_position++)) << 16;
129 l |= ((uint32_t)(*fileptr++)) << 24; 127 l |= ((uint32_t)(*pf->buffer_position++)) << 24;
130 return l; 128 return l;
131} 129}
132 130
133void font_reset(void) 131void font_reset(struct font *pf)
134{ 132{
135 memset(&font_ui, 0, sizeof(struct font)); 133 unsigned char* buffer = NULL;
134 size_t buf_size = 0;
135 if (pf == NULL)
136 pf = &font_ui;
137 else
138 {
139 buffer = pf->buffer_start;
140 buf_size = pf->buffer_size;
141 }
142 memset(pf, 0, sizeof(struct font));
143 pf->fd = -1;
144 if (buffer)
145 {
146 pf->buffer_start = buffer;
147 pf->buffer_size = buf_size;
148 }
136} 149}
137 150
138static struct font* font_load_header(struct font *pf) 151static struct font* font_load_header(struct font *pf)
@@ -142,23 +155,23 @@ static struct font* font_load_header(struct font *pf)
142 return NULL; 155 return NULL;
143 156
144 /* read magic and version #*/ 157 /* read magic and version #*/
145 if (memcmp(fileptr, VERSION, 4) != 0) 158 if (memcmp(pf->buffer_position, VERSION, 4) != 0)
146 return NULL; 159 return NULL;
147 160
148 fileptr += 4; 161 pf->buffer_position += 4;
149 162
150 /* font info*/ 163 /* font info*/
151 pf->maxwidth = readshort(); 164 pf->maxwidth = readshort(pf);
152 pf->height = readshort(); 165 pf->height = readshort(pf);
153 pf->ascent = readshort(); 166 pf->ascent = readshort(pf);
154 fileptr += 2; /* Skip padding */ 167 pf->buffer_position += 2; /* Skip padding */
155 pf->firstchar = readlong(); 168 pf->firstchar = readlong(pf);
156 pf->defaultchar = readlong(); 169 pf->defaultchar = readlong(pf);
157 pf->size = readlong(); 170 pf->size = readlong(pf);
158 171
159 /* get variable font data sizes*/ 172 /* get variable font data sizes*/
160 /* # words of bitmap_t*/ 173 /* # words of bitmap_t*/
161 pf->bits_size = readlong(); 174 pf->bits_size = readlong(pf);
162 175
163 return pf; 176 return pf;
164} 177}
@@ -171,32 +184,32 @@ static struct font* font_load_in_memory(struct font* pf)
171 return NULL; 184 return NULL;
172 185
173 /* # longs of offset*/ 186 /* # longs of offset*/
174 noffset = readlong(); 187 noffset = readlong(pf);
175 188
176 /* # bytes of width*/ 189 /* # bytes of width*/
177 nwidth = readlong(); 190 nwidth = readlong(pf);
178 191
179 /* variable font data*/ 192 /* variable font data*/
180 pf->bits = (unsigned char *)fileptr; 193 pf->bits = (unsigned char *)pf->buffer_position;
181 fileptr += pf->bits_size*sizeof(unsigned char); 194 pf->buffer_position += pf->bits_size*sizeof(unsigned char);
182 195
183 if (pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS) 196 if (pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS)
184 { 197 {
185 /* pad to 16-bit boundary */ 198 /* pad to 16-bit boundary */
186 fileptr = (unsigned char *)(((intptr_t)fileptr + 1) & ~1); 199 pf->buffer_position = (unsigned char *)(((intptr_t)pf->buffer_position + 1) & ~1);
187 } 200 }
188 else 201 else
189 { 202 {
190 /* pad to 32-bit boundary*/ 203 /* pad to 32-bit boundary*/
191 fileptr = (unsigned char *)(((intptr_t)fileptr + 3) & ~3); 204 pf->buffer_position = (unsigned char *)(((intptr_t)pf->buffer_position + 3) & ~3);
192 } 205 }
193 206
194 if (noffset) 207 if (noffset)
195 { 208 {
196 if (pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS) 209 if (pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS)
197 { 210 {
198 long_offset = 0; 211 pf->long_offset = 0;
199 pf->offset = (uint16_t*)fileptr; 212 pf->offset = (uint16_t*)pf->buffer_position;
200 213
201 /* Check we have sufficient buffer */ 214 /* Check we have sufficient buffer */
202 if (!HAVEBYTES(noffset * sizeof(uint16_t))) 215 if (!HAVEBYTES(noffset * sizeof(uint16_t)))
@@ -204,13 +217,13 @@ static struct font* font_load_in_memory(struct font* pf)
204 217
205 for (i=0; i<noffset; ++i) 218 for (i=0; i<noffset; ++i)
206 { 219 {
207 ((uint16_t*)(pf->offset))[i] = (uint16_t)readshort(); 220 ((uint16_t*)(pf->offset))[i] = (uint16_t)readshort(pf);
208 } 221 }
209 } 222 }
210 else 223 else
211 { 224 {
212 long_offset = 1; 225 pf->long_offset = 1;
213 pf->offset = (uint16_t*)fileptr; 226 pf->offset = (uint16_t*)pf->buffer_position;
214 227
215 /* Check we have sufficient buffer */ 228 /* Check we have sufficient buffer */
216 if (!HAVEBYTES(noffset * sizeof(int32_t))) 229 if (!HAVEBYTES(noffset * sizeof(int32_t)))
@@ -218,7 +231,7 @@ static struct font* font_load_in_memory(struct font* pf)
218 231
219 for (i=0; i<noffset; ++i) 232 for (i=0; i<noffset; ++i)
220 { 233 {
221 ((uint32_t*)(pf->offset))[i] = (uint32_t)readlong(); 234 ((uint32_t*)(pf->offset))[i] = (uint32_t)readlong(pf);
222 } 235 }
223 } 236 }
224 } 237 }
@@ -226,13 +239,13 @@ static struct font* font_load_in_memory(struct font* pf)
226 pf->offset = NULL; 239 pf->offset = NULL;
227 240
228 if (nwidth) { 241 if (nwidth) {
229 pf->width = (unsigned char *)fileptr; 242 pf->width = (unsigned char *)pf->buffer_position;
230 fileptr += nwidth*sizeof(unsigned char); 243 pf->buffer_position += nwidth*sizeof(unsigned char);
231 } 244 }
232 else 245 else
233 pf->width = NULL; 246 pf->width = NULL;
234 247
235 if (fileptr > eofptr) 248 if (pf->buffer_position > pf->buffer_end)
236 return NULL; 249 return NULL;
237 250
238 return pf; /* success!*/ 251 return pf; /* success!*/
@@ -242,135 +255,203 @@ static struct font* font_load_in_memory(struct font* pf)
242static struct font* font_load_cached(struct font* pf) 255static struct font* font_load_cached(struct font* pf)
243{ 256{
244 uint32_t noffset, nwidth; 257 uint32_t noffset, nwidth;
245 unsigned char* oldfileptr = fileptr; 258 unsigned char* oldfileptr = pf->buffer_position;
246 259
247 if (!HAVEBYTES(2 * sizeof(int32_t))) 260 if (!HAVEBYTES(2 * sizeof(int32_t)))
248 return NULL; 261 return NULL;
249 262
250 /* # longs of offset*/ 263 /* # longs of offset*/
251 noffset = readlong(); 264 noffset = readlong(pf);
252 265
253 /* # bytes of width*/ 266 /* # bytes of width*/
254 nwidth = readlong(); 267 nwidth = readlong(pf);
255 268
256 /* We are now at the bitmap data, this is fixed at 36.. */ 269 /* We are now at the bitmap data, this is fixed at 36.. */
257 pf->bits = NULL; 270 pf->bits = NULL;
258 271
259 /* Calculate offset to offset data */ 272 /* Calculate offset to offset data */
260 fileptr += pf->bits_size * sizeof(unsigned char); 273 pf->buffer_position += pf->bits_size * sizeof(unsigned char);
261 274
262 if (pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS) 275 if (pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS)
263 { 276 {
264 long_offset = 0; 277 pf->long_offset = 0;
265 /* pad to 16-bit boundary */ 278 /* pad to 16-bit boundary */
266 fileptr = (unsigned char *)(((intptr_t)fileptr + 1) & ~1); 279 pf->buffer_position = (unsigned char *)(((intptr_t)pf->buffer_position + 1) & ~1);
267 } 280 }
268 else 281 else
269 { 282 {
270 long_offset = 1; 283 pf->long_offset = 1;
271 /* pad to 32-bit boundary*/ 284 /* pad to 32-bit boundary*/
272 fileptr = (unsigned char *)(((intptr_t)fileptr + 3) & ~3); 285 pf->buffer_position = (unsigned char *)(((intptr_t)pf->buffer_position + 3) & ~3);
273 } 286 }
274 287
275 if (noffset) 288 if (noffset)
276 file_offset_offset = (uint32_t)(fileptr - freeptr); 289 pf->file_offset_offset = (uint32_t)(pf->buffer_position - pf->buffer_start);
277 else 290 else
278 file_offset_offset = 0; 291 pf->file_offset_offset = 0;
279 292
280 /* Calculate offset to widths data */ 293 /* Calculate offset to widths data */
281 if (pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS) 294 if (pf->bits_size < MAX_FONTSIZE_FOR_16_BIT_OFFSETS)
282 fileptr += noffset * sizeof(uint16_t); 295 pf->buffer_position += noffset * sizeof(uint16_t);
283 else 296 else
284 fileptr += noffset * sizeof(uint32_t); 297 pf->buffer_position += noffset * sizeof(uint32_t);
285 298
286 if (nwidth) 299 if (nwidth)
287 file_width_offset = (uint32_t)(fileptr - freeptr); 300 pf->file_width_offset = (uint32_t)(pf->buffer_position - pf->buffer_start);
288 else 301 else
289 file_width_offset = 0; 302 pf->file_width_offset = 0;
290 303
291 fileptr = oldfileptr; 304 pf->buffer_position = oldfileptr;
292 305
293 /* Create the cache */ 306 /* Create the cache */
294 cache_create(pf->maxwidth, pf->height); 307 cache_create(pf, pf->maxwidth, pf->height);
295 308
296 return pf; 309 return pf;
297} 310}
298 311
299/* read and load font into incore font structure*/ 312static bool internal_load_font(struct font* pf, const char *path,
300struct font* font_load(const char *path) 313 char *buf, size_t buf_size)
301{ 314{
302 int size; 315 int size;
303 struct font* pf = &font_ui; 316
304
305 /* save loaded glyphs */ 317 /* save loaded glyphs */
306 glyph_cache_save(); 318 glyph_cache_save(pf);
307
308 /* Close font file handle */ 319 /* Close font file handle */
309 if (fnt_file >= 0) 320 if (pf->fd >= 0)
310 close(fnt_file); 321 close(pf->fd);
322
323 font_reset(pf);
311 324
312 /* open and read entire font file*/ 325 /* open and read entire font file*/
313 fnt_file = open(path, O_RDONLY|O_BINARY); 326 pf->fd = open(path, O_RDONLY|O_BINARY);
314 327
315 if (fnt_file < 0) { 328 if (pf->fd < 0) {
316 DEBUGF("Can't open font: %s\n", path); 329 DEBUGF("Can't open font: %s\n", path);
317 return NULL; 330 return false;
318 } 331 }
319 332
320 /* Check file size */ 333 /* Check file size */
321 size = filesize(fnt_file); 334 size = filesize(pf->fd);
322 335 pf->buffer_start = buf;
323 font_reset(); 336 pf->buffer_size = buf_size;
324 337
325 /* currently, font loading replaces earlier font allocation*/ 338 pf->buffer_position = buf;
326 freeptr = (unsigned char *)(((intptr_t)mbuf + 3) & ~3); 339
327 fileptr = freeptr; 340 if (size > pf->buffer_size)
328
329
330 if (size > MAX_FONT_SIZE)
331 { 341 {
332 read(fnt_file, fileptr, FONT_HEADER_SIZE); 342 read(pf->fd, pf->buffer_position, FONT_HEADER_SIZE);
333 eofptr = fileptr + FONT_HEADER_SIZE; 343 pf->buffer_end = pf->buffer_position + FONT_HEADER_SIZE;
334 344
335 if (!font_load_header(pf)) 345 if (!font_load_header(pf))
336 { 346 {
337 DEBUGF("Failed font header load"); 347 DEBUGF("Failed font header load");
338 return NULL; 348 return false;
339 } 349 }
340 350
341 if (!font_load_cached(pf)) 351 if (!font_load_cached(pf))
342 { 352 {
343 DEBUGF("Failed font cache load"); 353 DEBUGF("Failed font cache load");
344 return NULL; 354 return false;
345 } 355 }
346 356
347 glyph_cache_load(); 357 glyph_cache_load(pf);
348 } 358 }
349 else 359 else
350 { 360 {
351 read(fnt_file, fileptr, MAX_FONT_SIZE); 361 read(pf->fd, pf->buffer_position, pf->buffer_size);
352 eofptr = fileptr + size; 362 pf->buffer_end = pf->buffer_position + size;
353 close(fnt_file); 363 close(pf->fd);
354 fnt_file = -1; 364 pf->fd = -1;
355 365
356 if (!font_load_header(pf)) 366 if (!font_load_header(pf))
357 { 367 {
358 DEBUGF("Failed font header load"); 368 DEBUGF("Failed font header load");
359 return NULL; 369 return false;
360 } 370 }
361 371
362 if (!font_load_in_memory(pf)) 372 if (!font_load_in_memory(pf))
363 { 373 {
364 DEBUGF("Failed mem load"); 374 DEBUGF("Failed mem load");
365 return NULL; 375 return false;
366 } 376 }
367 } 377 }
378 return true;
379}
380
381#ifdef HAVE_REMOTE_LCD
382/* Load a font into the special remote ui font slot */
383int font_load_remoteui(const char* path)
384{
385 struct font* pf = &remote_font_ui;
386 if (!path)
387 {
388 if (sysfonts[FONT_UI_REMOTE] && sysfonts[FONT_UI_REMOTE] != sysfonts[FONT_UI])
389 font_unload(FONT_UI_REMOTE);
390 sysfonts[FONT_UI_REMOTE] = NULL;
391 return FONT_UI;
392 }
393 if (!internal_load_font(pf, path, remote_buf, REMOTE_FONT_SIZE))
394 {
395 sysfonts[FONT_UI_REMOTE] = NULL;
396 return -1;
397 }
398
399 sysfonts[FONT_UI_REMOTE] = pf;
400 return FONT_UI_REMOTE;
401}
402#endif
368 403
369 /* no need for multiple font loads currently*/ 404/* read and load font into incore font structure,
370 /*freeptr += filesize;*/ 405 * returns the font number on success, -1 on failure */
371 /*freeptr = (unsigned char *)(freeptr + 3) & ~3;*/ /* pad freeptr*/ 406int font_load(struct font* pf, const char *path)
407{
408 int font_id = -1;
409 char *buffer;
410 size_t buffer_size;
411 if (pf == NULL)
412 {
413 pf = &font_ui;
414 font_id = FONT_UI;
415 }
416 else
417 {
418 for (font_id = SYSTEMFONTCOUNT; font_id < MAXFONTS; font_id++)
419 {
420 if (sysfonts[font_id] == NULL)
421 break;
422 }
423 if (font_id == MAXFONTS)
424 return -1; /* too many fonts */
425 }
426
427 if (font_id == FONT_UI)
428 {
429 /* currently, font loading replaces earlier font allocation*/
430 buffer = (unsigned char *)(((intptr_t)main_buf + 3) & ~3);
431 buffer_size = MAX_FONT_SIZE;
432 }
433 else
434 {
435 buffer = pf->buffer_start;
436 buffer_size = pf->buffer_size;
437 }
438
439 if (!internal_load_font(pf, path, buffer, buffer_size))
440 return -1;
441
442 sysfonts[font_id] = pf;
443 return font_id; /* success!*/
444}
372 445
373 return pf; /* success!*/ 446void font_unload(int font_id)
447{
448 struct font* pf = sysfonts[font_id];
449 if (font_id >= SYSTEMFONTCOUNT && pf)
450 {
451 if (pf->fd >= 0)
452 close(pf->fd);
453 sysfonts[font_id] = NULL;
454 }
374} 455}
375 456
376/* 457/*
@@ -382,9 +463,6 @@ struct font* font_get(int font)
382{ 463{
383 struct font* pf; 464 struct font* pf;
384 465
385 if (font >= MAXFONTS)
386 font = 0;
387
388 while (1) { 466 while (1) {
389 pf = sysfonts[font]; 467 pf = sysfonts[font];
390 if (pf && pf->height) 468 if (pf && pf->height)
@@ -404,11 +482,11 @@ load_cache_entry(struct font_cache_entry* p, void* callback_data)
404 unsigned short char_code = p->_char_code; 482 unsigned short char_code = p->_char_code;
405 unsigned char tmp[2]; 483 unsigned char tmp[2];
406 484
407 if (file_width_offset) 485 if (pf->file_width_offset)
408 { 486 {
409 int width_offset = file_width_offset + char_code; 487 int width_offset = pf->file_width_offset + char_code;
410 lseek(fnt_file, width_offset, SEEK_SET); 488 lseek(pf->fd, width_offset, SEEK_SET);
411 read(fnt_file, &(p->width), 1); 489 read(pf->fd, &(p->width), 1);
412 } 490 }
413 else 491 else
414 { 492 {
@@ -417,14 +495,14 @@ load_cache_entry(struct font_cache_entry* p, void* callback_data)
417 495
418 int32_t bitmap_offset = 0; 496 int32_t bitmap_offset = 0;
419 497
420 if (file_offset_offset) 498 if (pf->file_offset_offset)
421 { 499 {
422 int32_t offset = file_offset_offset + char_code * (long_offset ? sizeof(int32_t) : sizeof(int16_t)); 500 int32_t offset = pf->file_offset_offset + char_code * (pf->long_offset ? sizeof(int32_t) : sizeof(int16_t));
423 lseek(fnt_file, offset, SEEK_SET); 501 lseek(pf->fd, offset, SEEK_SET);
424 read (fnt_file, tmp, 2); 502 read (pf->fd, tmp, 2);
425 bitmap_offset = tmp[0] | (tmp[1] << 8); 503 bitmap_offset = tmp[0] | (tmp[1] << 8);
426 if (long_offset) { 504 if (pf->long_offset) {
427 read (fnt_file, tmp, 2); 505 read (pf->fd, tmp, 2);
428 bitmap_offset |= (tmp[0] << 16) | (tmp[1] << 24); 506 bitmap_offset |= (tmp[0] << 16) | (tmp[1] << 24);
429 } 507 }
430 } 508 }
@@ -434,22 +512,22 @@ load_cache_entry(struct font_cache_entry* p, void* callback_data)
434 } 512 }
435 513
436 int32_t file_offset = FONT_HEADER_SIZE + bitmap_offset; 514 int32_t file_offset = FONT_HEADER_SIZE + bitmap_offset;
437 lseek(fnt_file, file_offset, SEEK_SET); 515 lseek(pf->fd, file_offset, SEEK_SET);
438 516
439 int src_bytes = p->width * ((pf->height + 7) / 8); 517 int src_bytes = p->width * ((pf->height + 7) / 8);
440 read(fnt_file, p->bitmap, src_bytes); 518 read(pf->fd, p->bitmap, src_bytes);
441} 519}
442 520
443/* 521/*
444 * Converts cbuf into a font cache 522 * Converts cbuf into a font cache
445 */ 523 */
446static void cache_create(int maxwidth, int height) 524static void cache_create(struct font* pf, int maxwidth, int height)
447{ 525{
448 /* maximum size of rotated bitmap */ 526 /* maximum size of rotated bitmap */
449 int bitmap_size = maxwidth * ((height + 7) / 8); 527 int bitmap_size = maxwidth * ((height + 7) / 8);
450 528
451 /* Initialise cache */ 529 /* Initialise cache */
452 font_cache_create(&font_cache_ui, mbuf, MAX_FONT_SIZE, bitmap_size); 530 font_cache_create(&pf->cache, pf->buffer_start, pf->buffer_size, bitmap_size);
453} 531}
454 532
455/* 533/*
@@ -462,8 +540,8 @@ int font_get_width(struct font* pf, unsigned short char_code)
462 char_code = pf->defaultchar; 540 char_code = pf->defaultchar;
463 char_code -= pf->firstchar; 541 char_code -= pf->firstchar;
464 542
465 return (fnt_file >= 0 && pf != &sysfont)? 543 return (pf->fd >= 0 && pf != &sysfont)?
466 font_cache_get(&font_cache_ui,char_code,load_cache_entry,pf)->width: 544 font_cache_get(&pf->cache,char_code,load_cache_entry,pf)->width:
467 pf->width? pf->width[char_code]: pf->maxwidth; 545 pf->width? pf->width[char_code]: pf->maxwidth;
468} 546}
469 547
@@ -476,10 +554,10 @@ const unsigned char* font_get_bits(struct font* pf, unsigned short char_code)
476 char_code = pf->defaultchar; 554 char_code = pf->defaultchar;
477 char_code -= pf->firstchar; 555 char_code -= pf->firstchar;
478 556
479 if (fnt_file >= 0 && pf != &sysfont) 557 if (pf->fd >= 0 && pf != &sysfont)
480 { 558 {
481 bits = 559 bits =
482 (unsigned char*)font_cache_get(&font_cache_ui,char_code,load_cache_entry,pf)->bitmap; 560 (unsigned char*)font_cache_get(&pf->cache,char_code,load_cache_entry,pf)->bitmap;
483 } 561 }
484 else 562 else
485 { 563 {
@@ -497,7 +575,7 @@ const unsigned char* font_get_bits(struct font* pf, unsigned short char_code)
497 575
498 return bits; 576 return bits;
499} 577}
500 578static int cache_fd;
501static void glyph_file_write(void* data) 579static void glyph_file_write(void* data)
502{ 580{
503 struct font_cache_entry* p = data; 581 struct font_cache_entry* p = data;
@@ -507,45 +585,48 @@ static void glyph_file_write(void* data)
507 585
508 ch = p->_char_code + pf->firstchar; 586 ch = p->_char_code + pf->firstchar;
509 587
510 if (ch != 0xffff && glyph_file >= 0) { 588 if (ch != 0xffff && cache_fd >= 0) {
511 tmp[0] = ch >> 8; 589 tmp[0] = ch >> 8;
512 tmp[1] = ch & 0xff; 590 tmp[1] = ch & 0xff;
513 if (write(glyph_file, tmp, 2) != 2) { 591 if (write(cache_fd, tmp, 2) != 2) {
514 close(glyph_file); 592 close(cache_fd);
515 glyph_file = -1; 593 cache_fd = -1;
516 } 594 }
517 } 595 }
518 return; 596 return;
519} 597}
520 598
521/* save the char codes of the loaded glyphs to a file */ 599/* save the char codes of the loaded glyphs to a file */
522void glyph_cache_save(void) 600void glyph_cache_save(struct font* pf)
523{ 601{
524 602 if (!pf)
525 if (fnt_file >= 0) { 603 pf = &font_ui;
604 if (pf->fd >= 0 && pf == &font_ui)
605 {
526#ifdef WPSEDITOR 606#ifdef WPSEDITOR
527 glyph_file = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC); 607 cache_fd = open(GLYPH_CACHE_FILE, O_WRONLY|O_CREAT|O_TRUNC);
528#else 608#else
529 glyph_file = creat(GLYPH_CACHE_FILE); 609 cache_fd = creat(GLYPH_CACHE_FILE);
530#endif 610#endif
531 if (glyph_file < 0) return; 611 if (cache_fd < 0) return;
532 612
533 lru_traverse(&font_cache_ui._lru, glyph_file_write); 613 lru_traverse(&pf->cache._lru, glyph_file_write);
534 614
535 if (glyph_file >= 0) 615 if (cache_fd < 0)
536 close(glyph_file); 616 {
617 close(cache_fd);
618 cache_fd = -1;
619 }
537 } 620 }
538 return; 621 return;
539} 622}
540 623
541static void glyph_cache_load(void) 624static void glyph_cache_load(struct font* pf)
542{ 625{
543 if (fnt_file >= 0) { 626 if (pf->fd >= 0) {
544
545 int fd; 627 int fd;
546 unsigned char tmp[2]; 628 unsigned char tmp[2];
547 unsigned short ch; 629 unsigned short ch;
548 struct font* pf = &font_ui;
549 630
550 fd = open(GLYPH_CACHE_FILE, O_RDONLY|O_BINARY); 631 fd = open(GLYPH_CACHE_FILE, O_RDONLY|O_BINARY);
551 632
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 5f488810ac..3f2b3c0f85 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -744,7 +744,7 @@ void shutdown_hw(void)
744 744
745 if (battery_level_safe()) { /* do not save on critical battery */ 745 if (battery_level_safe()) { /* do not save on critical battery */
746#ifdef HAVE_LCD_BITMAP 746#ifdef HAVE_LCD_BITMAP
747 glyph_cache_save(); 747 glyph_cache_save(NULL);
748#endif 748#endif
749 749
750/* Commit pending writes if needed. Even though we don't do write caching, 750/* Commit pending writes if needed. Even though we don't do write caching,
diff --git a/tools/checkwps/SOURCES b/tools/checkwps/SOURCES
index 06ef3b9ee5..6223b97178 100644
--- a/tools/checkwps/SOURCES
+++ b/tools/checkwps/SOURCES
@@ -1,6 +1,9 @@
1../../apps/gui/skin_engine/wps_debug.c 1../../apps/gui/skin_engine/wps_debug.c
2../../apps/gui/skin_engine/skin_parser.c 2../../apps/gui/skin_engine/skin_parser.c
3../../apps/gui/skin_engine/skin_buffer.c 3../../apps/gui/skin_engine/skin_buffer.c
4#ifdef HAVE_LCD_BITMAP
5../../apps/gui/skin_engine/skin_fonts.c
6#endif
4../../apps/gui/viewport.c 7../../apps/gui/viewport.c
5../../apps/misc.c 8../../apps/misc.c
6../../firmware/common/strlcpy.c 9../../firmware/common/strlcpy.c
diff --git a/tools/checkwps/checkwps.c b/tools/checkwps/checkwps.c
index 38a650a878..32b6daa88b 100644
--- a/tools/checkwps/checkwps.c
+++ b/tools/checkwps/checkwps.c
@@ -31,6 +31,7 @@
31#include "settings.h" 31#include "settings.h"
32#include "viewport.h" 32#include "viewport.h"
33#include "file.h" 33#include "file.h"
34#include "font.h"
34 35
35bool debug_wps = true; 36bool debug_wps = true;
36int wps_verbose_level = 0; 37int wps_verbose_level = 0;
@@ -236,6 +237,21 @@ void screen_clear_area(struct screen * display, int xstart, int ystart,
236} 237}
237#endif 238#endif
238 239
240#ifdef HAVE_LCD_BITMAP
241static int loaded_fonts = 0;
242int font_load(struct font* pf, const char *path)
243{
244 int id = SYSTEMFONTCOUNT + loaded_fonts;
245 loaded_fonts++;
246 return id;
247}
248
249void font_unload(int font_id)
250{
251 (void)font_id;
252}
253#endif
254
239int main(int argc, char **argv) 255int main(int argc, char **argv)
240{ 256{
241 int res; 257 int res;
diff --git a/tools/convbdf.c b/tools/convbdf.c
index fd82fb5a73..9e42cb8d01 100644
--- a/tools/convbdf.c
+++ b/tools/convbdf.c
@@ -1393,7 +1393,16 @@ int gen_c_source(struct font* pf, char *path)
1393 " %s /* offset */\n" 1393 " %s /* offset */\n"
1394 " %s\n" 1394 " %s\n"
1395 " %d, /* defaultchar */\n" 1395 " %d, /* defaultchar */\n"
1396 " %d /* bits_size */\n" 1396 " %d, /* bits_size */\n"
1397 " -1, /* font fd */\n"
1398 " 0, /* buffer start */\n"
1399 " 0, /* ^ position */\n"
1400 " 0, /* ^ end */\n"
1401 " 0, /* ^ size */\n"
1402 " {{0,0,0,0,0},0,0,0}, /* cache */\n"
1403 " 0, /* */\n"
1404 " 0, /* */\n"
1405 " 0, /* */\n"
1397 "};\n" 1406 "};\n"
1398 "#endif /* HAVE_LCD_BITMAP */\n", 1407 "#endif /* HAVE_LCD_BITMAP */\n",
1399 pf->maxwidth, pf->height, 1408 pf->maxwidth, pf->height,