Yann,
thank you for the comments.

Yann E. MORIN ha scritto:
Yes, but I think also that this feature could be easily put under
conditional compilation.

Yes, it should be a config option.

Ok, now the text rendering is under the FBSPLASH_TEXT_RENDERING option.


The fontmap sounds like it could reside in RO, perhaps.
What you mean with RO? Read only memory? Isn't it hardware dependent?
Please, can you give me a more detailed description?

-static char fontmap[95][12] = {
+static const char fontmap[95][12] = {

Uh, much more clear! Of course, done.


Also, the fontmap could reside in a external file with the applet that loads
one character at a time.

Yes please do so, this way people could have 'personalised' font maps.
Still, offer a config option to hardcode the fontmap file.

With the new patch the text rendering is an option of the fbsplash applet.
I have also added an option (-m) to pass the map of characters from an external file. For the moment the font map file that I have added to the project (fbsplash_fontmap) contains the same fonts hard coded.

For the three options, the size output is:

size miscutils/fbsplash.o
   text    data     bss     dec     hex filename
   1773       0       0    1773     6ed miscutils/fbsplash.o
size miscutils/fbsplash_hardcoded.o
   text    data     bss     dec     hex filename
   3447       8       0    3455     d7f miscutils/fbsplash.o
size miscutils/fbsplash_extfile.o
   text    data     bss     dec     hex filename
   2375       8       4    2387     953 miscutils/fbsplash.o


And a further improvement would be to support multibyte-strings for
localisation.

I would recommend having a simple font file like:
  # Lines starting with # are ignored
  # So are empty line
  0x12345678 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C

where the first hexa number is the UTF-8 sequence to be recognised, and the
folowing single bytes are the patern to draw.

Of course, the font table will be sparse, and finding the character to
draw will need (smart) iteration throught the table. And because the table
might miss entries for some characters, have a default character be drawn
(eg 0x00000000).

Then, in the build procedure, have a litle script that parses that file format
and outputs either a .h file if the font is hardcoded, or a binary blob if the
font is dynamicaly loaded at run time.

So to sum up:
 - text rendering should be configurable
 - the font map can be either hard-coded to use the default font map,
   or it can be dynamically loaded at runtime, so the user can create
   their own font maps
 - font map should be UTF-8 compliant, to allow localisation.
 - the source font map format should be documented (at least in the
   default font map).

Of course, this is but my opinion. :-)

Very interesting design Yann!!
But since I have not yet had other answer, I propose to postpone this improvement.

Please, someone can test the new functionality?

Thanks a lot.

--
Michele Sanges

diff -urP /tmp/acroread_0_0/busybox-1.12.0/include/usage.h 
busybox-1.12.0/include/usage.h
--- /tmp/acroread_0_0/busybox-1.12.0/include/usage.h    2008-08-20 
00:05:31.000000000 +0200
+++ busybox-1.12.0/include/usage.h      2008-09-21 23:58:08.000000000 +0200
@@ -128,7 +128,7 @@
        "bar"
 
 #define fbsplash_trivial_usage \
-       "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD]"
+       "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD] [-m FONTMAPFILE]"
 #define fbsplash_full_usage "\n\n" \
        "Options:\n" \
      "\n       -s      Image" \
@@ -137,8 +137,10 @@
      "\n       -i      Config file (var=value):" \
      "\n                       BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT" \
      "\n                       BAR_R,BAR_G,BAR_B" \
+     "\n                       
TEXT_LEFT,TEXT_TOP,TEXT_R,TEXT_G,TEXT_B,TEXT_SIZE" \
      "\n       -f      Control pipe (else exit after drawing image)" \
-     "\n                       commands: 'NN' (% for progress bar) or 'exit'" \
+     "\n       -m      Font map file" \
+     "\n                       commands: 'NN' (% for progress bar), 
'write:string to print' or 'exit'"
 
 #define brctl_trivial_usage \
        "COMMAND [BRIDGE [INTERFACE]]"
diff -urP /tmp/acroread_0_0/busybox-1.12.0/miscutils/Config.in 
busybox-1.12.0/miscutils/Config.in
--- /tmp/acroread_0_0/busybox-1.12.0/miscutils/Config.in        2008-08-06 
00:56:08.000000000 +0200
+++ busybox-1.12.0/miscutils/Config.in  2008-09-21 23:53:05.000000000 +0200
@@ -223,6 +223,34 @@
            "NN" (ASCII decimal number) - percentage to show on progress bar
            "exit" - well you guessed it
 
+config FBSPLASH_TEXT_RENDERING
+       bool "text rendering"
+       default n
+       depends on FBSPLASH
+       help
+         This option adds the ability to print text messages on the
+         image displayed by the fbsplash applet.
+         - command for fifo:
+           "write:string to print" - print the string after the word "write:"
+
+choice
+       prompt "Choose the font map"
+       depends on FBSPLASH_TEXT_RENDERING
+       default FONTMAP_HARDCODED
+
+config FONTMAP_HARDCODED
+       bool "hardcoded"
+       help
+         The font map is hard-coded to use the default font map.
+         Adds about 1.6Kb.
+
+config FONTMAP_DINAMICALLY_LOADED
+       bool "dinamically loaded"
+       help
+         The font map is dinamically loaded from a file.
+         Adds about 600 byte.
+endchoice
+
 config INOTIFYD
        bool "inotifyd"
        default n
diff -urP /tmp/acroread_0_0/busybox-1.12.0/miscutils/fbsplash.c 
busybox-1.12.0/miscutils/fbsplash.c
--- /tmp/acroread_0_0/busybox-1.12.0/miscutils/fbsplash.c       2008-08-06 
00:56:08.000000000 +0200
+++ busybox-1.12.0/miscutils/fbsplash.c 2008-09-22 00:02:10.000000000 +0200
@@ -1,7 +1,6 @@
 /* vi: set sw=4 ts=4: */
 /*
- * Copyright (C) 2008 Michele Sanges <[EMAIL PROTECTED]>,
- * <[EMAIL PROTECTED]>
+ * Copyright (C) 2008 Michele Sanges <[EMAIL PROTECTED]>
  *
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  *
@@ -14,11 +13,13 @@
  *      -s path_to_image_file (can be "-" for stdin)
  *      -i path_to_cfg_file
  *      -f path_to_fifo (can be "-" for stdin)
+ *      -m font map file
  * - if you want to run it only in presence of a kernel parameter
  *   (for example fbsplash=on), use:
  *   grep -q "fbsplash=on" </proc/cmdline && setsid fbsplash [params]
  * - commands for fifo:
  *   "NN" (ASCII decimal number) - percentage to show on progress bar.
+ *   "write:string to print" - print the string after the word "write:"
  *   "exit" (or just close fifo) - well you guessed it.
  */
 
@@ -38,7 +39,7 @@
        FILE *logfile_fd;       // log file
 #endif
        unsigned char *addr;    // pointer to framebuffer memory
-       unsigned ns[7];         // n-parameters
+       unsigned ns[13];        // n-parameters
        const char *image_filename;
        struct fb_var_screeninfo scr_var;
        struct fb_fix_screeninfo scr_fix;
@@ -55,6 +56,12 @@
 #define nbar_colr      ns[4]   // progress bar color red component
 #define nbar_colg      ns[5]   // progress bar color green component
 #define nbar_colb      ns[6]   // progress bar color blue component
+#define text_posx      ns[7]   // text horizontal position
+#define text_posy      ns[8]   // text vertical position
+#define text_colr      ns[9]   // text color red component
+#define text_colg      ns[10]  // text color green component
+#define text_colb      ns[11]  // text color blue component
+#define text_size      ns[12]  // text size (1 to 4)
 
 #if DEBUG
 #define DEBUG_MESSAGE(strMessage, args...) \
@@ -66,6 +73,1345 @@
 #define DEBUG_MESSAGE(...) ((void)0)
 #endif
 
+#if ENABLE_FBSPLASH_TEXT_RENDERING
+
+#if ENABLE_FONTMAP_HARDCODED
+static const char fontmap[95][12] = {
+ //space (32) 
+{0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ // ! (33) 
+{0x00,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x00,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //" (34) 
+{0x00,
+0xA0,
+0xA0,
+0xA0,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //# (35) 
+{0x00,
+0x24,
+0x24,
+0x7E,
+0x28,
+0xFC,
+0x48,
+0x48,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //$ (36) 
+{0x00,
+0x20,
+0x78,
+0xA0,
+0x60,
+0x30,
+0x28,
+0xF0,
+0x20,
+0x20,
+0x00,
+0x00},
+
+ //% (37) 
+{0x00,
+0x64,
+0x98,
+0x98,
+0x7E,
+0x19,
+0x19,
+0x26,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //& (38) 
+{0x00,
+0x60,
+0x90,
+0x90,
+0x68,
+0x90,
+0x98,
+0x64,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //' (39) 
+{0x00,
+0x80,
+0x80,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //( (40) 
+{0x00,
+0x20,
+0x40,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x40,
+0x20,
+0x00},
+
+ //) (41) 
+{0x00,
+0x80,
+0x40,
+0x20,
+0x20,
+0x20,
+0x20,
+0x20,
+0x20,
+0x40,
+0x80,
+0x00},
+
+ //* (42) 
+{0x00,
+0x20,
+0xA8,
+0x70,
+0xA8,
+0x20,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //+ (43) 
+{0x00,
+0x00,
+0x20,
+0x20,
+0xF8,
+0x20,
+0x20,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //, (44) 
+{0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x40,
+0x40,
+0x80,
+0x00},
+
+ //- (45) 
+{0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0xC0,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //punto (112) 
+{0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x80,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ /// (47) 
+{0x00,
+0x20,
+0x20,
+0x40,
+0x40,
+0x40,
+0x40,
+0x40,
+0x80,
+0x80,
+0x00,
+0x00},
+
+ //0 (48) 
+{0x00,
+0x60,
+0x90,
+0x90,
+0x90,
+0x90,
+0x90,
+0x60,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //1 (49) 
+{0x00,
+0x40,
+0xC0,
+0x40,
+0x40,
+0x40,
+0x40,
+0xE0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //2 (50) 
+{0x00,
+0xE0,
+0x10,
+0x10,
+0x20,
+0x40,
+0x80,
+0xF0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //3 (51) 
+{0x00,
+0xE0,
+0x10,
+0x10,
+0x60,
+0x10,
+0x10,
+0xE0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //4 (52) 
+{0x00,
+0x10,
+0x30,
+0x50,
+0x90,
+0xF8,
+0x10,
+0x10,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //5 (53) 
+{0x00,
+0xF0,
+0x80,
+0x80,
+0xE0,
+0x10,
+0x10,
+0xE0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //6 (54) 
+{0x00,
+0x60,
+0x80,
+0x80,
+0xE0,
+0x90,
+0x90,
+0x60,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //7 (55) 
+{0x00,
+0xF0,
+0x10,
+0x20,
+0x20,
+0x40,
+0x40,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //8 (56) 
+{0x00,
+0x60,
+0x90,
+0x90,
+0x60,
+0x90,
+0x90,
+0x60,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //9 (57) 
+{0x00,
+0x60,
+0x90,
+0x90,
+0x70,
+0x10,
+0x10,
+0x60,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //: (58) 
+{0x00,
+0x00,
+0x00,
+0x80,
+0x80,
+0x00,
+0x80,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //; (59) 
+{0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x40,
+0x40,
+0x00,
+0x40,
+0x40,
+0x80},
+
+ //< (60) 
+{0x00,
+0x00,
+0x00,
+0x08,
+0x70,
+0x80,
+0x70,
+0x08,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //= (61) 
+{0x00,
+0x00,
+0x00,
+0x00,
+0xFC,
+0x00,
+0xFC,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //> (62) 
+{0x00,
+0x00,
+0x00,
+0x80,
+0x70,
+0x08,
+0x70,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //? (63) 
+{0x00,
+0xE0,
+0x10,
+0x10,
+0x20,
+0x40,
+0x00,
+0x40,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //@ (64) 
+{0x00,
+0x38,
+0x44,
+0x9A,
+0xAA,
+0xAA,
+0x9C,
+0x40,
+0x38,
+0x00,
+0x00,
+0x00},
+
+ //A (65) 
+{0x00,
+0x30,
+0x30,
+0x48,
+0x48,
+0xFC,
+0x84,
+0x84,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //B (66) 
+{0x00,
+0xE0,
+0x90,
+0x90,
+0xF0,
+0x88,
+0x88,
+0xF0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //C (67) 
+{0x00,
+0x38,
+0x44,
+0x80,
+0x80,
+0x80,
+0x44,
+0x38,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //D (68) 
+{0x00,
+0xF0,
+0x88,
+0x84,
+0x84,
+0x84,
+0x88,
+0xF0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //E (69) 
+{0x00,
+0xF8,
+0x80,
+0x80,
+0xF0,
+0x80,
+0x80,
+0xF8,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //F (70) 
+{0x00,
+0xF8,
+0x80,
+0x80,
+0xF0,
+0x80,
+0x80,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //G (71) 
+{0x00,
+0x38,
+0x44,
+0x80,
+0x9C,
+0x84,
+0x44,
+0x3C,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //H (72) 
+{0x00,
+0x84,
+0x84,
+0x84,
+0xFC,
+0x84,
+0x84,
+0x84,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //I (73) 
+{0x00,
+0xE0,
+0x40,
+0x40,
+0x40,
+0x40,
+0x40,
+0xE0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //J (74) 
+{0x00,
+0x60,
+0x20,
+0x20,
+0x20,
+0x20,
+0x20,
+0xC0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //K (75) 
+{0x00,
+0x88,
+0x90,
+0xA0,
+0xC0,
+0xA0,
+0x90,
+0x88,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //L (76) 
+{0x00,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0xF0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //M (77) 
+{0x00,
+0xC6,
+0xC6,
+0xAA,
+0xAA,
+0x92,
+0x92,
+0x82,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //N (78) 
+{0x00,
+0x84,
+0xC4,
+0xA4,
+0x94,
+0x8C,
+0x84,
+0x84,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //O (79) 
+{0x00,
+0x38,
+0x44,
+0x82,
+0x82,
+0x82,
+0x44,
+0x38,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //P (80) 
+{0x00,
+0xF0,
+0x88,
+0x88,
+0x88,
+0xF0,
+0x80,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //Q (81) 
+{0x00,
+0x38,
+0x44,
+0x82,
+0x82,
+0x82,
+0x44,
+0x38,
+0x08,
+0x06,
+0x00,
+0x00},
+
+ //R (82) 
+{0x00,
+0xF0,
+0x88,
+0x88,
+0xF0,
+0xA0,
+0x90,
+0x88,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //S (83) 
+{0x00,
+0x78,
+0x80,
+0x80,
+0x70,
+0x08,
+0x08,
+0xF0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //T (84) 
+{0x00,
+0xF8,
+0x20,
+0x20,
+0x20,
+0x20,
+0x20,
+0x20,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //U (85) 
+{0x00,
+0x84,
+0x84,
+0x84,
+0x84,
+0x84,
+0x84,
+0x78,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //V (86) 
+{0x00,
+0x84,
+0x84,
+0x84,
+0x48,
+0x48,
+0x30,
+0x30,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //W (87) 
+{0x00,
+0x92,
+0x92,
+0xAA,
+0xAA,
+0xAA,
+0x44,
+0x44,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //X (88) 
+{0x00,
+0x90,
+0x90,
+0x60,
+0x60,
+0x60,
+0x90,
+0x90,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //Y (89) 
+{0x00,
+0x88,
+0x50,
+0x50,
+0x20,
+0x20,
+0x20,
+0x20,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //Z (90) 
+{0x00,
+0xF0,
+0x10,
+0x20,
+0x40,
+0x40,
+0x80,
+0xF0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //[ (91) 
+{0x00,
+0xC0,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0xC0,
+0x00},
+
+ //\ (92) 
+{0x00,
+0x80,
+0x80,
+0x40,
+0x40,
+0x40,
+0x40,
+0x40,
+0x20,
+0x20,
+0x00,
+0x00},
+
+ //] (93) 
+{0x00,
+0xC0,
+0x40,
+0x40,
+0x40,
+0x40,
+0x40,
+0x40,
+0x40,
+0x40,
+0xC0,
+0x00},
+
+ //^ (94) 
+{0x00,
+0x20,
+0x50,
+0x88,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //_ (95) 
+{0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0xF0,
+0x00,
+0x00},
+
+ //  (32) 
+{0x00,
+0x80,
+0x40,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //a (97) 
+{0x00,
+0x00,
+0x00,
+0x60,
+0x10,
+0x70,
+0x90,
+0x70,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //b (98) 
+{0x80,
+0x80,
+0x80,
+0xE0,
+0x90,
+0x90,
+0x90,
+0xE0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //c (99) 
+{0x00,
+0x00,
+0x00,
+0x60,
+0x80,
+0x80,
+0x80,
+0x60,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //d (100) 
+{0x10,
+0x10,
+0x10,
+0x70,
+0x90,
+0x90,
+0x90,
+0x70,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //e (101) 
+{0x00,
+0x00,
+0x00,
+0x60,
+0x90,
+0xF0,
+0x80,
+0x70,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //f (102) 
+{0x60,
+0x80,
+0x80,
+0xE0,
+0x80,
+0x80,
+0x80,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //g (103) 
+{0x00,
+0x00,
+0x00,
+0x70,
+0x90,
+0x90,
+0x90,
+0x70,
+0x10,
+0x60,
+0x00,
+0x00},
+
+ //h (104) 
+{0x80,
+0x80,
+0x80,
+0xE0,
+0x90,
+0x90,
+0x90,
+0x90,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //i (105) 
+{0x00,
+0x80,
+0x00,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //j (106) 
+{0x00,
+0x40,
+0x00,
+0xC0,
+0x40,
+0x40,
+0x40,
+0x40,
+0x40,
+0x80,
+0x00,
+0x00},
+
+ //k (107) 
+{0x80,
+0x80,
+0x80,
+0x90,
+0xA0,
+0xC0,
+0xA0,
+0x90,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //l (108) 
+{0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //m (109) 
+{0x00,
+0x00,
+0x00,
+0xEC,
+0x92,
+0x92,
+0x92,
+0x92,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //n (110) 
+{0x00,
+0x00,
+0x00,
+0xE0,
+0x90,
+0x90,
+0x90,
+0x90,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //o (111) 
+{0x00,
+0x00,
+0x00,
+0x60,
+0x90,
+0x90,
+0x90,
+0x60,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //p (112) 
+{0x00,
+0x00,
+0x00,
+0xE0,
+0x90,
+0x90,
+0x90,
+0xE0,
+0x80,
+0x80,
+0x00,
+0x00},
+
+ //q (113) 
+{0x00,
+0x00,
+0x00,
+0x70,
+0x90,
+0x90,
+0x90,
+0x70,
+0x10,
+0x10,
+0x00,
+0x00},
+
+ //r (114) 
+{0x00,
+0x00,
+0x00,
+0xA0,
+0xC0,
+0x80,
+0x80,
+0x80,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //s (115) 
+{0x00,
+0x00,
+0x00,
+0xE0,
+0x80,
+0x40,
+0x20,
+0xE0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //t (116) 
+{0x00,
+0x00,
+0x80,
+0xC0,
+0x80,
+0x80,
+0x80,
+0x40,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //u (117) 
+{0x00,
+0x00,
+0x00,
+0x90,
+0x90,
+0x90,
+0x90,
+0x70,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //v (118) 
+{0x00,
+0x00,
+0x00,
+0x88,
+0x50,
+0x50,
+0x50,
+0x20,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //w (119) 
+{0x00,
+0x00,
+0x00,
+0x92,
+0x92,
+0xAA,
+0x6C,
+0x44,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //x (120) 
+{0x00,
+0x00,
+0x00,
+0xA0,
+0x40,
+0x40,
+0x40,
+0xA0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //y (121) 
+{0x00,
+0x00,
+0x00,
+0x88,
+0x50,
+0x50,
+0x50,
+0x20,
+0x20,
+0x40,
+0x00,
+0x00},
+
+ //z (122) 
+{0x00,
+0x00,
+0x00,
+0xE0,
+0x20,
+0x40,
+0x80,
+0xE0,
+0x00,
+0x00,
+0x00,
+0x00},
+
+ //{ (123) 
+{0x00,
+0x20,
+0x40,
+0x40,
+0x40,
+0x40,
+0x80,
+0x40,
+0x40,
+0x40,
+0x20,
+0x00},
+
+ //| (124) 
+{0x00,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x80,
+0x00},
+
+ //} (125) 
+{0x00,
+0x80,
+0x40,
+0x40,
+0x40,
+0x40,
+0x20,
+0x40,
+0x40,
+0x40,
+0x80,
+0x00},
+
+ //~ (126) 
+{0x00,
+0x60,
+0x90,
+0x90,
+0x60,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00}};
+
+#else
+       static FILE *fontmap_fd = NULL;
+#endif
+#endif
+
 
 /**
  *     Open and initialize the framebuffer device
@@ -213,9 +1559,13 @@
 
 
 /**
- *     Draw image from PPM file
+ *     Draws a PPM image.
+ * \param nXPos horizontal position from which draw the image.
+ * \param nYPos vertical position from which draw the image. With nXPos=-1 and 
nYPos=-1, draws the full image.
+ * \param nXDim horizontal dimension of the image section to draw.
+ * \param nYDim vertical dimension of the image section to draw.
  */
-static void fb_drawimage(void)
+static void fb_drawimage(int nXPos, int nYPos, int nXDim, int nYDim)
 {
        char head[256];
        char s[80];
@@ -254,13 +1604,29 @@
                height = G.scr_var.yres;
 
        pixline = xmalloc(line_size);
-       for (j = 0; j < height; j++) {
-               unsigned char *pixel = pixline;
-               DATA *src = (DATA *)(G.addr + j * G.scr_fix.line_length);
+
+       if (nYPos == -1) {
+               nYPos = 0;
+       }
+       else {
+               fseek(theme_file, line_size * nYPos, SEEK_CUR);
+               height = nYPos + nYDim;
+       }
+
+       if (nXPos == -1) {
+               nXPos = 0;
+       }
+       else {
+               width = nXPos + nXDim;
+       }
+
+       for (j = nYPos; j < height; j++) {
+               unsigned char *pixel = pixline + 3 * nXPos;
+               DATA *src = (DATA *)(G.addr + (j * G.scr_var.xres + nXPos) * 
BYTES_PER_PIXEL);
 
                if (fread(pixline, 1, line_size, theme_file) != line_size)
                        bb_error_msg_and_die("bad PPM file '%s'", 
G.image_filename);
-               for (i = 0; i < width; i++) {
+               for (i = nXPos; i < width; i++) {
                        unsigned thispix;
                        thispix = (((unsigned)pixel[0] << 8) & 0xf800)
                                | (((unsigned)pixel[1] << 3) & 0x07e0)
@@ -274,6 +1640,85 @@
 }
 
 
+#if ENABLE_FBSPLASH_TEXT_RENDERING
+/**
+ *     Draws a single character on framebuffer.
+ * \param nXPos horizontal position from which draw the character.
+ * \param nYPos vertical position from which draw the character.
+ * \param nCharSize character scale factor [1..4].
+ * \param nChar character to draw.
+ */
+static void fb_drawchar(int nXPos, int nYPos, int nCharSize, int nChar)
+{
+       unsigned char nred, ngreen, nblue;
+       DATA *ptr, thispix;
+
+       nred = G.text_colr;
+       ngreen = G.text_colg;
+       nblue = G.text_colb;
+
+       nred   >>= 3;  // 5-bit red
+       ngreen >>= 2;  // 6-bit green
+       nblue  >>= 3;  // 5-bit blue
+       thispix = nblue + (ngreen << 5) + (nred << (5+6));
+
+       for (int nHeight = 0; nHeight < 12 * nCharSize; nHeight++) {
+               for (int nWidth = 0; nWidth < 8 * nCharSize; nWidth++) {
+#if ENABLE_FONTMAP_HARDCODED
+                       if ((fontmap[nChar - 32][nHeight / nCharSize] & (0x80 
>> (nWidth / nCharSize))) != 0) {
+                               ptr = (DATA*)(G.addr + ((nYPos + nHeight) * 
G.scr_var.xres + (nXPos + nWidth)) * BYTES_PER_PIXEL);
+                               *ptr = thispix;
+                       }
+#else
+                       if (fontmap_fd != NULL) {
+                               char fontmap[12];
+                               fseek(fontmap_fd, 12 * (nChar - 32), SEEK_SET);
+                               fread(fontmap, 1, 12, fontmap_fd);
+                               if ((fontmap[nHeight / nCharSize] & (0x80 >> 
(nWidth / nCharSize))) != 0) {
+                                       ptr = (DATA*)(G.addr + ((nYPos + 
nHeight) * G.scr_var.xres + (nXPos + nWidth)) * BYTES_PER_PIXEL);
+                                       *ptr = thispix;
+                               }
+                       }
+#endif
+               }
+       }
+}
+
+
+/**
+ *     Draws a string on framebuffer.
+ * \param *strString pointer to the string.
+ */
+static void fb_drawstring(char *strString)
+{
+       int nCharSize;
+       static int nOldCharSize = -1;
+       static int nOldStringSize = -1;         // in pixel
+
+       // size check
+       nCharSize = G.text_size;
+       if (nCharSize < 1)
+               nCharSize = 1;
+       else if (nCharSize > 4)
+               nCharSize = 4;
+
+       // redraws the portion of image interested to the old write operation
+       if (nOldStringSize != -1) {
+               fb_drawimage(G.text_posx, G.text_posy, nOldStringSize, 12 * 
nCharSize);
+       }
+
+       // new write operation
+       for (int nCharNum = 0; nCharNum < strlen(strString); nCharNum++) {
+               char c = *(strString + nCharNum);
+               fb_drawchar(G.text_posx + 8 * nCharSize * nCharNum, 
G.text_posy, nCharSize, c);
+       }
+
+       nOldCharSize = nCharSize;
+       nOldStringSize = 8 * nCharSize * strlen(strString);
+}
+
+#endif
+
 /**
  *     Parse configuration file
  * \param *cfg_filename name of the configuration file
@@ -284,6 +1729,7 @@
                "BAR_WIDTH\0" "BAR_HEIGHT\0"
                "BAR_LEFT\0" "BAR_TOP\0"
                "BAR_R\0" "BAR_G\0" "BAR_B\0"
+               "TEXT_LEFT\0" "TEXT_TOP\0" "TEXT_R\0" "TEXT_G\0" "TEXT_B\0" 
"TEXT_SIZE\0"
 #if DEBUG
                "DEBUG\0"
 #endif
@@ -296,10 +1742,10 @@
                int i = index_in_strings(param_names, token[0]);
                if (i < 0)
                        bb_error_msg_and_die("syntax error: '%s'", token[0]);
-               if (i >= 0 && i < 7)
+               if (i >= 0 && i < 13)
                        G.ns[i] = val;
 #if DEBUG
-               if (i == 7) {
+               if (i == 13) {
                        G.bdebug_messages = val;
                        if (G.bdebug_messages)
                                G.logfile_fd = 
xfopen_for_write("/tmp/fbsplash.log");
@@ -314,6 +1760,10 @@
 int fbsplash_main(int argc UNUSED_PARAM, char **argv)
 {
        const char *fb_device, *cfg_filename, *fifo_filename;
+#if ENABLE_FONTMAP_DINAMICALLY_LOADED
+       const char *fontmap_filename = NULL;
+#endif
+
        FILE *fp = fp; // for compiler
        char *num_buf;
        unsigned num;
@@ -325,9 +1775,16 @@
        fb_device = "/dev/fb0";
        cfg_filename = NULL;
        fifo_filename = NULL;
+#if ENABLE_FONTMAP_DINAMICALLY_LOADED
+       bCursorOff = 1 & getopt32(argv, "cs:d:i:f:m:",
+                       &G.image_filename, &fb_device, &cfg_filename, 
&fifo_filename, &fontmap_filename);
+
+       if (fontmap_filename)
+               fontmap_fd = xfopen_stdin(fontmap_filename);
+#else
        bCursorOff = 1 & getopt32(argv, "cs:d:i:f:",
                        &G.image_filename, &fb_device, &cfg_filename, 
&fifo_filename);
-
+#endif
        // parse configuration file
        if (cfg_filename)
                init(cfg_filename);
@@ -343,7 +1800,7 @@
                full_write(STDOUT_FILENO, "\x1b" "[?25l", 6);
        }
 
-       fb_drawimage();
+       fb_drawimage(-1, -1, -1, -1);
 
        if (!fifo_filename)
                return EXIT_SUCCESS;
@@ -374,6 +1831,12 @@
                        DEBUG_MESSAGE("exit");
                        break;
                }
+#if ENABLE_FBSPLASH_TEXT_RENDERING
+               else if (strncmp(num_buf, "write:", 6) == 0) {
+                       fb_drawstring(num_buf + 6);
+                       continue;
+               }
+#endif
                num = atoi(num_buf);
                if (isdigit(num_buf[0]) && (num <= 100)) {
 #if DEBUG
diff -urP /tmp/acroread_0_0/busybox-1.12.0/miscutils/fbsplash.cfg 
busybox-1.12.0/miscutils/fbsplash.cfg
--- /tmp/acroread_0_0/busybox-1.12.0/miscutils/fbsplash.cfg     2008-08-06 
00:56:08.000000000 +0200
+++ busybox-1.12.0/miscutils/fbsplash.cfg       2008-09-21 15:35:41.000000000 
+0200
@@ -7,3 +7,13 @@
 BAR_R=80
 BAR_G=80
 BAR_B=130
+# the below settings are active only if you enable the option 
FBSPLASH_TEXT_RENDERING
+# text position
+TEXT_LEFT=100
+TEXT_TOP=350
+# text color
+TEXT_R=80
+TEXT_G=80
+TEXT_B=130
+# text size (1 to 4)
+TEXT_SIZE=2
Binary files /tmp/acroread_0_0/busybox-1.12.0/miscutils/fbsplash_fontmap and 
busybox-1.12.0/miscutils/fbsplash_fontmap differ

Attachment: fbsplash_fontmap
Description: Binary data

_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to