vlc_text_style.h 5.76 KB
 Laurent Aimar committed May 04, 2010 1 2 3 /***************************************************************************** * vlc_text_style.h: text_style_t definition and helpers. *****************************************************************************  Jean-Baptiste Kempf committed Nov 27, 2011 4  * Copyright (C) 1999-2010 VLC authors and VideoLAN  Laurent Aimar committed May 04, 2010 5 6 7 8 9  * $Id$ * * Authors: Derk-Jan Hartman * basOS G *  Jean-Baptiste Kempf committed Nov 27, 2011 10 11 12  * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or  Laurent Aimar committed May 04, 2010 13 14 15 16  * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of  Jean-Baptiste Kempf committed Nov 27, 2011 17 18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details.  Laurent Aimar committed May 04, 2010 19  *  Jean-Baptiste Kempf committed Nov 27, 2011 20 21 22  * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.  Laurent Aimar committed May 04, 2010 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40  *****************************************************************************/ #ifndef VLC_TEXT_STYLE_H #define VLC_TEXT_STYLE_H 1 #ifdef __cplusplus extern "C" { #endif /** * Text style * * A text style is used to specify the formatting of text. * A font renderer can use the supplied information to render the * text specified. */ typedef struct {  Jean-Baptiste Kempf committed Jul 28, 2015 41  /* Family font names */  Laurent Aimar committed May 04, 2010 42  char * psz_fontname; /**< The name of the font */  Jean-Baptiste Kempf committed Sep 09, 2013 43  char * psz_monofontname; /**< The name of the mono font */  Jean-Baptiste Kempf committed Jul 28, 2015 44 45  /* Font style */  Laurent Aimar committed May 04, 2010 46 47 48  int i_font_size; /**< The font size in pixels */ int i_font_color; /**< The color of the text 0xRRGGBB (native endianness) */  Jean-Baptiste Kempf committed Jul 28, 2015 49  uint8_t i_font_alpha; /**< The transparency of the text.  Laurent Aimar committed May 04, 2010 50 51 52  0x00 is fully opaque, 0xFF fully transparent */ int i_style_flags; /**< Formatting style flags */  Jean-Baptiste Kempf committed Jul 28, 2015 53 54 55  int i_spacing; /**< The spaceing between glyphs in pixels */ /* Outline */  Laurent Aimar committed May 04, 2010 56  int i_outline_color; /**< The color of the outline 0xRRGGBB */  Jean-Baptiste Kempf committed Jul 28, 2015 57  uint8_t i_outline_alpha; /**< The transparency of the outline.  Laurent Aimar committed May 04, 2010 58 59  0x00 is fully opaque, 0xFF fully transparent */  Jean-Baptiste Kempf committed Jul 28, 2015 60 61 62  int i_outline_width; /**< The width of the outline in pixels */ /* Shadow */  Laurent Aimar committed May 04, 2010 63  int i_shadow_color; /**< The color of the shadow 0xRRGGBB */  Jean-Baptiste Kempf committed Jul 28, 2015 64  uint8_t i_shadow_alpha; /**< The transparency of the shadow.  Laurent Aimar committed May 04, 2010 65 66  0x00 is fully opaque, 0xFF fully transparent */  Jean-Baptiste Kempf committed Jul 28, 2015 67 68 69  int i_shadow_width; /**< The width of the shadow in pixels */ /* Background (and karaoke) */  Laurent Aimar committed May 04, 2010 70  int i_background_color;/**< The color of the background 0xRRGGBB */  Jean-Baptiste Kempf committed Jul 28, 2015 71  uint8_t i_background_alpha;/**< The transparency of the background.  Laurent Aimar committed May 04, 2010 72 73 74  0x00 is fully opaque, 0xFF fully transparent */ int i_karaoke_background_color;/**< Background color for karaoke 0xRRGGBB */  Jean-Baptiste Kempf committed Jul 28, 2015 75  uint8_t i_karaoke_background_alpha;/**< The transparency of the karaoke bg.  Laurent Aimar committed May 04, 2010 76 77 78 79 80 81 82 83 84 85 86 87  0x00 is fully opaque, 0xFF fully transparent */ } text_style_t; /* Style flags for \ref text_style_t */ #define STYLE_BOLD 1 #define STYLE_ITALIC 2 #define STYLE_OUTLINE 4 #define STYLE_SHADOW 8 #define STYLE_BACKGROUND 16 #define STYLE_UNDERLINE 32 #define STYLE_STRIKEOUT 64  nkoriyama committed Aug 05, 2014 88 #define STYLE_HALFWIDTH 128  Laurent Aimar committed May 04, 2010 89   François Cartegnie committed Mar 25, 2014 90 91 #define STYLE_DEFAULT_FONT_SIZE 22  Jean-Baptiste Kempf committed Jul 28, 2015 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111  typedef struct text_segment_t text_segment_t; /** * Text segment for subtitles * * This structure is used to store a formatted text, with mixed styles * Every segment is comprised of one text and a unique style * * On style change, a new segment is created with the next part of text * and the new style, and chained to the list * * Create with text_segment_New and clean the chain with * text_segment_ChainDelete */ struct text_segment_t { char *psz_text; /**< text string of the segment */ text_style_t *style; /**< style applied to this segment */ text_segment_t *p_next; /**< next segment */ };  Laurent Aimar committed May 04, 2010 112 113 114 /** * Create a default text style */  Rémi Denis-Courmont committed May 07, 2011 115 VLC_API text_style_t * text_style_New( void );  Laurent Aimar committed May 04, 2010 116 117 118 119  /** * Copy a text style into another */  Rémi Denis-Courmont committed May 07, 2011 120 VLC_API text_style_t * text_style_Copy( text_style_t *, const text_style_t * );  Laurent Aimar committed May 04, 2010 121 122 123 124  /** * Duplicate a text style */  Rémi Denis-Courmont committed May 07, 2011 125 VLC_API text_style_t * text_style_Duplicate( const text_style_t * );  Laurent Aimar committed May 04, 2010 126 127 128 129  /** * Delete a text style created by text_style_New or text_style_Duplicate */  Rémi Denis-Courmont committed May 07, 2011 130 VLC_API void text_style_Delete( text_style_t * );  Laurent Aimar committed May 04, 2010 131   Jean-Baptiste Kempf committed Jul 28, 2015 132 133 134 135 /** * This function will create a new text segment. * * You should use text_segment_ChainDelete to destroy it, to clean all  Hugo Beauzée-Luyssen committed Jul 28, 2015 136  * the linked segments, or text_segment_Delete to free a specic one  Jean-Baptiste Kempf committed Jul 28, 2015 137 138 139 140 141  * * This duplicates the string passed as argument */ VLC_API text_segment_t *text_segment_New( const char * );  Hugo Beauzée-Luyssen committed Jul 28, 2015 142 143 144 145 146 147 148 /** * Delete a text segment and its content. * * This assumes the segment is not part of a chain */ VLC_API void text_segment_Delete( text_segment_t * );  Jean-Baptiste Kempf committed Jul 28, 2015 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 /** * This function will destroy a list of text segments allocated * by text_segment_New. * * You may pass it NULL. */ VLC_API void text_segment_ChainDelete( text_segment_t * ); /** * This function will copy a text_segment and its chain into a new one * * You may give it NULL, but it will return NULL. */ VLC_API text_segment_t * text_segment_Copy( text_segment_t * );  Laurent Aimar committed May 04, 2010 164 165 166 167 168 169 #ifdef __cplusplus } #endif #endif /* VLC_TEXT_STYLE_H */