diff options
| author | Teruaki Kawashima <teru@rockbox.org> | 2010-07-12 14:59:16 +0000 |
|---|---|---|
| committer | Teruaki Kawashima <teru@rockbox.org> | 2010-07-12 14:59:16 +0000 |
| commit | ddbfffb2173630b16b5ddafaa6449cad8709bf83 (patch) | |
| tree | 995b2c19565c1b5a12743288ee8c98283d334e73 /apps/plugins/lib/simple_viewer.c | |
| parent | 8e68e223a4a672060775493f253afc9e6d9c46f5 (diff) | |
| download | rockbox-ddbfffb2173630b16b5ddafaa6449cad8709bf83.zip rockbox-ddbfffb2173630b16b5ddafaa6449cad8709bf83.tar.gz rockbox-ddbfffb2173630b16b5ddafaa6449cad8709bf83.tar.bz2 rockbox-ddbfffb2173630b16b5ddafaa6449cad8709bf83.tar.xz | |
improve displaying of string containing diacritic characters. add some characters to determine the position to break line.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27401 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib/simple_viewer.c')
| -rw-r--r-- | apps/plugins/lib/simple_viewer.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/apps/plugins/lib/simple_viewer.c b/apps/plugins/lib/simple_viewer.c index 13fdc32..09144b6 100644 --- a/apps/plugins/lib/simple_viewer.c +++ b/apps/plugins/lib/simple_viewer.c @@ -39,6 +39,22 @@ struct view_info { int start; /* possition of first line in text */ }; +static bool isbrchr(const unsigned char *str, int len) +{ + const unsigned char *p = "!,-.:;? 、。!,.:;?―"; + if (isspace(*str)) + return true; + + while(*p) + { + int n = rb->utf8seek(p, 1); + if (len == n && !rb->strncmp(p, str, len)) + return true; + p += n; + } + return false; +} + static const char* get_next_line(const char *text, struct view_info *info) { const char *ptr = text; @@ -53,10 +69,13 @@ static const char* get_next_line(const char *text, struct view_info *info) #else unsigned short ch; n = ((long)rb->utf8decode(ptr, &ch) - (long)ptr); - w = rb->font_get_width(info->pf, ch); + if (rb->is_diacritic(ch, NULL)) + w = 0; + else + w = rb->font_get_width(info->pf, ch); #endif - if (isspace(*ptr)) - space = ptr+n; + if (isbrchr(ptr, n)) + space = ptr+(isspace(*ptr) || total + w <= info->vp.width? n: 0); if (*ptr == '\n') { ptr += n; |