diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-06-24 06:41:19 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-06-24 06:41:19 +0000 |
commit | 848c2cd7338490b2237b0ef86528f2bea2020f47 (patch) | |
tree | b7947e47cdd063741e1522f702edfb950ef977ab /firmware/drivers/lcd.c | |
parent | c5ddb150d9565dfd460d43255c2458fb56072180 (diff) |
slightly improved fix for proportional font scrolling, but it still isn't
really as good as it should be
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1134 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd.c')
-rw-r--r-- | firmware/drivers/lcd.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c index e1e27c8f39..e77fd56b56 100644 --- a/firmware/drivers/lcd.c +++ b/firmware/drivers/lcd.c @@ -495,7 +495,7 @@ extern unsigned char char_dw_8x8_prop[][9]; /* * Return width and height of a given font. */ -void lcd_getstringsize(char *str, unsigned int font, int *w, int *h) +int lcd_getstringsize(char *str, unsigned int font, int *w, int *h) { int width=0; int height=0; @@ -518,6 +518,8 @@ void lcd_getstringsize(char *str, unsigned int font, int *w, int *h) } *w = width; *h = height; + + return width; } /* @@ -527,7 +529,7 @@ void lcd_getstringsize(char *str, unsigned int font, int *w, int *h) void lcd_putspropxy(int x, int y, char *str, int thisfont) { int ch; - int nx = char_dw_8x8_prop[*str][8] >> 4; + int nx = char_dw_8x8_prop[(int)*str][8] >> 4; int ny=8; unsigned char *src; int lcd_x = x; @@ -914,21 +916,30 @@ void lcd_getfontsize(unsigned int font, int *width, int *height) void lcd_puts_scroll(int x, int y, char* string ) { struct scrollinfo* s = &scroll; - char *ch; #ifdef HAVE_LCD_CHARCELLS s->space = 11 - x; #else + +#ifdef LCD_PROPFONTS + unsigned char ch[2]; + int w, h; +#endif int width, height; lcd_getfontsize(font, &width, &height); #ifndef LCD_PROPFONTS s->space = (LCD_WIDTH - xmargin - x*width) / width; #else - ch = string; + ch[1] = 0; /* zero terminate */ + ch[0] = string[0]; width = 0; - for (s->space = 0; width + (char_dw_8x8_prop[*ch][8]>>4) < LCD_WIDTH - x; - width += (char_dw_8x8_prop[*ch][8]>>4), ch++, s->space++); + for (s->space = 0; + width + lcd_getstringsize(ch, 0, &w, &h) < (LCD_WIDTH - x*8); ) { + width += lcd_getstringsize(ch, 0, &w, &h); + ch[0]=string[(int)++s->space]; + } #endif #endif + lcd_puts(x,y,string); s->textlen = strlen(string); if ( s->textlen > s->space ) { |