diff options
| author | Marcoen Hirschberg <marcoen@gmail.com> | 2006-03-22 09:53:27 +0000 |
|---|---|---|
| committer | Marcoen Hirschberg <marcoen@gmail.com> | 2006-03-22 09:53:27 +0000 |
| commit | d257683f3edbb0a2b819b27d34c2708809d3d57d (patch) | |
| tree | 94ad35018c304fa345f1b1963cc49493086b39a5 | |
| parent | d0e8c57b779bbf96d84c5251465dc92303df5424 (diff) | |
| download | rockbox-d257683f3edbb0a2b819b27d34c2708809d3d57d.zip rockbox-d257683f3edbb0a2b819b27d34c2708809d3d57d.tar.gz rockbox-d257683f3edbb0a2b819b27d34c2708809d3d57d.tar.bz2 rockbox-d257683f3edbb0a2b819b27d34c2708809d3d57d.tar.xz | |
font caching fixes by Frank Dischner
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9178 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/drivers/lcd-16bit.c | 5 | ||||
| -rw-r--r-- | firmware/drivers/lcd-2bit-horz.c | 5 | ||||
| -rw-r--r-- | firmware/drivers/lcd-h100-remote.c | 5 | ||||
| -rw-r--r-- | firmware/drivers/lcd-h100.c | 5 | ||||
| -rw-r--r-- | firmware/drivers/lcd-recorder.c | 5 | ||||
| -rw-r--r-- | firmware/font.c | 29 |
6 files changed, 20 insertions, 34 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index 08e62b8..e98403a 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c @@ -735,11 +735,6 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) int width; const unsigned char *bits; - /* 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 = font_get_width(pf,ch); diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c index a76ebe1..bfb69da 100644 --- a/firmware/drivers/lcd-2bit-horz.c +++ b/firmware/drivers/lcd-2bit-horz.c @@ -703,11 +703,6 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) int width; const unsigned char *bits; - /* 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 = font_get_width(pf,ch); diff --git a/firmware/drivers/lcd-h100-remote.c b/firmware/drivers/lcd-h100-remote.c index 58953f6..ffe6f14 100644 --- a/firmware/drivers/lcd-h100-remote.c +++ b/firmware/drivers/lcd-h100-remote.c @@ -1117,11 +1117,6 @@ static void lcd_remote_putsxyofs(int x, int y, int ofs, const unsigned char *str int width; const unsigned char *bits; - /* 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 = font_get_width(pf, ch); diff --git a/firmware/drivers/lcd-h100.c b/firmware/drivers/lcd-h100.c index 1d80458..8a06367 100644 --- a/firmware/drivers/lcd-h100.c +++ b/firmware/drivers/lcd-h100.c @@ -1033,11 +1033,6 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) int width; const unsigned char *bits; - /* 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 = font_get_width(pf,ch); diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index 7a44acf..89b041d 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c @@ -886,11 +886,6 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) int width; const unsigned char *bits; - /* 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 = font_get_width(pf,ch); diff --git a/firmware/font.c b/firmware/font.c index d45c0e8..5f244bc 100644 --- a/firmware/font.c +++ b/firmware/font.c @@ -389,10 +389,6 @@ int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber) for (str = utf8decode(str, &ch); ch != 0 ; str = utf8decode(str, &ch)) { - /* 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 += font_get_width(pf,ch); @@ -467,6 +463,11 @@ static void cache_create(int maxwidth, int height) */ int font_get_width(struct font* pf, unsigned short char_code) { + /* check input range*/ + if (char_code < pf->firstchar || char_code >= pf->firstchar+pf->size) + char_code = pf->defaultchar; + char_code -= pf->firstchar; + return (fnt_file >= 0 && pf != &sysfont)? font_cache_get(&font_cache_ui,char_code,load_cache_entry,pf)->width: pf->width? pf->width[char_code]: pf->maxwidth; @@ -475,6 +476,12 @@ int font_get_width(struct font* pf, unsigned short char_code) const unsigned char* font_get_bits(struct font* pf, unsigned short char_code) { const unsigned char* bits; + + /* check input range*/ + if (char_code < pf->firstchar || char_code >= pf->firstchar+pf->size) + char_code = pf->defaultchar; + char_code -= pf->firstchar; + if (fnt_file >= 0 && pf != &sysfont) { bits = @@ -493,11 +500,15 @@ const unsigned char* font_get_bits(struct font* pf, unsigned short char_code) void glyph_file_write(void* data) { struct font_cache_entry* p = data; + struct font* pf = &font_ui; + unsigned short ch; unsigned char tmp[2]; - if (p->_char_code != 0xffff && glyph_file >= 0) { - tmp[0] = p->_char_code >> 8; - tmp[1] = p->_char_code & 0xff; + ch = p->_char_code + pf->firstchar; + + if (ch != 0xffff && glyph_file >= 0) { + tmp[0] = ch >> 8; + tmp[1] = ch & 0xff; if (write(glyph_file, tmp, 2) != 2) { close(glyph_file); glyph_file = -1; @@ -545,8 +556,8 @@ void glyph_cache_load(void) close(fd); } else { /* load latin1 chars into cache */ - ch = 255 - pf->firstchar; - while (ch--) + ch = 256; + while (ch-- > 32) font_get_bits(pf, ch); } } |