[vlc-commits] Freetype: fallback to arial.ttf on Win32

Jean-Baptiste Kempf git at videolan.org
Tue Nov 1 14:09:29 CET 2011


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Nov  1 14:08:32 2011 +0100| [0891ac62c94b90337fe437c8eada9f14e55c5e9b] | committer: Jean-Baptiste Kempf

Freetype: fallback to arial.ttf on Win32

When we haven't found the right font, use arial.ttf

Close #4946

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0891ac62c94b90337fe437c8eada9f14e55c5e9b
---

 modules/text_renderer/freetype.c |   42 ++++++++++++++++++++++---------------
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
index f9d2d77..8ab6196 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -592,7 +592,6 @@ static char* Win32_Select( filter_t *p_filter, const char* family,
                            bool b_bold, bool b_italic, int i_size, int *i_idx )
 {
     VLC_UNUSED( i_size );
-    // msg_Dbg( p_filter, "Here in Win32_Select, asking for %s", family );
 
     /* */
     LOGFONT lf;
@@ -609,30 +608,39 @@ static char* Win32_Select( filter_t *p_filter, const char* family,
     EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)&EnumFontCallback, (LPARAM)&psz_filename, 0);
     ReleaseDC(NULL, hDC);
 
-    if( psz_filename == NULL )
-        return NULL;
-
-    /* FIXME: increase i_idx, when concatenated strings  */
-    i_idx = 0;
-
     /* */
-    if( strchr( psz_filename, DIR_SEP_CHAR ) )
-        return psz_filename;
-    else
+    if( psz_filename != NULL )
     {
-        char *psz_tmp;
-        if( asprintf( &psz_tmp, "%s\\%s", p_filter->p_sys->psz_win_fonts_path, psz_filename ) == -1 )
+        /* FIXME: increase i_idx, when concatenated strings  */
+        i_idx = 0;
+
+        /* Prepend the Windows Font path, when only a filename was provided */
+        if( strchr( psz_filename, DIR_SEP_CHAR ) )
+            return psz_filename;
+        else
         {
+            char *psz_tmp;
+            if( asprintf( &psz_tmp, "%s\\%s", p_filter->p_sys->psz_win_fonts_path, psz_filename ) == -1 )
+            {
+                free( psz_filename );
+                return NULL;
+            }
             free( psz_filename );
-            return NULL;
+            return psz_tmp;
         }
-        free( psz_filename );
-        return psz_tmp;
+    }
+    else /* Let's take any font we can */
+    {
+        char *psz_tmp;
+        if( asprintf( &psz_tmp, "%s\\%s", p_filter->p_sys->psz_win_fonts_path, "arial.ttf" ) == -1 )
+            return NULL;
+        else
+            return psz_tmp;
     }
 }
-#endif
+#endif /* HAVE_WIN32 */
 
-#endif
+#endif /* HAVE_STYLES */
 
 
 /*****************************************************************************



More information about the vlc-commits mailing list