diff mbox series

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

Message ID 5fca566749053291c27a8f7df7a2b6240913850b.1642649134.git.ffmpegagent@gmail.com
State New
Headers show
Series Subtitle Filtering 2022 | expand

Checks

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

Commit Message

softworkz Jan. 20, 2022, 3:25 a.m. UTC
From: softworkz <softworkz@hotmail.com>

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 c0436f5739..48945dcb8e 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