swscale: all 4 planes must be set, even if alpha is dropped
[vlc.git] / include / vlc_text_style.h
blob9996002a0288e365dd6c853141ac1d7cdf5923bb
1 /*****************************************************************************
2 * vlc_text_style.h: text_style_t definition and helpers.
3 *****************************************************************************
4 * Copyright (C) 1999-2010 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Derk-Jan Hartman <hartman _AT_ videolan _DOT_ org>
8 * basOS G <noxelia 4t gmail , com>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef VLC_TEXT_STYLE_H
26 #define VLC_TEXT_STYLE_H 1
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
32 /**
33 * Text style
35 * A text style is used to specify the formatting of text.
36 * A font renderer can use the supplied information to render the
37 * text specified.
39 typedef struct
41 /* Family font names */
42 char * psz_fontname; /**< The name of the font */
43 char * psz_monofontname; /**< The name of the mono font */
45 uint16_t i_features; /**< Feature flags (means non default) */
46 uint16_t i_style_flags; /**< Formatting style flags */
48 /* Font style */
49 float f_font_relsize; /**< The font size in % */
50 int i_font_size; /**< The font size in pixels */
51 int i_font_color; /**< The color of the text 0xRRGGBB
52 (native endianness) */
53 uint8_t i_font_alpha; /**< The transparency of the text.*/
54 int i_spacing; /**< The spaceing between glyphs in pixels */
56 /* Outline */
57 int i_outline_color; /**< The color of the outline 0xRRGGBB */
58 uint8_t i_outline_alpha; /**< The transparency of the outline */
59 int i_outline_width; /**< The width of the outline in pixels */
61 /* Shadow */
62 int i_shadow_color; /**< The color of the shadow 0xRRGGBB */
63 uint8_t i_shadow_alpha; /**< The transparency of the shadow. */
64 int i_shadow_width; /**< The width of the shadow in pixels */
66 /* Background (and karaoke) */
67 int i_background_color;/**< The color of the background 0xRRGGBB */
68 uint8_t i_background_alpha;/**< The transparency of the background */
69 int i_karaoke_background_color;/**< Background color for karaoke 0xRRGGBB */
70 uint8_t i_karaoke_background_alpha;/**< The transparency of the karaoke bg */
71 } text_style_t;
73 #define STYLE_ALPHA_OPAQUE 0xFF
74 #define STYLE_ALPHA_TRANSPARENT 0x00
76 /* Features flags for \ref i_features */
77 #define STYLE_NO_DEFAULTS 0x0
78 #define STYLE_FULLY_SET 0xFFFF
79 #define STYLE_HAS_FONT_COLOR (1 << 0)
80 #define STYLE_HAS_FONT_ALPHA (1 << 1)
81 #define STYLE_HAS_FLAGS (1 << 2)
82 #define STYLE_HAS_OUTLINE_COLOR (1 << 3)
83 #define STYLE_HAS_OUTLINE_ALPHA (1 << 4)
84 #define STYLE_HAS_SHADOW_COLOR (1 << 5)
85 #define STYLE_HAS_SHADOW_ALPHA (1 << 6)
86 #define STYLE_HAS_BACKGROUND_COLOR (1 << 7)
87 #define STYLE_HAS_BACKGROUND_ALPHA (1 << 8)
88 #define STYLE_HAS_K_BACKGROUND_COLOR (1 << 9)
89 #define STYLE_HAS_K_BACKGROUND_ALPHA (1 << 10)
91 /* Style flags for \ref text_style_t */
92 #define STYLE_BOLD (1 << 0)
93 #define STYLE_ITALIC (1 << 1)
94 #define STYLE_OUTLINE (1 << 2)
95 #define STYLE_SHADOW (1 << 3)
96 #define STYLE_BACKGROUND (1 << 4)
97 #define STYLE_UNDERLINE (1 << 5)
98 #define STYLE_STRIKEOUT (1 << 6)
99 #define STYLE_HALFWIDTH (1 << 7)
100 #define STYLE_MONOSPACED (1 << 8)
102 #define STYLE_DEFAULT_FONT_SIZE 20
103 #define STYLE_DEFAULT_REL_FONT_SIZE 5.0
106 typedef struct text_segment_t text_segment_t;
108 * Text segment for subtitles
110 * This structure is used to store a formatted text, with mixed styles
111 * Every segment is comprised of one text and a unique style
113 * On style change, a new segment is created with the next part of text
114 * and the new style, and chained to the list
116 * Create with text_segment_New and clean the chain with
117 * text_segment_ChainDelete
119 struct text_segment_t {
120 char *psz_text; /**< text string of the segment */
121 text_style_t *style; /**< style applied to this segment */
122 text_segment_t *p_next; /**< next segment */
126 * Create a default text style
128 VLC_API text_style_t * text_style_New( void );
131 * Create a text style
133 * Set feature flags as argument if you want to set style defaults
135 VLC_API text_style_t * text_style_Create( int );
138 * Copy a text style into another
140 VLC_API text_style_t * text_style_Copy( text_style_t *, const text_style_t * );
143 * Duplicate a text style
145 VLC_API text_style_t * text_style_Duplicate( const text_style_t * );
148 * Merge two styles using non default values
150 * Set b_override to true if you also want to overwrite non-defaults
152 VLC_API void text_style_Merge( text_style_t *, const text_style_t *, bool b_override );
155 * Delete a text style created by text_style_New or text_style_Duplicate
157 VLC_API void text_style_Delete( text_style_t * );
160 * This function will create a new text segment.
162 * You should use text_segment_ChainDelete to destroy it, to clean all
163 * the linked segments, or text_segment_Delete to free a specic one
165 * This duplicates the string passed as argument
167 VLC_API text_segment_t *text_segment_New( const char * );
170 * This function will create a new text segment and duplicates the style passed as argument
172 * You should use text_segment_ChainDelete to destroy it, to clean all
173 * the linked segments, or text_segment_Delete to free a specic one
175 * This doesn't initialize the text.
177 VLC_API text_segment_t *text_segment_NewInheritStyle( const text_style_t* p_style );
180 * Delete a text segment and its content.
182 * This assumes the segment is not part of a chain
184 VLC_API void text_segment_Delete( text_segment_t * );
187 * This function will destroy a list of text segments allocated
188 * by text_segment_New.
190 * You may pass it NULL.
192 VLC_API void text_segment_ChainDelete( text_segment_t * );
195 * This function will copy a text_segment and its chain into a new one
197 * You may give it NULL, but it will return NULL.
199 VLC_API text_segment_t * text_segment_Copy( text_segment_t * );
201 #ifdef __cplusplus
203 #endif
205 #endif /* VLC_TEXT_STYLE_H */