[vlc-commits] STL: handle italics/underline styles

Jean-Baptiste Kempf git at videolan.org
Wed Jan 25 20:46:50 CET 2017


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed Jan 25 20:44:56 2017 +0100| [6b58d87b85f2629e4fe24a3c76d200c197d6cf67] | committer: Jean-Baptiste Kempf

STL: handle italics/underline styles

The support is not 100% complete, but we lack samples

Close #10910

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6b58d87b85f2629e4fe24a3c76d200c197d6cf67
---

 modules/codec/stl.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/modules/codec/stl.c b/modules/codec/stl.c
index cc610da..fa0608e 100644
--- a/modules/codec/stl.c
+++ b/modules/codec/stl.c
@@ -80,6 +80,7 @@ static cct_number_t cct_nums[] = { {CCT_ISO_6937_2, "ISO_6937-2"},
 
 static text_segment_t *ParseText(const uint8_t *data, size_t size, const char *charset)
 {
+    text_style_t *style = NULL;
     char *text = malloc(size);
     if (text == NULL)
         return NULL;
@@ -93,16 +94,29 @@ static text_segment_t *ParseText(const uint8_t *data, size_t size, const char *c
             break;
         if (code == 0x7f)
             continue;
-        /* TODO: italics begin/end 0x80/0x81, underline being/end 0x82/0x83 */
         if (code & 0x60)
             text[text_size++] = code;
+        /* italics begin/end 0x80/0x81, underline being/end 0x82/0x83
+         * TODO: handle the endings */
+        if (code == 0x80 || code == 0x82 )
+        {
+            style = text_style_Create( STYLE_NO_DEFAULTS );
+            if (code == 0x80)
+                style->i_style_flags |= STYLE_ITALIC;
+            if (code == 0x82)
+                style->i_style_flags |= STYLE_UNDERLINE;
+            style->i_features |= STYLE_HAS_FLAGS;
+        }
         if (code == 0x8a)
             text[text_size++] = '\n';
     }
 
     char *u8 = FromCharset(charset, text, text_size);
     free(text);
+
     text_segment_t *segment = text_segment_New( u8 );
+    if( style )
+        segment->style = style;
     return segment;
 }
 



More information about the vlc-commits mailing list