summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/menu.c4
-rw-r--r--firmware/font.c38
-rw-r--r--firmware/font.h7
-rw-r--r--firmware/loadfont.c28
-rw-r--r--firmware/system.c4
-rwxr-xr-xtools/bdf2c19
-rw-r--r--tools/writerbf.c5
7 files changed, 67 insertions, 38 deletions
diff --git a/apps/menu.c b/apps/menu.c
index dd5b9ba..a42929c 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -125,7 +125,7 @@ void put_cursorxy(int x, int y, bool on)
static void menu_draw(int m)
{
int i = 0;
-#if LCD_PROPFONTS
+#ifdef HAVE_LCD_BITMAP
int fw, fh;
int menu_lines;
lcd_getfontsize(FONT_UI, &fw, &fh);
@@ -175,7 +175,7 @@ static void menu_draw(int m)
static void put_cursor(int m, int target)
{
bool do_update = true;
-#if LCD_PROPFONTS
+#ifdef HAVE_LCD_BITMAP
int fw, fh;
int menu_lines;
lcd_getfontsize(FONT_UI, &fw, &fh);
diff --git a/firmware/font.c b/firmware/font.c
index 5237f7d..e9c70cd 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -83,6 +83,8 @@ getfont(int font)
{
PMWCFONT pf;
+ if (font >= MAXFONTS)
+ font = 0;
while (1) {
pf = sysfonts[font].pf;
if (pf && pf->height)
@@ -115,13 +117,13 @@ lcd_getstringsize(unsigned char *str, int font, int *w, int *h)
int width = 0;
while((ch = *str++)) {
- /* check input range*/
- if (ch < pf->firstchar || ch >= pf->firstchar+pf->size)
- ch = pf->defaultchar;
- ch -= pf->firstchar;
+ /* check input range*/
+ if (ch < pf->firstchar || ch >= pf->firstchar+pf->size)
+ ch = pf->defaultchar;
+ ch -= pf->firstchar;
- /* get proportional width and glyph bits*/
- width += pf->width? pf->width[ch]: pf->maxwidth;
+ /* get proportional width and glyph bits*/
+ width += pf->width? pf->width[ch]: pf->maxwidth;
}
*w = width;
*h = pf->height;
@@ -150,7 +152,11 @@ lcd_putsxy(int x, int y, unsigned char *str, int font)
/* get proportional width and glyph bits*/
width = pf->width? pf->width[ch]: pf->maxwidth;
- if(x + width > LCD_WIDTH)
+ if (x + width > LCD_WIDTH)
+ break;
+
+ /* no partial-height drawing for now...*/
+ if (y + pf->height > LCD_HEIGHT)
break;
bits = pf->bits + (pf->offset? pf->offset[ch]: (pf->height * ch));
@@ -224,29 +230,29 @@ rotleft(unsigned char *dst, MWIMAGEBITS *src, unsigned int width,
MWIMAGEBITS srcmap; /* current src input bit*/
MWIMAGEBITS dstmap; /* current dst output bit*/
- /* calc src input bit*/
- srcmap = 1 << (sizeof(MWIMAGEBITS)*8-1);
+ /* calc src input bit*/
+ srcmap = 1 << (sizeof(MWIMAGEBITS)*8-1);
- /* calc dst output bit*/
+ /* calc dst output bit*/
if (i>0 && (i%8==0)) {
++dst_col;
dst_shift = 0;
}
dstmap = 1 << dst_shift++;
- /* for each input column...*/
+ /* for each input column...*/
for(j=0; j < width; j++) {
- /* calc input bitmask*/
+ /* calc input bitmask*/
MWIMAGEBITS bit = srcmap >> j;
if (bit==0) {
srcmap = 1 << (sizeof(MWIMAGEBITS)*8-1);
bit = srcmap >> (j % 16);
}
- /* if set in input, set in rotated output*/
- if (bit & src[i]) {
- /* input column j becomes output row*/
+ /* if set in input, set in rotated output*/
+ if (bit & src[i]) {
+ /* input column j becomes output row*/
dst[j*dst_linelen + dst_col] |= dstmap;
}
/*debugf((bit & src[i])? "*": ".");*/
@@ -259,6 +265,6 @@ rotleft(unsigned char *dst, MWIMAGEBITS *src, unsigned int width,
/* -----------------------------------------------------------------
* local variables:
* eval: (load-file "rockbox-mode.el")
- * vim: et sw=4 ts=4 sts=4 tw=78
+ * vim: et sw=4 ts=8 sts=4 tw=78
* end:
*/
diff --git a/firmware/font.h b/firmware/font.h
index 8535ab2..645848e 100644
--- a/firmware/font.h
+++ b/firmware/font.h
@@ -46,7 +46,7 @@
/*
* .fnt (.rbf) loadable font file format definition
*
- * format len description
+ * format len description
* ------------------------- ---- ------------------------------
* UCHAR version[4] 4 magic number and version bytes
* UCHAR name[64] 64 font name, space padded
@@ -54,6 +54,7 @@
* USHORT maxwidth 2 font max width in pixels
* USHORT height 2 font height in pixels
* USHORT ascent 2 font ascent (baseline) in pixels
+ * USHORT pad 2 unused, pad to 32-bit boundary
* ULONG firstchar 4 first character code in font
* ULONG defaultchar 4 default character code in font
* ULONG size 4 # characters in font
@@ -61,12 +62,13 @@
* ULONG noffset 4 # longs offset data in file
* ULONG nwidth 4 # bytes width data in file
* MWIMAGEBITS bits nbits*2 image bits variable data
+ * [MWIMAGEBITS padded to 32-bit boundary]
* ULONG offset noffset*4 offset variable data
* UCHAR width nwidth*1 width variable data
*/
/* loadable font magic and version #*/
-#define VERSION "RB10"
+#define VERSION "RB11"
/* MWIMAGEBITS helper macros*/
#define MWIMAGE_WORDS(x) (((x)+15)/16) /* image size in words*/
@@ -122,5 +124,6 @@ void font_init(void);
/* -----------------------------------------------------------------
* local variables:
* eval: (load-file "rockbox-mode.el")
+ * vim: et sw=4 ts=8 sts=4 tw=78
* end:
*/
diff --git a/firmware/loadfont.c b/firmware/loadfont.c
index 7f572a4..e78f208 100644
--- a/firmware/loadfont.c
+++ b/firmware/loadfont.c
@@ -39,9 +39,8 @@
/* static buffer allocation structures*/
static unsigned char mbuf[MAX_FONT_SIZE];
static unsigned char *freeptr = mbuf;
-typedef unsigned char CFILE;
-static CFILE *fileptr;
-static CFILE *eofptr;
+static unsigned char *fileptr;
+static unsigned char *eofptr;
static int
READSHORT(unsigned short *sp)
@@ -101,9 +100,9 @@ PMWCFONT
rbf_load_font(char *path, PMWCFONT pf)
{
int fd, filesize;
- unsigned short maxwidth, height, ascent;
+ unsigned short maxwidth, height, ascent, pad;
unsigned long firstchar, defaultchar, size;
- unsigned long nbits, noffset, nwidth;
+ unsigned long i, nbits, noffset, nwidth;
char version[4+1];
char copyright[256+1];
@@ -115,10 +114,12 @@ rbf_load_font(char *path, PMWCFONT pf)
DEBUGF("Can't open font: %s\n", path);
return NULL;
}
+freeptr = (unsigned char *)(((int)mbuf + 3) & ~3);
fileptr = freeptr;
filesize = read(fd, fileptr, MAX_FONT_SIZE);
- freeptr += filesize;
eofptr = fileptr + filesize;
+ //freeptr += filesize;
+ //freeptr = (unsigned char *)(freeptr + 3) & ~3; /* pad freeptr*/
close(fd);
if (filesize == MAX_FONT_SIZE) {
DEBUGF("Font %s too large: %d\n", path, filesize);
@@ -151,6 +152,8 @@ rbf_load_font(char *path, PMWCFONT pf)
if (!READSHORT(&ascent))
return NULL;
pf->ascent = ascent;
+ if (!READSHORT(&pad))
+ return NULL;
if (!READLONG(&firstchar))
return NULL;
pf->firstchar = firstchar;
@@ -177,16 +180,22 @@ rbf_load_font(char *path, PMWCFONT pf)
/* variable font data*/
pf->bits = (MWIMAGEBITS *)fileptr;
- fileptr += nbits*sizeof(MWIMAGEBITS);
+ for (i=0; i<nbits; ++i)
+ if (!READSHORT(&pf->bits[i]))
+ return NULL;
+ /* pad to longword boundary*/
+ fileptr = (unsigned char *)(((int)fileptr + 3) & ~3);
if (noffset) {
pf->offset = (unsigned long *)fileptr;
- fileptr += noffset*sizeof(unsigned long);
+ for (i=0; i<noffset; ++i)
+ if (!READLONG(&pf->offset[i]))
+ return NULL;
} else pf->offset = NULL;
if (nwidth) {
pf->width = (unsigned char *)fileptr;
- fileptr += noffset*sizeof(unsigned char);
+ fileptr += nwidth*sizeof(unsigned char);
} else pf->width = NULL;
if (fileptr > eofptr)
@@ -198,5 +207,6 @@ rbf_load_font(char *path, PMWCFONT pf)
/* -----------------------------------------------------------------
* local variables:
* eval: (load-file "rockbox-mode.el")
+ * vim: et sw=4 ts=8 sts=4 tw=78
* end:
*/
diff --git a/firmware/system.c b/firmware/system.c
index 74e3fce..1dce076 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -19,7 +19,8 @@
#include <stdio.h>
#include "config.h"
-#include <lcd.h>
+#include "lcd.h"
+#include "font.h"
#include "led.h"
#include "system.h"
@@ -325,6 +326,7 @@ void UIE (unsigned int pc) /* Unexpected Interrupt or Exception */
/* clear screen */
lcd_clear_display ();
+ lcd_setfont(FONT_SYSFIXED);
/* output exception */
n = (n - (unsigned)UIE0 - 4)>>2; // get exception or interrupt number
snprintf(str,sizeof(str),"I%02x:%s",n,irqname[n]);
diff --git a/tools/bdf2c b/tools/bdf2c
index e6b8ee7..6832e5c 100755
--- a/tools/bdf2c
+++ b/tools/bdf2c
@@ -5,6 +5,7 @@
#
# from The Microwindows Project (http://microwindows.org)
#
+# modified 09/13/02 correct output when no DEFAULT_CHAR, allow numeric font name
# modified 09/12/02 added -limit <max_encode_hex_value> option
# modified on 09/10/02 by G Haerr
# - fixed DWIDTH 0 parsing
@@ -79,7 +80,7 @@ print " descent: $font_descent\n";
print "*/\n\n";
print "/* Font character bitmap data. */\n";
-print "static MWIMAGEBITS ${font}_bits[] = {\n";
+print "static MWIMAGEBITS _${font}_bits[] = {\n";
$ch_height = $font_ascent + $font_descent;
$ofs = 0;
@@ -162,8 +163,10 @@ print "};\n\n";
##print STDERR "Maximum character width=$maxwidth\n";
+$default_char = $firstchar if !defined $default_char;
+
print "/* Character->glyph mapping. */\n";
-print "static unsigned long ${font}_offset[] = {\n";
+print "static unsigned long _${font}_offset[] = {\n";
for (my $i = $firstchar; $i <= $lastchar; $i++) {
my $char = $i;
my $ofs = $encoding_tab[$i];
@@ -177,13 +180,13 @@ $gen_width_table = 0;
for (my $i = $firstchar; $i <= $lastchar; $i++) {
my $char = $i;
my $width = $width[$i];
- $width = $width[$default_char], $char = $default_char if !defined $encoding_tab[$i];
+ $width = $width[$default_char] if !defined $encoding_tab[$i];
$gen_width_table = 1 if $width != $maxwidth
}
if ($gen_width_table) {
print "/* Character width data. */\n";
- print "static unsigned char ${font}_width[] = {\n";
+ print "static unsigned char _${font}_width[] = {\n";
for (my $i = $firstchar; $i <= $lastchar; $i++) {
my $char = $i;
my $width = $width[$i];
@@ -204,11 +207,11 @@ print " $ch_height,\n";
print " $font_ascent,\n";
print " $firstchar,\n";
print " $size,\n";
-print " ${font}_bits,\n";
-print " ${font}_offset,\n";
+print " _${font}_bits,\n";
+print " _${font}_offset,\n";
if ($gen_width_table) {
- print " ${font}_width,\n";
+ print " _${font}_width,\n";
} else { print " 0, /* fixed width*/\n"; }
print " $default_char,\n";
-print " sizeof(${font}_bits)/sizeof(MWIMAGEBITS),\n";
+print " sizeof(_${font}_bits)/sizeof(MWIMAGEBITS),\n";
print "};\n";
diff --git a/tools/writerbf.c b/tools/writerbf.c
index b3ba864..3bd55a7 100644
--- a/tools/writerbf.c
+++ b/tools/writerbf.c
@@ -80,6 +80,7 @@ rbf_write_font(PMWCFONT pf)
WRITESHORT(ofp, pf->maxwidth);
WRITESHORT(ofp, pf->height);
WRITESHORT(ofp, pf->ascent);
+ WRITESHORT(ofp, 0);
WRITELONG(ofp, pf->firstchar);
WRITELONG(ofp, pf->defaultchar);
WRITELONG(ofp, pf->size);
@@ -92,9 +93,13 @@ rbf_write_font(PMWCFONT pf)
/* variable font data*/
for (i=0; i<pf->bits_size; ++i)
WRITESHORT(ofp, pf->bits[i]);
+ if (ftell(ofp) & 2)
+ WRITESHORT(ofp, 0); /* pad to 32-bit boundary*/
+
if (pf->offset)
for (i=0; i<pf->size; ++i)
WRITELONG(ofp, pf->offset[i]);
+
if (pf->width)
for (i=0; i<pf->size; ++i)
WRITEBYTE(ofp, pf->width[i]);