]> git.sesse.net Git - vlc/blob - modules/text_renderer/text_renderer.h
mux: avi: fix leak on format failure
[vlc] / modules / text_renderer / text_renderer.h
1 /*****************************************************************************
2  * text_renderer.h : fonts, text styles helpers
3  *****************************************************************************
4  * Copyright (C) 2002 - 2013 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
8  *          Gildas Bazin <gbazin@videolan.org>
9  *          Bernie Purcell <bitmap@videolan.org>
10  *          Jean-Baptiste Kempf <jb@videolan.org>
11  *          Felix Paul Kühne <fkuehne@videolan.org>
12  *
13  * This program is free software; you can redistribute it and/or modify it
14  * under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation; either version 2.1 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License
24  * along with this program; if not, write to the Free Software Foundation, Inc.,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26  *****************************************************************************/
27
28 #include <vlc_text_style.h>                                   /* text_style_t*/
29
30 /* fonts and font_stack_t functions */
31 typedef struct font_stack_t font_stack_t;
32 struct font_stack_t
33 {
34     char          *psz_name;
35     int            i_size;
36     uint32_t       i_color;            /* ARGB */
37     uint32_t       i_karaoke_bg_color; /* ARGB */
38
39     font_stack_t  *p_next;
40 };
41
42 int PushFont( font_stack_t **p_font, const char *psz_name, int i_size,
43               uint32_t i_color, uint32_t i_karaoke_bg_color );
44
45 int PopFont( font_stack_t **p_font );
46
47 int PeekFont( font_stack_t **p_font, char **psz_name, int *i_size,
48               uint32_t *i_color, uint32_t *i_karaoke_bg_color );
49
50 int HandleFontAttributes( xml_reader_t *p_xml_reader,
51                           font_stack_t **p_fonts );
52
53 int HandleTT(font_stack_t **p_fonts, const char *p_fontfamily );
54
55 /* Turn any multiple-whitespaces into single spaces */
56 void HandleWhiteSpace( char *psz_node );
57
58 /* text_style_t functions */
59 text_style_t *CreateStyle( char *psz_fontname, int i_font_size,
60                            uint32_t i_font_color, uint32_t i_karaoke_bg_color,
61                            int i_style_flags );
62
63 text_style_t *GetStyleFromFontStack( filter_t *p_filter,
64                                      font_stack_t **p_fonts,
65                                      text_style_t *style,
66                                      int i_style_flags );
67
68 #ifdef __OS2__
69 typedef uint16_t uni_char_t;
70 # define FREETYPE_TO_UCS    "UCS-2LE"
71 #else
72 typedef uint32_t uni_char_t;
73 # if defined(WORDS_BIGENDIAN)
74 #  define FREETYPE_TO_UCS   "UCS-4BE"
75 # else
76 #  define FREETYPE_TO_UCS   "UCS-4LE"
77 # endif
78 #endif
79
80 unsigned SetupText( filter_t *p_filter,
81                     uni_char_t *psz_text_out,
82                     text_style_t **pp_styles,
83                     uint32_t *pi_k_dates,
84                     const char *psz_text_in,
85                     text_style_t *p_style,
86                     uint32_t i_k_date );
87
88 bool FaceStyleEquals( const text_style_t *p_style1,
89                       const text_style_t *p_style2 );
90
91 /* Parser */
92 int ProcessNodes( filter_t *p_filter,
93                          uni_char_t *psz_text,
94                          text_style_t **pp_styles,
95                          uint32_t *pi_k_dates,
96                          int *pi_len,
97                          xml_reader_t *p_xml_reader,
98                          text_style_t *p_font_style,
99                          text_style_t *p_default_style );