VLC 4.0.0-dev
Loading...
Searching...
No Matches
vlc_text_style.h
Go to the documentation of this file.
1/*****************************************************************************
2 * vlc_text_style.h: text_style_t definition and helpers.
3 *****************************************************************************
4 * Copyright (C) 1999-2010 VLC authors and VideoLAN
5 *
6 * Authors: Derk-Jan Hartman <hartman _AT_ videolan _DOT_ org>
7 * basOS G <noxelia 4t gmail , com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
23
24#ifndef VLC_TEXT_STYLE_H
25#define VLC_TEXT_STYLE_H 1
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32 * Text style
33 *
34 * A text style is used to specify the formatting of text.
35 * A font renderer can use the supplied information to render the
36 * text specified.
37 */
38typedef struct
40 /* Family font names */
41 char * psz_fontname; /**< The name of the font */
42 char * psz_monofontname; /**< The name of the mono font */
44 uint16_t i_features; /**< Feature flags (means non default) */
45 uint16_t i_style_flags; /**< Formatting style flags */
47 /* Font style */
48 float f_font_relsize; /**< The font size in video height % */
49 int i_font_size; /**< The font size in pixels */
50 uint32_t i_font_color; /**< The color of the text in XRGB */
51 uint8_t i_font_alpha; /**< The transparency of the text.*/
52 int i_spacing; /**< The spaceing between glyphs in pixels */
54 /* Outline */
55 uint32_t i_outline_color; /**< The color of the outline in XRGB */
56 uint8_t i_outline_alpha; /**< The transparency of the outline */
57 int i_outline_width; /**< The width of the outline in pixels */
59 /* Shadow */
60 uint32_t i_shadow_color; /**< The color of the shadow in XRGB */
61 uint8_t i_shadow_alpha; /**< The transparency of the shadow. */
62 int i_shadow_width; /**< The width of the shadow in pixels */
64 /* Background */
65 uint32_t i_background_color;/**< The color of the background in XRGB */
66 uint8_t i_background_alpha;/**< The transparency of the background */
68 /* Line breaking */
69 enum
70 {
71 STYLE_WRAP_DEFAULT = 0, /**< Breaks on whitespace or fallback on char */
72 STYLE_WRAP_CHAR, /**< Breaks at character level only */
73 STYLE_WRAP_NONE, /**< No line breaks (except explicit ones) */
74 } e_wrapinfo;
76 /*blending style*/
77 enum
78 {
79 STYLE_BLENDING_DEFAULT = 0, /**< Overlay blending style>**/
80 STYLE_BLENDING_TRANSPARENT, /**< Knockout blending style>**/
81 } e_blending_mode;
83
84#define STYLE_ALPHA_OPAQUE 0xFF
85#define STYLE_ALPHA_TRANSPARENT 0x00
87/* Features flags for \ref i_features */
88#define STYLE_NO_DEFAULTS 0x0
89#define STYLE_FULLY_SET 0xFFFF
90#define STYLE_HAS_FONT_COLOR (1 << 0)
91#define STYLE_HAS_FONT_ALPHA (1 << 1)
92#define STYLE_HAS_FLAGS (1 << 2)
93#define STYLE_HAS_OUTLINE_COLOR (1 << 3)
94#define STYLE_HAS_OUTLINE_ALPHA (1 << 4)
95#define STYLE_HAS_SHADOW_COLOR (1 << 5)
96#define STYLE_HAS_SHADOW_ALPHA (1 << 6)
97#define STYLE_HAS_BACKGROUND_COLOR (1 << 7)
98#define STYLE_HAS_BACKGROUND_ALPHA (1 << 8)
99#define STYLE_HAS_WRAP_INFO (1 << 9)
100#define STYLE_HAS_BLENDING_MODE (1 << 10)
102/* Style flags for \ref text_style_t */
103#define STYLE_BOLD (1 << 0)
104#define STYLE_ITALIC (1 << 1)
105#define STYLE_OUTLINE (1 << 2)
106#define STYLE_SHADOW (1 << 3)
107#define STYLE_BACKGROUND (1 << 4)
108#define STYLE_UNDERLINE (1 << 5)
109#define STYLE_STRIKEOUT (1 << 6)
110#define STYLE_HALFWIDTH (1 << 7)
111#define STYLE_MONOSPACED (1 << 8)
112#define STYLE_DOUBLEWIDTH (1 << 9)
113#define STYLE_BLINK_FOREGROUND (1 << 10)
114#define STYLE_BLINK_BACKGROUND (1 << 11)
116#define STYLE_DEFAULT_FONT_SIZE 20
117#define STYLE_DEFAULT_REL_FONT_SIZE 6.25
119
120typedef struct text_segment_t text_segment_t;
123/**
124 * Text segment ruby for subtitles
125 * Each ruby has an anchor to the segment char.
126 */
134/**
135 * Text segment for subtitles
136 *
137 * This structure is used to store a formatted text, with mixed styles
138 * Every segment is comprised of one text and a unique style
139 *
140 * On style change, a new segment is created with the next part of text
141 * and the new style, and chained to the list
142 *
143 * Create with text_segment_New and clean the chain with
144 * text_segment_ChainDelete
145 */
146struct text_segment_t {
147 char *psz_text; /**< text string of the segment */
148 text_style_t *style; /**< style applied to this segment */
149 text_segment_t *p_next; /**< next segment */
150 text_segment_ruby_t *p_ruby; /**< ruby descriptions */
152
153/**
154 * Create a default text style
155 */
157
158/**
159 * Create a text style
160 *
161 * Give STYLE_NO_DEFAULTS as the argument if you want only the zero-filled
162 * object. Give STYLE_FULLY_SET (or anything other than STYLE_NO_DEFAULTS)
163 * if you want an object with sensible defaults. (The value is not stored,
164 * the only effect is to determine whether to return a zero-filled or
165 * sensible-defaults-filled object).
166 */
168
169/**
170 * Copy a text style into another
171 */
173
174/**
175 * Duplicate a text style
176 */
178
179/**
180 * Merge two styles using non default values
181 *
182 * Set b_override to true if you also want to overwrite non-defaults
183 */
184VLC_API void text_style_Merge( text_style_t *, const text_style_t *, bool b_override );
185
186/**
187 * Delete a text style created by text_style_New or text_style_Duplicate
188 */
190
191/**
192 * This function will create a new text segment.
193 *
194 * You should use text_segment_ChainDelete to destroy it, to clean all
195 * the linked segments, or text_segment_Delete to free a specific one
196 *
197 * This duplicates the string passed as argument
198 */
200
201/**
202 * This function will create a new text segment and duplicates the style passed as argument
203 *
204 * You should use text_segment_ChainDelete to destroy it, to clean all
205 * the linked segments, or text_segment_Delete to free a specific one
206 *
207 * This doesn't initialize the text.
208 */
210
211/**
212 * Delete a text segment and its content.
213 *
214 * This assumes the segment is not part of a chain
215 */
217
218/**
219 * This function will destroy a list of text segments allocated
220 * by text_segment_New.
221 *
222 * You may pass it NULL.
223 */
225
226/**
227 * This function will copy a text_segment and its chain into a new one
228 *
229 * You may give it NULL, but it will return NULL.
230 */
232
233/**
234 * This function will create a ruby section for a text_segment
235 *
236 */
238 const char *psz_rt );
239
240/**
241 * Deletes a ruby sections chain
242 */
244
245/**
246 * This function creates a text segment from a ruby section,
247 * and creates fallback string.
248 */
250
251/**
252 * Returns an integer representation of an HTML color.
253 *
254 * @param psz_value An HTML color, which can be either:
255 * - A standard HTML color (red, cyan, ...) as defined in p_html_colors
256 * - An hexadecimal color, of the form [#]RRGGBB[AA]
257 * - A decimal-based color, of the form rgb(RRR,GGG,BBB) or rgba(RRR,GGG,BBB,AAA)
258 * @param ok If non-null, true will be stored in this pointer to signal
259 * a successful conversion
260 */
261VLC_API unsigned int vlc_html_color( const char *psz_value, bool* ok );
262
263#ifdef __cplusplus
264}
265#endif
266
267#endif /* VLC_TEXT_STYLE_H */
#define VLC_API
Definition fourcc_gen.c:31
Text segment ruby for subtitles Each ruby has an anchor to the segment char.
Definition vlc_text_style.h:129
char * psz_base
Definition vlc_text_style.h:130
text_segment_ruby_t * p_next
Definition vlc_text_style.h:132
char * psz_rt
Definition vlc_text_style.h:131
Text segment for subtitles.
Definition vlc_text_style.h:147
text_segment_ruby_t * p_ruby
ruby descriptions
Definition vlc_text_style.h:151
text_segment_t * p_next
next segment
Definition vlc_text_style.h:150
char * psz_text
text string of the segment
Definition vlc_text_style.h:148
text_style_t * style
style applied to this segment
Definition vlc_text_style.h:149
Text style.
Definition vlc_text_style.h:40
uint8_t i_outline_alpha
The transparency of the outline.
Definition vlc_text_style.h:57
@ STYLE_WRAP_CHAR
Breaks at character level only.
Definition vlc_text_style.h:73
@ STYLE_WRAP_DEFAULT
Breaks on whitespace or fallback on char.
Definition vlc_text_style.h:72
@ STYLE_WRAP_NONE
No line breaks (except explicit ones).
Definition vlc_text_style.h:74
uint16_t i_features
Feature flags (means non default).
Definition vlc_text_style.h:45
int i_spacing
The spaceing between glyphs in pixels.
Definition vlc_text_style.h:53
uint16_t i_style_flags
Formatting style flags.
Definition vlc_text_style.h:46
uint32_t i_font_color
The color of the text in XRGB.
Definition vlc_text_style.h:51
uint8_t i_shadow_alpha
The transparency of the shadow.
Definition vlc_text_style.h:62
char * psz_fontname
The name of the font.
Definition vlc_text_style.h:42
uint32_t i_shadow_color
The color of the shadow in XRGB.
Definition vlc_text_style.h:61
uint32_t i_outline_color
The color of the outline in XRGB.
Definition vlc_text_style.h:56
int i_outline_width
The width of the outline in pixels.
Definition vlc_text_style.h:58
float f_font_relsize
The font size in video height %.
Definition vlc_text_style.h:49
int i_shadow_width
The width of the shadow in pixels.
Definition vlc_text_style.h:63
char * psz_monofontname
The name of the mono font.
Definition vlc_text_style.h:43
uint32_t i_background_color
The color of the background in XRGB.
Definition vlc_text_style.h:66
int i_font_size
The font size in pixels.
Definition vlc_text_style.h:50
uint8_t i_background_alpha
The transparency of the background.
Definition vlc_text_style.h:67
uint8_t i_font_alpha
The transparency of the text.
Definition vlc_text_style.h:52
@ STYLE_BLENDING_TRANSPARENT
Knockout blending style>.
Definition vlc_text_style.h:81
@ STYLE_BLENDING_DEFAULT
Overlay blending style>.
Definition vlc_text_style.h:80
This file is a collection of common definitions and types.
text_style_t * text_style_New(void)
Create a default text style.
Definition text_style.c:208
text_style_t * text_style_Duplicate(const text_style_t *)
Duplicate a text style.
Definition text_style.c:312
text_style_t * text_style_Create(int)
Create a text style.
Definition text_style.c:213
text_segment_t * text_segment_New(const char *)
This function will create a new text segment.
Definition text_style.c:375
text_segment_t * text_segment_Copy(text_segment_t *)
This function will copy a text_segment and its chain into a new one.
Definition text_style.c:447
void text_style_Delete(text_style_t *)
Delete a text style created by text_style_New or text_style_Duplicate.
Definition text_style.c:323
void text_segment_Delete(text_segment_t *)
Delete a text segment and its content.
Definition text_style.c:424
text_segment_ruby_t * text_segment_ruby_New(const char *psz_base, const char *psz_rt)
This function will create a ruby section for a text_segment.
Definition text_style.c:344
void text_segment_ChainDelete(text_segment_t *)
This function will destroy a list of text segments allocated by text_segment_New.
Definition text_style.c:435
text_segment_t * text_segment_FromRuby(text_segment_ruby_t *p_ruby)
This function creates a text segment from a ruby section, and creates fallback string.
Definition text_style.c:403
text_style_t * text_style_Copy(text_style_t *, const text_style_t *)
Copy a text style into another.
Definition text_style.c:247
unsigned int vlc_html_color(const char *psz_value, bool *ok)
Returns an integer representation of an HTML color.
Definition text_style.c:476
void text_segment_ruby_ChainDelete(text_segment_ruby_t *p_ruby)
Deletes a ruby sections chain.
Definition text_style.c:332
text_segment_t * text_segment_NewInheritStyle(const text_style_t *p_style)
This function will create a new text segment and duplicates the style passed as argument.
Definition text_style.c:387
void text_style_Merge(text_style_t *, const text_style_t *, bool b_override)
Merge two styles using non default values.
Definition text_style.c:272
char psz_value[8]
Definition vout_intf.c:110