]> git.sesse.net Git - vlc/commitdiff
libass: set windows/fonts as default directory
authorLaurent Aimar <fenrir@videolan.org>
Sat, 10 Jan 2009 20:12:56 +0000 (21:12 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 10 Jan 2009 20:16:09 +0000 (21:16 +0100)
Initial patch by Hannes Domani with the comments:
"Hello

 this fixes the problem when font is not attached in mkv.

 was mentioned in:
 http://forum.videolan.org/viewtopic.php?f=14&t=51096&p=166340
 http://forum.videolan.org/viewtopic.php?f=7&t=50534&p=163900
"

modules/codec/libass.c

index 32a6a1ef076e69ae6e1b212fb1f37ad91617b43d..6c86de0c489b1ec068464ba4ae97a0ed0721332e 100644 (file)
 
 #include <ass/ass.h>
 
+#if defined(WIN32)
+#   include <vlc_charset.h>
+#endif
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -675,7 +679,31 @@ static ass_handle_t *AssHandleHold( decoder_t *p_dec )
     }
     free( pp_attachments );
 
-    char *psz_font_dir = config_GetCacheDir();
+    char *psz_font_dir = NULL;
+
+#if defined(WIN32)
+    const UINT uPath = GetSystemWindowsDirectory( NULL, 0 );
+    if( uPath > 0 )
+    {
+        wchar_t *psw_path = calloc( uPath + 1, sizeof(wchar_t) );
+        if( psw_path )
+        {
+            if( GetSystemWindowsDirectoryW( psw_path, uPath + 1 ) > 0 )
+            {
+                char *psz_tmp = FromWide( psw_path );
+                if( psz_tmp &&
+                    asprintf( &psz_font_dir, "%s\\Fonts", psz_tmp ) < 0 )
+                    psz_font_dir = NULL;
+                free( psz_tmp );
+            }
+            free( psw_path );
+        }
+    }
+#endif
+
+    if( !psz_font_dir )
+        psz_font_dir = config_GetCacheDir();
+
     if( !psz_font_dir )
         goto error;
     ass_set_fonts_dir( p_library, psz_font_dir );