mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/ass,webvttdec: implement more portable curly brace escapes
Unlike what the old comment suggested, standard ASS has no character escape mechanism, but a closing curly bracket doesn't even need one. For manual authored sub files using a full-width variant of an appropriate font and with scaling and spacing modifiers is a common workaround. This is not an option here, but we can still make things much less bad. Now the desired opening bracket still shows up in libass, and standard renders will merely display a backslash in its place instead of stripping the following text like before.
This commit is contained in:
parent
baa64fa4e6
commit
0fc975c0d3
|
@ -181,10 +181,14 @@ void ff_ass_bprint_text_event(AVBPrint *buf, const char *p, int size,
|
|||
if (linebreaks && strchr(linebreaks, *p)) {
|
||||
av_bprintf(buf, "\\N");
|
||||
|
||||
/* standard ASS escaping so random characters don't get mis-interpreted
|
||||
* as ASS */
|
||||
} else if (!keep_ass_markup && strchr("{}", *p)) {
|
||||
av_bprintf(buf, "\\%c", *p);
|
||||
/* cancel curly brackets to avoid bogus override tag blocks
|
||||
* hiding text. Standard ASS has no character escapes,
|
||||
* though (only) libass provides \{ and \}.
|
||||
* Unpaired closing brackets don't need escaping at all though and
|
||||
* to make the situation less bad in standard ASS insert an empty block
|
||||
*/
|
||||
} else if (!keep_ass_markup && *p == '{') {
|
||||
av_bprintf(buf, "\\{{}");
|
||||
|
||||
/* append word-joiner U+2060 as UTF-8 to break up sequences like \N */
|
||||
} else if (!keep_ass_markup && *p == '\\') {
|
||||
|
|
|
@ -37,7 +37,7 @@ static const struct {
|
|||
{"<i>", "{\\i1}"}, {"</i>", "{\\i0}"},
|
||||
{"<b>", "{\\b1}"}, {"</b>", "{\\b0}"},
|
||||
{"<u>", "{\\u1}"}, {"</u>", "{\\u0}"},
|
||||
{"{", "\\{"}, {"}", "\\}"}, {"\\", "\\\xe2\x81\xa0"}, // escape to avoid ASS markup conflicts
|
||||
{"{", "\\{{}"}, {"\\", "\\\xe2\x81\xa0"}, // escape to avoid ASS markup conflicts
|
||||
{">", ">"}, {"<", "<"},
|
||||
{"‎", "\xe2\x80\x8e"}, {"‏", "\xe2\x80\x8f"},
|
||||
{"&", "&"}, {" ", "\\h"},
|
||||
|
|
|
@ -21,7 +21,7 @@ Dialogue: 0,0:00:22.00,0:00:24.00,Default,,0,0,0,,at the AMNH.
|
|||
Dialogue: 0,0:00:24.00,0:00:26.00,Default,,0,0,0,,Thank you for walking down here.
|
||||
Dialogue: 0,0:00:27.00,0:00:30.00,Default,,0,0,0,,And I want to do a follow-up on the last conversation we did.\Nmultiple lines\Nagain
|
||||
Dialogue: 0,0:00:30.00,0:00:31.50,Default,,0,0,0,,When we e-mailed—
|
||||
Dialogue: 0,0:00:30.50,0:00:32.50,Default,,0,0,0,,Didn't we {\b1}talk {\i1}about\N{\i0} enough{\b0} in that conversation? \{I'm not an ASS comment\}
|
||||
Dialogue: 0,0:00:30.50,0:00:32.50,Default,,0,0,0,,Didn't we {\b1}talk {\i1}about\N{\i0} enough{\b0} in that conversation? \{{}I'm not an ASS comment}
|
||||
Dialogue: 0,0:00:32.00,0:00:35.50,Default,,0,0,0,,No! No no no no; 'cos 'cos obviously 'cos
|
||||
Dialogue: 0,0:00:32.50,0:00:33.50,Default,,0,0,0,,{\i1}Laughs{\i0}
|
||||
Dialogue: 0,0:00:35.50,0:00:38.00,Default,,0,0,0,,You know I'm so excited my glasses are falling off here.
|
||||
|
|
Loading…
Reference in New Issue