mirror of
https://github.com/mpv-player/mpv
synced 2025-01-01 12:22:22 +00:00
Make fribidi (i.e. right-to-left) support work with embedded subtitles.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29950 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
4a89d76451
commit
03e99c5cb8
16
subreader.c
16
subreader.c
@ -1148,7 +1148,13 @@ subtitle* subcp_recode (subtitle *sub)
|
||||
#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 @@ static subtitle* sub_fribidi (subtitle *sub, int sub_utf8)
|
||||
}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 @@ sub_data* sub_read_file (char *filename, float fps) {
|
||||
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 @@ void sub_add_text(subtitle *sub, const char *txt, int len, double endpts) {
|
||||
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 @@ void sub_add_text(subtitle *sub, const char *txt, int len, double endpts) {
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user