From f1c9032ddf5eba1241d9616656b4c36bc4043283 Mon Sep 17 00:00:00 2001 From: Dan Oscarsson Date: Wed, 1 Feb 2017 13:19:09 +0100 Subject: sub: add justify of subtitles To make it easier for the eyes, multi line subtitles should be left justified (for most languages). This adds an option to define how subtitles are to be justified inpendently of how they are aligned. Also add option to enable --sub-justify to be applied on ASS subtitles. --- sub/ass_mp.c | 3 +++ sub/osd.c | 2 ++ sub/osd.h | 1 + sub/sd_ass.c | 4 ++++ 4 files changed, 10 insertions(+) (limited to 'sub') diff --git a/sub/ass_mp.c b/sub/ass_mp.c index 84a706b681..6d85ac1f28 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -78,6 +78,9 @@ void mp_ass_set_style(ASS_Style *style, double res_y, style->ScaleX = 1.; style->ScaleY = 1.; style->Alignment = 1 + (opts->align_x + 1) + (opts->align_y + 2) % 3 * 4; +#ifdef ASS_JUSTIFY_LEFT + style->Justify = opts->justify; +#endif style->Blur = opts->blur; style->Bold = opts->bold; style->Italic = opts->italic; diff --git a/sub/osd.c b/sub/osd.c index bf6233a0b1..a35380d99f 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -62,6 +62,8 @@ static const m_option_t style_opts[] = { OPT_FLOATRANGE("blur", blur, 0, 0, 20), OPT_FLAG("bold", bold, 0), OPT_FLAG("italic", italic, 0), + OPT_CHOICE("justify", justify, 0, + ({"auto", 0}, {"left", 1}, {"center", 2}, {"right", 3})), {0} }; diff --git a/sub/osd.h b/sub/osd.h index aef1c60b33..7572ec0360 100644 --- a/sub/osd.h +++ b/sub/osd.h @@ -134,6 +134,7 @@ struct osd_style_opts { float blur; int bold; int italic; + int justify; }; extern const struct m_sub_options osd_style_conf; diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 31c66a6087..9b4d3763c5 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -332,6 +332,10 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim, #if LIBASS_VERSION >= 0x01201001 if (converted) set_force_flags |= ASS_OVERRIDE_BIT_ALIGNMENT; +#endif +#ifdef ASS_JUSTIFY_AUTO + if ((converted || opts->ass_style_override) && opts->ass_justify) + set_force_flags |= ASS_OVERRIDE_BIT_JUSTIFY; #endif ass_set_selective_style_override_enabled(priv, set_force_flags); ASS_Style style = {0}; -- cgit v1.2.3