diff mbox series

[FFmpeg-devel,v22,23/23] avcodec/webvttenc: convert hard-space tags to  

Message ID DM8P223MB03658240E3FFFD5603152E9DBA709@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM
State Superseded, archived
Headers show
Series [FFmpeg-devel,v22,01/23] avcodec, avutil: Move enum AVSubtitleType to avutil, add new and deprecate old values | expand

Checks

Context Check Description
andriy/configurex86 warning Failed to apply patch
andriy/configureppc warning Failed to apply patch

Commit Message

Soft Works Dec. 9, 2021, 12:13 p.m. UTC
Signed-off-by: softworkz <softworkz@hotmail.com>
---
 libavcodec/webvttenc.c       |  6 ++++++
 tests/ref/fate/sub-webvttenc | 10 +++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c
index 43dace6575..a4997969ee 100644
--- a/libavcodec/webvttenc.c
+++ b/libavcodec/webvttenc.c
@@ -123,6 +123,11 @@  static void webvtt_new_line_cb(void *priv, int forced)
     webvtt_print(priv, "\n");
 }
 
+static void webvtt_hard_space_cb(void *priv)
+{
+    webvtt_print(priv, "&nbsp;");
+}
+
 static void webvtt_style_cb(void *priv, char style, int close)
 {
     if (style == 's') // strikethrough unsupported
@@ -147,6 +152,7 @@  static void webvtt_end_cb(void *priv)
 static const ASSCodesCallbacks webvtt_callbacks = {
     .text             = webvtt_text_cb,
     .new_line         = webvtt_new_line_cb,
+    .hard_space       = webvtt_hard_space_cb,
     .style            = webvtt_style_cb,
     .color            = NULL,
     .font_name        = NULL,
diff --git a/tests/ref/fate/sub-webvttenc b/tests/ref/fate/sub-webvttenc
index f4172dcc84..ee9de2859e 100644
--- a/tests/ref/fate/sub-webvttenc
+++ b/tests/ref/fate/sub-webvttenc
@@ -132,26 +132,26 @@  but show this: {normal text}
 \ N is a forced line break
 \ h is a hard space
 Normal spaces at the start and at the end of the line are trimmed while hard spaces are not trimmed.
-The line will never break automatically right before or after a hard space. :-D
+The&nbsp;line&nbsp;will&nbsp;never&nbsp;break&nbsp;automatically&nbsp;right&nbsp;before&nbsp;or&nbsp;after&nbsp;a&nbsp;hard&nbsp;space.&nbsp;:-D
 
 00:54.501 --> 00:56.500
 
-     A (05 hard spaces followed by a letter)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A (05 hard spaces followed by a letter)
 A (Normal  spaces followed by a letter)
 A (No hard spaces followed by a letter)
 
 00:56.501 --> 00:58.500
-     A (05 hard spaces followed by a letter)
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A (05 hard spaces followed by a letter)
 A (Normal  spaces followed by a letter)
 A (No hard spaces followed by a letter)
 Show this: \TEST and this: \-)
 
 00:58.501 --> 01:00.500
 
-A letter followed by 05 hard spaces: A     
+A letter followed by 05 hard spaces: A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 A letter followed by normal  spaces: A
 A letter followed by no hard spaces: A
-05 hard  spaces between letters: A     A
+05 hard  spaces between letters: A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A
 5 normal spaces between letters: A     A
 
 ^--Forced line break