]> git.sesse.net Git - vlc/blobdiff - modules/misc/freetype.c
Compile fix
[vlc] / modules / misc / freetype.c
index 5ef46409adc24c1a615a3aad8d07b784d2b4da02..5fc41fd4556cebfa026b1e23db02f88be9c1ed2d 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
-#include <vlc_osd.h>
 #include <vlc_filter.h>
 #include <vlc_stream.h>
 #include <vlc_xml.h>
@@ -94,7 +93,7 @@ static void Destroy( vlc_object_t * );
 #ifdef HAVE_FONTCONFIG
 #define FONT_LONGTEXT N_("Font family for the font you want to use")
 #else
-#define FONT_LONGTEXT N_("Fontfile for the font you want to use")
+#define FONT_LONGTEXT N_("Font file for the font you want to use")
 #endif
 
 #define FONTSIZE_TEXT N_("Font size in pixels")
@@ -114,7 +113,7 @@ static void Destroy( vlc_object_t * );
 #define FONTSIZER_TEXT N_("Relative font size")
 #define FONTSIZER_LONGTEXT N_("This is the relative default size of the " \
     "fonts that will be rendered on the video. If absolute font size is set, "\
-    "relative size will be overriden." )
+    "relative size will be overridden." )
 
 static const int pi_sizes[] = { 20, 18, 16, 12, 6 };
 static const char *const ppsz_sizes_text[] = {
@@ -346,55 +345,45 @@ static int Create( vlc_object_t *p_this )
     }
 
 #ifdef HAVE_FONTCONFIG
-    /* Lets find some fontfile from freetype-font variable family */
-    char *psz_fontsize;
-    if( asprintf( &psz_fontsize, "%d", p_sys->i_default_font_size ) == -1 )
-        goto error;
+    msg_Dbg( p_filter, "Building font databases.");
+    mtime_t t1, t2;
+    t1 = mdate();
 
 #ifdef WIN32
-    dialog_progress_bar_t *p_dialog = dialog_ProgressCreate( p_filter,
+    dialog_progress_bar_t *p_dialog = NULL;
+    FcConfig *fcConfig = FcInitLoadConfig();
+
+    p_dialog = dialog_ProgressCreate( p_filter,
             _("Building font cache"),
             _("Please wait while your font cache is rebuilt.\n"
                 "This should take less than a few minutes."), NULL );
-    char *path = xmalloc( PATH_MAX + 1 );
-    /* Fontconfig doesnt seem to know where windows fonts are with
-     * current contribs. So just tell default windows font directory
-     * is the place to search fonts
-     */
-    GetWindowsDirectory( path, PATH_MAX + 1 );
-    strcat( path, "\\fonts" );
-    if( p_dialog )
-        dialog_ProgressSet( p_dialog, NULL, 0.4 );
-
-    FcConfigAppFontAddDir( NULL , path );
-    free(path);
-
 
     if( p_dialog )
         dialog_ProgressSet( p_dialog, NULL, 0.5 );
-#endif
-    mtime_t t1, t2;
 
-    msg_Dbg( p_filter, "Building font database.");
-    t1 = mdate();
-    FcConfigBuildFonts( NULL );
+    FcConfigBuildFonts( fcConfig );
     t2 = mdate();
-
-    msg_Dbg( p_filter, "Finished building font database." );
     msg_Dbg( p_filter, "Took %ld microseconds", (long)((t2 - t1)) );
 
-    fontpattern = FcPatternCreate();
+    if( p_dialog )
+    {
+        dialog_ProgressSet( p_dialog, NULL, 1.0 );
+        dialog_ProgressDestroy( p_dialog );
+        p_dialog = NULL;
+    }
+#endif
+    /* Lets find some fontfile from freetype-font variable family */
+    char *psz_fontsize;
+    if( asprintf( &psz_fontsize, "%d", p_sys->i_default_font_size ) == -1 )
+        goto error;
 
+    fontpattern = FcPatternCreate();
     if( !fontpattern )
     {
         msg_Err( p_filter, "Creating fontpattern failed");
         goto error;
     }
 
-#ifdef WIN32
-    if( p_dialog )
-        dialog_ProgressSet( p_dialog, NULL, 0.7 );
-#endif
     FcPatternAddString( fontpattern, FC_FAMILY, psz_fontfamily);
     FcPatternAddString( fontpattern, FC_SIZE, psz_fontsize );
     free( psz_fontsize );
@@ -406,10 +395,6 @@ static int Create( vlc_object_t *p_this )
     }
     FcDefaultSubstitute( fontpattern );
 
-#ifdef WIN32
-    if( p_dialog )
-        dialog_ProgressSet( p_dialog, NULL, 0.8 );
-#endif
     /* testing fontresult here doesn't do any good really, but maybe it will
      * in future as fontconfig code doesn't set it in all cases and just
      * returns NULL or doesn't set to to Match on all Match cases.*/
@@ -431,21 +416,10 @@ static int Create( vlc_object_t *p_this )
     msg_Dbg( p_filter, "Using %s as font from file %s", psz_fontfamily,
              psz_fontfile ? psz_fontfile : "(null)" );
     p_sys->psz_fontfamily = strdup( psz_fontfamily );
-# ifdef WIN32
-    if( p_dialog )
-    {
-        dialog_ProgressSet( p_dialog, NULL, 1.0 );
-        dialog_ProgressDestroy( p_dialog );
-        p_dialog = NULL;
-    }
-# endif
 
 #else
 
-#ifdef HAVE_FONTCONFIG
-    p_sys->psz_fontfamily = strdup( DEFAULT_FONT );
     psz_fontfile = psz_fontfamily;
-#endif
 
 #endif