From 2f6713bedeb77a7c058ce4954eb95ee7a2ca7119 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 11 Oct 2012 02:23:22 +0200 Subject: sub: enable sub-pos with libass The --sub-pos option and sub-pos property control the vertical position of a subtitle. Also change how sub-pos is handled in the old subtitle renderer (used with -no-ass). The new behavior doesn't render subtitles out of the screen if the subtitle is located near the top screen border and has too many lines. --- sub/osd_libass.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sub/osd_libass.c') diff --git a/sub/osd_libass.c b/sub/osd_libass.c index e770215ce6..9b0bbb01ab 100644 --- a/sub/osd_libass.c +++ b/sub/osd_libass.c @@ -345,8 +345,10 @@ void vo_update_text_sub(struct osd_state *osd, mp_osd_obj_t* obj) ASS_Style *style = obj->osd_track->styles + obj->osd_track->default_style; - style->MarginV = obj->osd_track->PlayResY * ((100 - sub_pos)/110.0); update_font_scale(obj->osd_track, style, text_font_scale_factor); +#if LIBASS_VERSION >= 0x01010000 + ass_set_line_position(osd->osd_render, 100 - sub_pos); +#endif char *text = talloc_strdup(NULL, ""); -- cgit v1.2.3 From 0ff7dd992fb06fa8a5cba0a895717787a615e7bb Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 13 Oct 2012 21:09:34 +0200 Subject: osd_libass: fix \n escapes Apparently libass can't be made to not interpret "\n" as escape. That means "\n" can't be printed literally. Use the same hack that was added to mplayer2 when that project merged osd_libass.c: add an invisible zero-width joiner character between "\" and "n". It seems U+FEFF is deprecated, because it has been redefined as BOM mark. Use U+2060, which seems to be the replacement. --- sub/osd_libass.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'sub/osd_libass.c') diff --git a/sub/osd_libass.c b/sub/osd_libass.c index 9b0bbb01ab..de9f31b2cb 100644 --- a/sub/osd_libass.c +++ b/sub/osd_libass.c @@ -233,14 +233,6 @@ static char *mangle_ass(const char *in) { char *res = talloc_strdup(NULL, ""); while (*in) { - if (in[0] == '\\' && strchr("nNh{}", in[1])) { - // Undo escaping, e.g. \{ -> \\{ - // Note that e.g. \\j still must be emitted as \\j - // (libass only understands the escapes listed in the strchr args) - res = talloc_asprintf_append_buffer(res, "\\\\%c", in[1]); - in += 2; - continue; - } // As used by osd_get_function_sym(). if (in[0] == '\xFF') { res = talloc_strdup_append_buffer(res, ASS_USE_OSD_FONT); @@ -252,6 +244,9 @@ static char *mangle_ass(const char *in) if (*in == '{') res = talloc_strdup_append_buffer(res, "\\"); res = talloc_strndup_append_buffer(res, in, 1); + // Break ASS escapes with U+2060 WORD JOINER + if (*in == '\\') + append_utf8_buffer(res, 0x2060); in++; } return res; -- cgit v1.2.3