summaryrefslogtreecommitdiff
path: root/firmware/font.c
diff options
context:
space:
mode:
authorEric Linenberg <elinenbe@umich.edu>2002-09-16 03:18:49 +0000
committerEric Linenberg <elinenbe@umich.edu>2002-09-16 03:18:49 +0000
commit038df5cdc99c53530f52f7c0755bd64c473908b0 (patch)
tree1e0e408a276d727270a7f0496abbb908b2d76dd9 /firmware/font.c
parent8e1a00ccb290aacc5236698ea9159a377c822ec6 (diff)
downloadrockbox-038df5cdc99c53530f52f7c0755bd64c473908b0.tar.gz
rockbox-038df5cdc99c53530f52f7c0755bd64c473908b0.zip
Daniel,
The following patch makes loadable fonts actually work (finally!). It took me quite a while, but I finally figured out why the sim worked and the target didn't: the SH1 processor won't read longwords from a shortword alignment... I had to rev the .fnt file to version 1.1 (requires remaking *.fnt files) in order to fix this. Please apply the following patch completely. It's diffed against the latest CVS. I've also attached rockbox-fonts-1.1.tar.gz which includes known working *.fnt files, including a courB08 system.fnt, for demonstration. Now the real work can begin... Although the new system.fnt will work fine, if you try going to a really big font (try copying courB14.fnt to system.fnt), then you will find that it comes up and works in tree mode, but will crash the system when going into WPS mode... I'm sure this is because of the low-level lcd_bitmap not clipping properly when given a too-large bitmap, which the characters become. I haven't yet tried to debug the low-level driver. Of course, it all works on the sim... So the apps developers will now have to make sure that all apps screen sizes may vary according to the loaded font. The font height can be gotten through the lcd_getfontsize API. Files patched in fonts-6.patch 1. apps/menu.c - LCD_PROPFONTS error (2nd resubmission on this, please checkin) 2. firmware/font.c - fixes and reformatting. Please check this in as is, my vi editor requires more reformatting changes since I left tabs in the file, these are removed now (2nd resubmission on this, please checkin) 3. firmware/fonts.h - doc change on .fnt file format, .fnt version number incremented. 4. firmware/loadfont.c - fixes to load font properly, typedefs removed. 5. firmware/system.c - lcd_setfont(FONT_SYSFIXED) before issuing error, otherwise font may not exist. 6. tools/bdf2c - fixes for correct output when filename starts with a number, as well as when no DEFAULT_CHAR in .bdf file. (2nd resubmission on this, please checkin) 7. tools/writerbf.c - fixes for bugfixed fontfile format. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2294 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/font.c')
-rw-r--r--firmware/font.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/firmware/font.c b/firmware/font.c
index 5237f7d2aa..e9c70cd64e 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -83,6 +83,8 @@ getfont(int font)
83{ 83{
84 PMWCFONT pf; 84 PMWCFONT pf;
85 85
86 if (font >= MAXFONTS)
87 font = 0;
86 while (1) { 88 while (1) {
87 pf = sysfonts[font].pf; 89 pf = sysfonts[font].pf;
88 if (pf && pf->height) 90 if (pf && pf->height)
@@ -115,13 +117,13 @@ lcd_getstringsize(unsigned char *str, int font, int *w, int *h)
115 int width = 0; 117 int width = 0;
116 118
117 while((ch = *str++)) { 119 while((ch = *str++)) {
118 /* check input range*/ 120 /* check input range*/
119 if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) 121 if (ch < pf->firstchar || ch >= pf->firstchar+pf->size)
120 ch = pf->defaultchar; 122 ch = pf->defaultchar;
121 ch -= pf->firstchar; 123 ch -= pf->firstchar;
122 124
123 /* get proportional width and glyph bits*/ 125 /* get proportional width and glyph bits*/
124 width += pf->width? pf->width[ch]: pf->maxwidth; 126 width += pf->width? pf->width[ch]: pf->maxwidth;
125 } 127 }
126 *w = width; 128 *w = width;
127 *h = pf->height; 129 *h = pf->height;
@@ -150,7 +152,11 @@ lcd_putsxy(int x, int y, unsigned char *str, int font)
150 152
151 /* get proportional width and glyph bits*/ 153 /* get proportional width and glyph bits*/
152 width = pf->width? pf->width[ch]: pf->maxwidth; 154 width = pf->width? pf->width[ch]: pf->maxwidth;
153 if(x + width > LCD_WIDTH) 155 if (x + width > LCD_WIDTH)
156 break;
157
158 /* no partial-height drawing for now...*/
159 if (y + pf->height > LCD_HEIGHT)
154 break; 160 break;
155 bits = pf->bits + (pf->offset? pf->offset[ch]: (pf->height * ch)); 161 bits = pf->bits + (pf->offset? pf->offset[ch]: (pf->height * ch));
156 162
@@ -224,29 +230,29 @@ rotleft(unsigned char *dst, MWIMAGEBITS *src, unsigned int width,
224 MWIMAGEBITS srcmap; /* current src input bit*/ 230 MWIMAGEBITS srcmap; /* current src input bit*/
225 MWIMAGEBITS dstmap; /* current dst output bit*/ 231 MWIMAGEBITS dstmap; /* current dst output bit*/
226 232
227 /* calc src input bit*/ 233 /* calc src input bit*/
228 srcmap = 1 << (sizeof(MWIMAGEBITS)*8-1); 234 srcmap = 1 << (sizeof(MWIMAGEBITS)*8-1);
229 235
230 /* calc dst output bit*/ 236 /* calc dst output bit*/
231 if (i>0 && (i%8==0)) { 237 if (i>0 && (i%8==0)) {
232 ++dst_col; 238 ++dst_col;
233 dst_shift = 0; 239 dst_shift = 0;
234 } 240 }
235 dstmap = 1 << dst_shift++; 241 dstmap = 1 << dst_shift++;
236 242
237 /* for each input column...*/ 243 /* for each input column...*/
238 for(j=0; j < width; j++) { 244 for(j=0; j < width; j++) {
239 245
240 /* calc input bitmask*/ 246 /* calc input bitmask*/
241 MWIMAGEBITS bit = srcmap >> j; 247 MWIMAGEBITS bit = srcmap >> j;
242 if (bit==0) { 248 if (bit==0) {
243 srcmap = 1 << (sizeof(MWIMAGEBITS)*8-1); 249 srcmap = 1 << (sizeof(MWIMAGEBITS)*8-1);
244 bit = srcmap >> (j % 16); 250 bit = srcmap >> (j % 16);
245 } 251 }
246 252
247 /* if set in input, set in rotated output*/ 253 /* if set in input, set in rotated output*/
248 if (bit & src[i]) { 254 if (bit & src[i]) {
249 /* input column j becomes output row*/ 255 /* input column j becomes output row*/
250 dst[j*dst_linelen + dst_col] |= dstmap; 256 dst[j*dst_linelen + dst_col] |= dstmap;
251 } 257 }
252 /*debugf((bit & src[i])? "*": ".");*/ 258 /*debugf((bit & src[i])? "*": ".");*/
@@ -259,6 +265,6 @@ rotleft(unsigned char *dst, MWIMAGEBITS *src, unsigned int width,
259/* ----------------------------------------------------------------- 265/* -----------------------------------------------------------------
260 * local variables: 266 * local variables:
261 * eval: (load-file "rockbox-mode.el") 267 * eval: (load-file "rockbox-mode.el")
262 * vim: et sw=4 ts=4 sts=4 tw=78 268 * vim: et sw=4 ts=8 sts=4 tw=78
263 * end: 269 * end:
264 */ 270 */