text_renderer.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * text_renderer.h: common text renderer code
00003  *****************************************************************************
00004  * Copyright (C) 2007-2008 the VideoLAN team
00005  * $Id: 319f82246b1e0ab1aa5a48711669d7cbe4c095bf $
00006  *
00007  * Authors: Bernie Purcell <bitmap@videolan.org>
00008  *          Laurent Aimar < fenrir AT videolan DOT org >
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #include <vlc_memory.h>
00026 
00027 typedef struct font_stack_t font_stack_t;
00028 struct font_stack_t
00029 {
00030     char          *psz_name;
00031     int            i_size;
00032     uint32_t       i_color;            /* ARGB */
00033     uint32_t       i_karaoke_bg_color; /* ARGB */
00034 
00035     font_stack_t  *p_next;
00036 };
00037 
00038 static void SetupLine( filter_t *p_filter, const char *psz_text_in,
00039                        UCHAR **psz_text_out, uint32_t *pi_runs,
00040                        uint32_t **ppi_run_lengths, TR_FONT_STYLE_PTR **ppp_styles,
00041                        TR_FONT_STYLE_PTR p_style );
00042 
00043 static TR_FONT_STYLE_PTR GetStyleFromFontStack( filter_sys_t *p_sys,
00044                                           font_stack_t **p_fonts, bool b_bold, bool b_italic,
00045                                           bool b_uline, bool b_through );
00046 
00047 static int PushFont( font_stack_t **p_font, const char *psz_name, int i_size,
00048                      uint32_t i_color, uint32_t i_karaoke_bg_color )
00049 {
00050     font_stack_t *p_new;
00051 
00052     if( !p_font )
00053         return VLC_EGENERIC;
00054 
00055     p_new = malloc( sizeof( font_stack_t ) );
00056     if( ! p_new )
00057         return VLC_ENOMEM;
00058 
00059     p_new->p_next = NULL;
00060 
00061     if( psz_name )
00062         p_new->psz_name = strdup( psz_name );
00063     else
00064         p_new->psz_name = NULL;
00065 
00066     p_new->i_size              = i_size;
00067     p_new->i_color             = i_color;
00068     p_new->i_karaoke_bg_color  = i_karaoke_bg_color;
00069 
00070     if( !*p_font )
00071     {
00072         *p_font = p_new;
00073     }
00074     else
00075     {
00076         font_stack_t *p_last;
00077 
00078         for( p_last = *p_font;
00079              p_last->p_next;
00080              p_last = p_last->p_next )
00081         ;
00082 
00083         p_last->p_next = p_new;
00084     }
00085     return VLC_SUCCESS;
00086 }
00087 
00088 static int PopFont( font_stack_t **p_font )
00089 {
00090     font_stack_t *p_last, *p_next_to_last;
00091 
00092     if( !p_font || !*p_font )
00093         return VLC_EGENERIC;
00094 
00095     p_next_to_last = NULL;
00096     for( p_last = *p_font;
00097          p_last->p_next;
00098          p_last = p_last->p_next )
00099     {
00100         p_next_to_last = p_last;
00101     }
00102 
00103     if( p_next_to_last )
00104         p_next_to_last->p_next = NULL;
00105     else
00106         *p_font = NULL;
00107 
00108     free( p_last->psz_name );
00109     free( p_last );
00110 
00111     return VLC_SUCCESS;
00112 }
00113 
00114 static int PeekFont( font_stack_t **p_font, char **psz_name, int *i_size,
00115                      uint32_t *i_color, uint32_t *i_karaoke_bg_color )
00116 {
00117     font_stack_t *p_last;
00118 
00119     if( !p_font || !*p_font )
00120         return VLC_EGENERIC;
00121 
00122     for( p_last=*p_font;
00123          p_last->p_next;
00124          p_last=p_last->p_next )
00125     ;
00126 
00127     *psz_name            = p_last->psz_name;
00128     *i_size              = p_last->i_size;
00129     *i_color             = p_last->i_color;
00130     *i_karaoke_bg_color  = p_last->i_karaoke_bg_color;
00131 
00132     return VLC_SUCCESS;
00133 }
00134 
00135 static const struct {
00136     const char *psz_name;
00137     uint32_t   i_value;
00138 } p_html_colors[] = {
00139     /* Official html colors */
00140     { "Aqua",    0x00FFFF },
00141     { "Black",   0x000000 },
00142     { "Blue",    0x0000FF },
00143     { "Fuchsia", 0xFF00FF },
00144     { "Gray",    0x808080 },
00145     { "Green",   0x008000 },
00146     { "Lime",    0x00FF00 },
00147     { "Maroon",  0x800000 },
00148     { "Navy",    0x000080 },
00149     { "Olive",   0x808000 },
00150     { "Purple",  0x800080 },
00151     { "Red",     0xFF0000 },
00152     { "Silver",  0xC0C0C0 },
00153     { "Teal",    0x008080 },
00154     { "White",   0xFFFFFF },
00155     { "Yellow",  0xFFFF00 },
00156 
00157     /* Common ones */
00158     { "AliceBlue", 0xF0F8FF },
00159     { "AntiqueWhite", 0xFAEBD7 },
00160     { "Aqua", 0x00FFFF },
00161     { "Aquamarine", 0x7FFFD4 },
00162     { "Azure", 0xF0FFFF },
00163     { "Beige", 0xF5F5DC },
00164     { "Bisque", 0xFFE4C4 },
00165     { "Black", 0x000000 },
00166     { "BlanchedAlmond", 0xFFEBCD },
00167     { "Blue", 0x0000FF },
00168     { "BlueViolet", 0x8A2BE2 },
00169     { "Brown", 0xA52A2A },
00170     { "BurlyWood", 0xDEB887 },
00171     { "CadetBlue", 0x5F9EA0 },
00172     { "Chartreuse", 0x7FFF00 },
00173     { "Chocolate", 0xD2691E },
00174     { "Coral", 0xFF7F50 },
00175     { "CornflowerBlue", 0x6495ED },
00176     { "Cornsilk", 0xFFF8DC },
00177     { "Crimson", 0xDC143C },
00178     { "Cyan", 0x00FFFF },
00179     { "DarkBlue", 0x00008B },
00180     { "DarkCyan", 0x008B8B },
00181     { "DarkGoldenRod", 0xB8860B },
00182     { "DarkGray", 0xA9A9A9 },
00183     { "DarkGrey", 0xA9A9A9 },
00184     { "DarkGreen", 0x006400 },
00185     { "DarkKhaki", 0xBDB76B },
00186     { "DarkMagenta", 0x8B008B },
00187     { "DarkOliveGreen", 0x556B2F },
00188     { "Darkorange", 0xFF8C00 },
00189     { "DarkOrchid", 0x9932CC },
00190     { "DarkRed", 0x8B0000 },
00191     { "DarkSalmon", 0xE9967A },
00192     { "DarkSeaGreen", 0x8FBC8F },
00193     { "DarkSlateBlue", 0x483D8B },
00194     { "DarkSlateGray", 0x2F4F4F },
00195     { "DarkSlateGrey", 0x2F4F4F },
00196     { "DarkTurquoise", 0x00CED1 },
00197     { "DarkViolet", 0x9400D3 },
00198     { "DeepPink", 0xFF1493 },
00199     { "DeepSkyBlue", 0x00BFFF },
00200     { "DimGray", 0x696969 },
00201     { "DimGrey", 0x696969 },
00202     { "DodgerBlue", 0x1E90FF },
00203     { "FireBrick", 0xB22222 },
00204     { "FloralWhite", 0xFFFAF0 },
00205     { "ForestGreen", 0x228B22 },
00206     { "Fuchsia", 0xFF00FF },
00207     { "Gainsboro", 0xDCDCDC },
00208     { "GhostWhite", 0xF8F8FF },
00209     { "Gold", 0xFFD700 },
00210     { "GoldenRod", 0xDAA520 },
00211     { "Gray", 0x808080 },
00212     { "Grey", 0x808080 },
00213     { "Green", 0x008000 },
00214     { "GreenYellow", 0xADFF2F },
00215     { "HoneyDew", 0xF0FFF0 },
00216     { "HotPink", 0xFF69B4 },
00217     { "IndianRed", 0xCD5C5C },
00218     { "Indigo", 0x4B0082 },
00219     { "Ivory", 0xFFFFF0 },
00220     { "Khaki", 0xF0E68C },
00221     { "Lavender", 0xE6E6FA },
00222     { "LavenderBlush", 0xFFF0F5 },
00223     { "LawnGreen", 0x7CFC00 },
00224     { "LemonChiffon", 0xFFFACD },
00225     { "LightBlue", 0xADD8E6 },
00226     { "LightCoral", 0xF08080 },
00227     { "LightCyan", 0xE0FFFF },
00228     { "LightGoldenRodYellow", 0xFAFAD2 },
00229     { "LightGray", 0xD3D3D3 },
00230     { "LightGrey", 0xD3D3D3 },
00231     { "LightGreen", 0x90EE90 },
00232     { "LightPink", 0xFFB6C1 },
00233     { "LightSalmon", 0xFFA07A },
00234     { "LightSeaGreen", 0x20B2AA },
00235     { "LightSkyBlue", 0x87CEFA },
00236     { "LightSlateGray", 0x778899 },
00237     { "LightSlateGrey", 0x778899 },
00238     { "LightSteelBlue", 0xB0C4DE },
00239     { "LightYellow", 0xFFFFE0 },
00240     { "Lime", 0x00FF00 },
00241     { "LimeGreen", 0x32CD32 },
00242     { "Linen", 0xFAF0E6 },
00243     { "Magenta", 0xFF00FF },
00244     { "Maroon", 0x800000 },
00245     { "MediumAquaMarine", 0x66CDAA },
00246     { "MediumBlue", 0x0000CD },
00247     { "MediumOrchid", 0xBA55D3 },
00248     { "MediumPurple", 0x9370D8 },
00249     { "MediumSeaGreen", 0x3CB371 },
00250     { "MediumSlateBlue", 0x7B68EE },
00251     { "MediumSpringGreen", 0x00FA9A },
00252     { "MediumTurquoise", 0x48D1CC },
00253     { "MediumVioletRed", 0xC71585 },
00254     { "MidnightBlue", 0x191970 },
00255     { "MintCream", 0xF5FFFA },
00256     { "MistyRose", 0xFFE4E1 },
00257     { "Moccasin", 0xFFE4B5 },
00258     { "NavajoWhite", 0xFFDEAD },
00259     { "Navy", 0x000080 },
00260     { "OldLace", 0xFDF5E6 },
00261     { "Olive", 0x808000 },
00262     { "OliveDrab", 0x6B8E23 },
00263     { "Orange", 0xFFA500 },
00264     { "OrangeRed", 0xFF4500 },
00265     { "Orchid", 0xDA70D6 },
00266     { "PaleGoldenRod", 0xEEE8AA },
00267     { "PaleGreen", 0x98FB98 },
00268     { "PaleTurquoise", 0xAFEEEE },
00269     { "PaleVioletRed", 0xD87093 },
00270     { "PapayaWhip", 0xFFEFD5 },
00271     { "PeachPuff", 0xFFDAB9 },
00272     { "Peru", 0xCD853F },
00273     { "Pink", 0xFFC0CB },
00274     { "Plum", 0xDDA0DD },
00275     { "PowderBlue", 0xB0E0E6 },
00276     { "Purple", 0x800080 },
00277     { "Red", 0xFF0000 },
00278     { "RosyBrown", 0xBC8F8F },
00279     { "RoyalBlue", 0x4169E1 },
00280     { "SaddleBrown", 0x8B4513 },
00281     { "Salmon", 0xFA8072 },
00282     { "SandyBrown", 0xF4A460 },
00283     { "SeaGreen", 0x2E8B57 },
00284     { "SeaShell", 0xFFF5EE },
00285     { "Sienna", 0xA0522D },
00286     { "Silver", 0xC0C0C0 },
00287     { "SkyBlue", 0x87CEEB },
00288     { "SlateBlue", 0x6A5ACD },
00289     { "SlateGray", 0x708090 },
00290     { "SlateGrey", 0x708090 },
00291     { "Snow", 0xFFFAFA },
00292     { "SpringGreen", 0x00FF7F },
00293     { "SteelBlue", 0x4682B4 },
00294     { "Tan", 0xD2B48C },
00295     { "Teal", 0x008080 },
00296     { "Thistle", 0xD8BFD8 },
00297     { "Tomato", 0xFF6347 },
00298     { "Turquoise", 0x40E0D0 },
00299     { "Violet", 0xEE82EE },
00300     { "Wheat", 0xF5DEB3 },
00301     { "White", 0xFFFFFF },
00302     { "WhiteSmoke", 0xF5F5F5 },
00303     { "Yellow", 0xFFFF00 },
00304     { "YellowGreen", 0x9ACD32 },
00305 
00306     { NULL, 0 }
00307 };
00308 
00309 static int HandleFontAttributes( xml_reader_t *p_xml_reader,
00310                                   font_stack_t **p_fonts, int i_scale )
00311 {
00312     int        rv;
00313     char      *psz_fontname = NULL;
00314     uint32_t   i_font_color = 0xffffff;
00315     int        i_font_alpha = 0;
00316     uint32_t   i_karaoke_bg_color = 0x00ffffff;
00317     int        i_font_size  = 24;
00318 
00319     /* Default all attributes to the top font in the stack -- in case not
00320      * all attributes are specified in the sub-font
00321      */
00322     if( VLC_SUCCESS == PeekFont( p_fonts,
00323                                  &psz_fontname,
00324                                  &i_font_size,
00325                                  &i_font_color,
00326                                  &i_karaoke_bg_color ))
00327     {
00328         psz_fontname = strdup( psz_fontname );
00329         i_font_size = i_font_size * 1000 / i_scale;
00330     }
00331     i_font_alpha = (i_font_color >> 24) & 0xff;
00332     i_font_color &= 0x00ffffff;
00333 
00334     while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
00335     {
00336         char *psz_name = xml_ReaderName( p_xml_reader );
00337         char *psz_value = xml_ReaderValue( p_xml_reader );
00338 
00339         if( psz_name && psz_value )
00340         {
00341             if( !strcasecmp( "face", psz_name ) )
00342             {
00343                 free( psz_fontname );
00344                 psz_fontname = strdup( psz_value );
00345             }
00346             else if( !strcasecmp( "size", psz_name ) )
00347             {
00348                 if( ( *psz_value == '+' ) || ( *psz_value == '-' ) )
00349                 {
00350                     int i_value = atoi( psz_value );
00351 
00352                     if( ( i_value >= -5 ) && ( i_value <= 5 ) )
00353                         i_font_size += ( i_value * i_font_size ) / 10;
00354                     else if( i_value < -5 )
00355                         i_font_size = - i_value;
00356                     else if( i_value > 5 )
00357                         i_font_size = i_value;
00358                 }
00359                 else
00360                     i_font_size = atoi( psz_value );
00361             }
00362             else if( !strcasecmp( "color", psz_name ) )
00363             {
00364                 if( psz_value[0] == '#' )
00365                 {
00366                     i_font_color = strtol( psz_value + 1, NULL, 16 );
00367                     i_font_color &= 0x00ffffff;
00368                 }
00369                 else
00370                 {
00371                     for( int i = 0; p_html_colors[i].psz_name != NULL; i++ )
00372                     {
00373                         if( !strncasecmp( psz_value, p_html_colors[i].psz_name, strlen(p_html_colors[i].psz_name) ) )
00374                         {
00375                             i_font_color = p_html_colors[i].i_value;
00376                             break;
00377                         }
00378                     }
00379                 }
00380             }
00381             else if( !strcasecmp( "alpha", psz_name ) &&
00382                      ( psz_value[0] == '#' ) )
00383             {
00384                 i_font_alpha = strtol( psz_value + 1, NULL, 16 );
00385                 i_font_alpha &= 0xff;
00386             }
00387         }
00388         free( psz_name );
00389         free( psz_value );
00390     }
00391     rv = PushFont( p_fonts,
00392                    psz_fontname,
00393                    i_font_size * i_scale / 1000,
00394                    (i_font_color & 0xffffff) | ((i_font_alpha & 0xff) << 24),
00395                    i_karaoke_bg_color );
00396 
00397     free( psz_fontname );
00398 
00399     return rv;
00400 }
00401 
00402 static void SetKaraokeLen( uint32_t i_runs, uint32_t *pi_run_lengths,
00403                            uint32_t i_k_runs, uint32_t *pi_k_run_lengths )
00404 {
00405     /* Karaoke tags _PRECEDE_ the text they specify a duration
00406      * for, therefore we are working out the length for the
00407      * previous tag, and first time through we have nothing
00408      */
00409     if( pi_k_run_lengths )
00410     {
00411         int i_chars = 0;
00412         uint32_t i;
00413 
00414         /* Work out how many characters are presently in the string
00415          */
00416         for( i = 0; i < i_runs; i++ )
00417             i_chars += pi_run_lengths[ i ];
00418 
00419         /* Subtract away those we've already allocated to other
00420          * karaoke tags
00421          */
00422         for( i = 0; i < i_k_runs; i++ )
00423             i_chars -= pi_k_run_lengths[ i ];
00424 
00425         pi_k_run_lengths[ i_k_runs - 1 ] = i_chars;
00426     }
00427 }
00428 
00429 static void SetupKaraoke( xml_reader_t *p_xml_reader, uint32_t *pi_k_runs,
00430                           uint32_t **ppi_k_run_lengths,
00431                           uint32_t **ppi_k_durations )
00432 {
00433     while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
00434     {
00435         char *psz_name = xml_ReaderName( p_xml_reader );
00436         char *psz_value = xml_ReaderValue( p_xml_reader );
00437 
00438         if( psz_name && psz_value &&
00439             !strcasecmp( "t", psz_name ) )
00440         {
00441             if( ppi_k_durations && ppi_k_run_lengths )
00442             {
00443                 (*pi_k_runs)++;
00444 
00445                 if( *ppi_k_durations )
00446                 {
00447                     *ppi_k_durations = realloc_or_free( *ppi_k_durations,
00448                                  *pi_k_runs * sizeof( uint32_t ) );
00449                 }
00450                 else if( *pi_k_runs == 1 )
00451                 {
00452                     *ppi_k_durations = (uint32_t *)
00453                         malloc( *pi_k_runs * sizeof( uint32_t ) );
00454                 }
00455 
00456                 if( *ppi_k_run_lengths )
00457                 {
00458                     *ppi_k_run_lengths = realloc_or_free( *ppi_k_run_lengths,
00459                                  *pi_k_runs * sizeof( uint32_t ) );
00460                 }
00461                 else if( *pi_k_runs == 1 )
00462                 {
00463                     *ppi_k_run_lengths = (uint32_t *)
00464                         malloc( *pi_k_runs * sizeof( uint32_t ) );
00465                 }
00466                 if( *ppi_k_durations )
00467                     (*ppi_k_durations)[ *pi_k_runs - 1 ] = atoi( psz_value );
00468 
00469                 if( *ppi_k_run_lengths )
00470                     (*ppi_k_run_lengths)[ *pi_k_runs - 1 ] = 0;
00471             }
00472         }
00473         free( psz_name );
00474         free( psz_value );
00475     }
00476 }
00477 
00478 /* Turn any multiple-whitespaces into single spaces */
00479 static void HandleWhiteSpace( char *psz_node )
00480 {
00481     char *s = strpbrk( psz_node, "\t\r\n " );
00482     while( s )
00483     {
00484         int i_whitespace = strspn( s, "\t\r\n " );
00485 
00486         if( i_whitespace > 1 )
00487             memmove( &s[1],
00488                      &s[i_whitespace],
00489                      strlen( s ) - i_whitespace + 1 );
00490         *s++ = ' ';
00491 
00492         s = strpbrk( s, "\t\r\n " );
00493     }
00494 }
00495 
00496 /* */
00497 static int ProcessNodes( filter_t *p_filter,
00498                          xml_reader_t *p_xml_reader,
00499                          text_style_t *p_font_style,
00500                          UCHAR *psz_text,
00501                          int *pi_len,
00502 
00503                          uint32_t *pi_runs,
00504                          uint32_t **ppi_run_lengths,
00505                          TR_FONT_STYLE_PTR **ppp_styles,
00506 
00507                          bool b_karaoke,
00508                          uint32_t *pi_k_runs,
00509                          uint32_t **ppi_k_run_lengths,
00510                          uint32_t **ppi_k_durations )
00511 {
00512     int           rv             = VLC_SUCCESS;
00513     filter_sys_t *p_sys          = p_filter->p_sys;
00514     UCHAR        *psz_text_orig  = psz_text;
00515     font_stack_t *p_fonts        = NULL;
00516     vlc_value_t   val;
00517     int           i_scale        = 1000;
00518 
00519     char *psz_node  = NULL;
00520 
00521     bool b_italic = false;
00522     bool b_bold   = false;
00523     bool b_uline  = false;
00524     bool b_through = false;
00525 
00526     if( VLC_SUCCESS == var_Get( p_filter, "scale", &val ))
00527         i_scale = val.i_int;
00528 
00529     if( p_font_style )
00530     {
00531         rv = PushFont( &p_fonts,
00532                p_font_style->psz_fontname,
00533                p_font_style->i_font_size * i_scale / 1000,
00534                (p_font_style->i_font_color & 0xffffff) |
00535                    ((p_font_style->i_font_alpha & 0xff) << 24),
00536                (p_font_style->i_karaoke_background_color & 0xffffff) |
00537                    ((p_font_style->i_karaoke_background_alpha & 0xff) << 24));
00538 
00539         if( p_font_style->i_style_flags & STYLE_BOLD )
00540             b_bold = true;
00541         if( p_font_style->i_style_flags & STYLE_ITALIC )
00542             b_italic = true;
00543         if( p_font_style->i_style_flags & STYLE_UNDERLINE )
00544             b_uline = true;
00545         if( p_font_style->i_style_flags & STYLE_STRIKEOUT )
00546             b_through = true;
00547     }
00548 #ifdef HAVE_FONTCONFIG
00549     else
00550     {
00551         rv = PushFont( &p_fonts,
00552                        TR_DEFAULT_FONT,
00553                        p_sys->i_font_size,
00554                        (p_sys->i_font_color & 0xffffff) |
00555                           (((255-p_sys->i_font_opacity) & 0xff) << 24),
00556                        0x00ffffff );
00557     }
00558 #endif
00559 
00560     if( rv != VLC_SUCCESS )
00561         return rv;
00562 
00563     while ( ( xml_ReaderRead( p_xml_reader ) == 1 ) )
00564     {
00565         switch ( xml_ReaderNodeType( p_xml_reader ) )
00566         {
00567             case XML_READER_NONE:
00568                 break;
00569             case XML_READER_ENDELEM:
00570                 psz_node = xml_ReaderName( p_xml_reader );
00571                 if( psz_node )
00572                 {
00573                     if( !strcasecmp( "font", psz_node ) )
00574                         PopFont( &p_fonts );
00575                     else if( !strcasecmp( "b", psz_node ) )
00576                         b_bold   = false;
00577                     else if( !strcasecmp( "i", psz_node ) )
00578                         b_italic = false;
00579                     else if( !strcasecmp( "u", psz_node ) )
00580                         b_uline  = false;
00581                     else if( !strcasecmp( "s", psz_node ) )
00582                         b_through = false;
00583 
00584                     free( psz_node );
00585                 }
00586                 break;
00587             case XML_READER_STARTELEM:
00588                 psz_node = xml_ReaderName( p_xml_reader );
00589                 if( psz_node )
00590                 {
00591                     if( !strcasecmp( "font", psz_node ) )
00592                         rv = HandleFontAttributes( p_xml_reader, &p_fonts, i_scale );
00593                     else if( !strcasecmp( "b", psz_node ) )
00594                         b_bold = true;
00595                     else if( !strcasecmp( "i", psz_node ) )
00596                         b_italic = true;
00597                     else if( !strcasecmp( "u", psz_node ) )
00598                         b_uline = true;
00599                     else if( !strcasecmp( "s", psz_node ) )
00600                         b_through = true;
00601 
00602                     else if( !strcasecmp( "br", psz_node ) )
00603                     {
00604                         SetupLine( p_filter, "\n", &psz_text,
00605                                    pi_runs, ppi_run_lengths, ppp_styles,
00606                                    GetStyleFromFontStack( p_sys,
00607                                                           &p_fonts,
00608                                                           b_bold,
00609                                                           b_italic,
00610                                                           b_uline,
00611                                                           b_through) );
00612                     }
00613                     else if( !strcasecmp( "k", psz_node ) )
00614                     {
00615                         /* Only valid in karaoke */
00616                         if( b_karaoke )
00617                         {
00618                             if( *pi_k_runs > 0 )
00619                             {
00620                                 SetKaraokeLen( *pi_runs, *ppi_run_lengths,
00621                                                *pi_k_runs, *ppi_k_run_lengths );
00622                             }
00623                             SetupKaraoke( p_xml_reader, pi_k_runs,
00624                                           ppi_k_run_lengths, ppi_k_durations );
00625                         }
00626                     }
00627 
00628                     free( psz_node );
00629                 }
00630                 break;
00631             case XML_READER_TEXT:
00632                 psz_node = xml_ReaderValue( p_xml_reader );
00633                 if( psz_node )
00634                 {
00635                     /* */
00636                     HandleWhiteSpace( psz_node );
00637                     resolve_xml_special_chars( psz_node );
00638 
00639                     SetupLine( p_filter, psz_node, &psz_text,
00640                                pi_runs, ppi_run_lengths, ppp_styles,
00641                                GetStyleFromFontStack( p_sys,
00642                                                       &p_fonts,
00643                                                       b_bold,
00644                                                       b_italic,
00645                                                       b_uline,
00646                                                       b_through) );
00647                     free( psz_node );
00648                 }
00649                 break;
00650         }
00651         if( rv != VLC_SUCCESS )
00652         {
00653             psz_text = psz_text_orig;
00654             break;
00655         }
00656     }
00657     if( b_karaoke )
00658     {
00659         SetKaraokeLen( *pi_runs, *ppi_run_lengths,
00660                        *pi_k_runs, *ppi_k_run_lengths );
00661     }
00662 
00663     *pi_len = psz_text - psz_text_orig;
00664 
00665     while( VLC_SUCCESS == PopFont( &p_fonts ) );
00666 
00667     return rv;
00668 }

Generated on Tue May 25 08:04:59 2010 for VLC by  doxygen 1.5.6