[vlc-devel] [PATCH] Add support for monospace font in HTML renderer

Rafaël Carré funman at videolan.org
Tue Jan 1 23:03:24 CET 2013


Le 31/12/2012 16:01, Rafaël Carré a écrit :
> From: Devin Heitmueller <dheitmueller at kernellabs.com>
> 
> The EIA-608 decoder expects fonts to be rendered with a monospace font,
> so add the ability for decoders to make use of the "tt" tag, and tweak
> the EIA-608 decoder to use that tag.
> 

> +static int HandleTT(font_stack_t **p_fonts, const char *p_fontfamily )
> +{
> +    int        rv;
> +    char      *psz_fontname = NULL;
> +    uint32_t   i_font_color = 0xffffff;
> +    int        i_font_alpha = 255;
> +    uint32_t   i_karaoke_bg_color = 0x00ffffff;
> +    int        i_font_size  = 24;
> +
> +    /* Default all attributes to the top font in the stack -- in case not
> +     * all attributes are specified in the sub-font
> +     */
> +    if( VLC_SUCCESS == PeekFont( p_fonts,
> +                                 &psz_fontname,
> +                                 &i_font_size,
> +                                 &i_font_color,
> +                                 &i_karaoke_bg_color ))
> +    {
> +        if (psz_fontname)
> +            psz_fontname = strdup( psz_fontname );
> +    }
> +    i_font_alpha = (i_font_color >> 24) & 0xff;
> +    i_font_color &= 0x00ffffff;
> +
> +    /* Just keep all the parent's font attributes, but change to 
> +       a monospace font */
> +    free( psz_fontname );

Why do we need the strdup() above if it is to free() it immediately
after without using it ?

> +    psz_fontname = strdup(p_fontfamily);
> +
> +    rv = PushFont( p_fonts,
> +                   psz_fontname,
> +                   i_font_size,
> +                   (i_font_color & 0xffffff) | ((i_font_alpha & 0xff) << 24),
> +                   i_karaoke_bg_color );
> +
> +    free( psz_fontname );
> +
> +    return rv;
> +}



More information about the vlc-devel mailing list