From b0fee17d6e1a463dcd84568e5997663b69488998 Mon Sep 17 00:00:00 2001 From: Marcoen Hirschberg Date: Tue, 6 Dec 2005 13:27:15 +0000 Subject: waiting is over: initial unicode commit git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8169 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/lcd-16bit.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'firmware/drivers/lcd-16bit.c') diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index a4ae6cd553..582050c878 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c @@ -30,6 +30,7 @@ #include "debug.h" #include "system.h" #include "font.h" +#include "rbunicode.h" #include "bidi.h" #define SCROLLABLE_LINES 26 @@ -542,13 +543,13 @@ void lcd_bitmap(const fb_data *src, int x, int y, int width, int height) /* put a string at a given pixel position, skipping first ofs pixel columns */ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) { - int ch; + unsigned short ch; + unsigned short *ucs; struct font* pf = font_get(curfont); - if (bidi_support_enabled) - str = bidi_l2v(str, 1); + ucs = bidi_l2v(str, 1); - while ((ch = *str++) != '\0' && x < LCD_WIDTH) + while ((ch = *ucs++) != 0 && x < LCD_WIDTH) { int width; const unsigned char *bits; @@ -559,7 +560,7 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) ch -= pf->firstchar; /* get proportional width and glyph bits */ - width = pf->width ? pf->width[ch] : pf->maxwidth; + width = font_get_width(pf,ch); if (ofs > width) { @@ -567,8 +568,7 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) continue; } - bits = pf->bits + (pf->offset ? - pf->offset[ch] : ((pf->height + 7) / 8 * pf->maxwidth * ch)); + bits = font_get_bits(pf, ch); lcd_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, pf->height); @@ -597,7 +597,7 @@ void lcd_puts_style(int x, int y, const unsigned char *str, int style) return; lcd_getstringsize(str, &w, &h); - xpos = xmargin + x*w / strlen(str); + xpos = xmargin + x*w / utf8length(str); ypos = ymargin + y*h; lcd_putsxy(xpos, ypos, str); drawmode = (DRMODE_SOLID|DRMODE_INVERSEVID); @@ -707,7 +707,7 @@ void lcd_puts_scroll_style(int x, int y, const unsigned char *string, int style) end = strchr(s->line, '\0'); strncpy(end, string, LCD_WIDTH/2); - s->len = strlen(string); + s->len = utf8length(string); s->offset = 0; s->startx = x; s->backward = false; @@ -765,9 +765,11 @@ static void scroll_thread(void) } } else { - /* scroll forward the whole time */ - if (s->offset >= s->width) - s->offset %= s->width; + /* pause at beginning of line */ + if (s->offset >= s->width) { + s->offset = 0; + s->start_tick = current_tick + scroll_delay * 2; + } } lastmode = drawmode; -- cgit v1.2.3