Mercurial > mplayer.hg
changeset 29908:0ebce433be9e
Make fribidi (i.e. right-to-left) support work with embedded subtitles.
author | reimar |
---|---|
date | Sun, 22 Nov 2009 00:09:40 +0000 |
parents | a64beb99965b |
children | b9ac1a72aeb8 |
files | subreader.c |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/subreader.c Sat Nov 21 23:47:19 2009 +0000 +++ b/subreader.c Sun Nov 22 00:09:40 2009 +0000 @@ -1148,7 +1148,13 @@ #endif #ifdef CONFIG_FRIBIDI -static subtitle* sub_fribidi (subtitle *sub, int sub_utf8) +/** + * Do conversion necessary for right-to-left language support via fribidi. + * @param sub subtitle to convert + * @param sub_utf8 whether the subtitle is encoded in UTF-8 + * @param from first new subtitle, all lines before this are assumed to be already converted + */ +static subtitle* sub_fribidi (subtitle *sub, int sub_utf8, int from) { FriBidiChar logical[LINE_LEN+1], visual[LINE_LEN+1]; // Hopefully these two won't smash the stack char *ip = NULL, *op = NULL; @@ -1167,7 +1173,7 @@ }else { char_set_num = fribidi_parse_charset ("UTF-8"); } - while (l) { + while (l > from) { ip = sub->text[--l]; orig_len = len = strlen( ip ); // We assume that we don't use full unicode, only UTF-8 or ISO8859-x if(len > LINE_LEN) { @@ -1415,7 +1421,7 @@ if ((sub!=ERR) && (sub_utf8 & 2)) sub=subcp_recode(sub); #endif #ifdef CONFIG_FRIBIDI - if (sub!=ERR) sub=sub_fribidi(sub,sub_utf8); + if (sub!=ERR) sub=sub_fribidi(sub,sub_utf8,0); #endif if ( sub == ERR ) { @@ -2269,6 +2275,7 @@ int double_newline = 1; // ignore newlines at the beginning int i, pos; char *buf; + int orig_lines = sub->lines; if (sub->lines >= SUB_MAX_TEXT) return; pos = 0; buf = malloc(MAX_SUBLINE + 1); @@ -2313,6 +2320,9 @@ if (sub->lines < SUB_MAX_TEXT && strlen(sub->text[sub->lines])) sub->lines++; +#ifdef CONFIG_FRIBIDI + sub = sub_fribidi(sub, sub_utf8, orig_lines); +#endif } #define MP_NOPTS_VALUE (-1LL<<63)