summaryrefslogtreecommitdiff
path: root/firmware/font.c
diff options
context:
space:
mode:
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 */