From 0b8b64fba312d53ae72974618e2e7f191afa0d00 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 30 Oct 2017 21:15:09 +0100 Subject: osd: don't strip leading whitespace in messages Do this by replacing the first space after a line break with "\h". --- sub/osd_libass.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sub/osd_libass.c b/sub/osd_libass.c index 046007d66b..ce1a3cddb4 100644 --- a/sub/osd_libass.c +++ b/sub/osd_libass.c @@ -190,6 +190,7 @@ void osd_get_function_sym(char *buffer, size_t buffer_size, int osd_function) static void mangle_ass(bstr *dst, const char *in) { + const char *start = in; bool escape_ass = true; while (*in) { // As used by osd_get_function_sym(). @@ -207,6 +208,12 @@ static void mangle_ass(bstr *dst, const char *in) } if (escape_ass && *in == '{') bstr_xappend(NULL, dst, bstr0("\\")); + // Libass will strip leading whitespace + if (in[0] == ' ' && in != start && in[-1] == '\n') { + bstr_xappend(NULL, dst, bstr0("\\h")); + in += 1; + continue; + } bstr_xappend(NULL, dst, (bstr){(char *)in, 1}); // Break ASS escapes with U+2060 WORD JOINER if (escape_ass && *in == '\\') -- cgit v1.2.3