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

Hugo Beauzée-Luyssen hugo at beauzee.fr
Thu Jan 26 09:45:44 CET 2017


On 01/25/2017 08:46 PM, Jean-Baptiste Kempf wrote:
> 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 )

I don't think you need to check the style for NULLity.

> +        segment->style = style;
>      return segment;
>  }
>
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits
>



More information about the vlc-devel mailing list