]> git.sesse.net Git - vlc/blobdiff - modules/text_renderer/freetype.c
Improve x86 cpuid
[vlc] / modules / text_renderer / freetype.c
index 10c81508c4ea2092df760b13df519e720a40d312..fe14eda38ad3a2964b72df33cbb215d31ba96246 100644 (file)
@@ -1453,7 +1453,8 @@ static int ProcessNodes( filter_t *p_filter,
     {
         rv = PushFont( &p_fonts,
                p_font_style->psz_fontname,
-               p_font_style->i_font_size,
+               p_font_style->i_font_size > 0 ? p_font_style->i_font_size
+                                             : p_sys->i_font_size,
                (p_font_style->i_font_color & 0xffffff) |
                    ((p_font_style->i_font_alpha & 0xff) << 24),
                (p_font_style->i_karaoke_background_color & 0xffffff) |
@@ -1759,15 +1760,22 @@ static int GetGlyph( filter_t *p_filter,
     if( p_filter->p_sys->p_stroker )
     {
         outline = glyph;
-        FT_Glyph_StrokeBorder( &outline, p_filter->p_sys->p_stroker, 0, 0 );
+        if( FT_Glyph_StrokeBorder( &outline, p_filter->p_sys->p_stroker, 0, 0 ) )
+            outline = NULL;
     }
 
     FT_Glyph shadow = NULL;
     if( p_filter->p_sys->i_shadow_opacity > 0 )
     {
         shadow = outline ? outline : glyph;
-        FT_Glyph_To_Bitmap( &shadow, FT_RENDER_MODE_NORMAL, p_pen_shadow, 0 );
-        FT_Glyph_Get_CBox( shadow, ft_glyph_bbox_pixels, p_shadow_bbox );
+        if( FT_Glyph_To_Bitmap( &shadow, FT_RENDER_MODE_NORMAL, p_pen_shadow, 0  ) )
+        {
+            shadow = NULL;
+        }
+        else
+        {
+            FT_Glyph_Get_CBox( shadow, ft_glyph_bbox_pixels, p_shadow_bbox );
+        }
     }
     *pp_shadow = shadow;
 
@@ -2180,7 +2188,8 @@ static int ProcessLines( filter_t *p_filter,
         /* Update our baseline */
         if( i_face_height_previous > 0 )
             i_base_line += __MAX(i_face_height, i_face_height_previous);
-        i_face_height_previous = i_face_height;
+        if( i_face_height > 0 )
+            i_face_height_previous = i_face_height;
 
         /* Update the line bbox with the actual base line */
         if (line_bbox.yMax > line_bbox.yMin) {
@@ -2341,7 +2350,8 @@ static int RenderCommon( filter_t *p_filter, subpicture_region_t *p_region_out,
         text_style_t *p_style;
         if( p_region_in->p_style )
             p_style = CreateStyle( p_region_in->p_style->psz_fontname,
-                                   p_region_in->p_style->i_font_size,
+                                   p_region_in->p_style->i_font_size > 0 ? p_region_in->p_style->i_font_size
+                                                                         : p_sys->i_font_size,
                                    (p_region_in->p_style->i_font_color & 0xffffff) |
                                    ((p_region_in->p_style->i_font_alpha & 0xff) << 24),
                                    0x00ffffff,
@@ -2584,9 +2594,6 @@ static int Create( vlc_object_t *p_this )
                  psz_fontfile ? psz_fontfile : "(null)" );
         goto error;
     }
-#ifdef HAVE_STYLES
-    free( psz_fontfile );
-#endif
 
     i_error = FT_Select_Charmap( p_sys->p_face, ft_encoding_unicode );
     if( i_error )
@@ -2617,6 +2624,10 @@ static int Create( vlc_object_t *p_this )
 
     LoadFontsFromAttachments( p_filter );
 
+#ifdef HAVE_STYLES
+    free( psz_fontfile );
+#endif
+
     return VLC_SUCCESS;
 
 error: