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/lrcplayer.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/lrcplayer.c')
| -rw-r--r-- | apps/plugins/lrcplayer.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/apps/plugins/lrcplayer.c b/apps/plugins/lrcplayer.c index 7cc9f92..cf5c07b 100644 --- a/apps/plugins/lrcplayer.c +++ b/apps/plugins/lrcplayer.c @@ -415,6 +415,24 @@ static const char *lrc_skip_space(const char *str) return str; } +#ifdef HAVE_LCD_BITMAP +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; +} +#endif + /* calculate how many lines is needed to display and store it. * create cache if there is enough space in lrc_buffer. */ static struct lrc_brpos *calc_brpos(struct lrc_line *lrc_line, int i) @@ -518,17 +536,28 @@ static struct lrc_brpos *calc_brpos(struct lrc_line *lrc_line, int i) w = 1; #else c = ((long)rb->utf8decode(cr.str, &ch) - (long)cr.str); - w = rb->font_get_width(pf, ch); - if (cr.count && isspace(*cr.str)) + if (rb->is_diacritic(ch, NULL)) + w = 0; + else + w = rb->font_get_width(pf, ch); + if (cr.count && prefs.wrap && isbrchr(cr.str, c)) { /* remember position of last space */ rb->memcpy(&sp, &cr, sizeof(struct snap)); sp.word_count = lrc_word->count; sp.word_width = lrc_word->width; + if (!isspace(*cr.str) && cr.width+w <= vp_lyrics[i].width) + { + sp.count += c; + sp.width += w; + sp.word_count += c; + sp.word_width += w; + sp.str += c; + } } if (cr.count && cr.width+w > vp_lyrics[i].width) { - if (prefs.wrap && sp.str != NULL) /* wrap */ + if (sp.str != NULL) /* wrap */ { rb->memcpy(&cr, &sp, sizeof(struct snap)); lrc_word = lrc_line->words+cr.nword; |