[vlc-devel] commit: libass: set windows/fonts as default directory (Laurent Aimar )

git version control git at videolan.org
Fri Jan 16 18:01:32 CET 2009


vlc | branch: 0.9-bugfix | Laurent Aimar <fenrir at videolan.org> | Sat Jan 10 21:12:56 2009 +0100| [049a5774d17ce714b0d520e17f8fc43f04d4a056] | committer: Jean-Baptiste Kempf 

libass: set windows/fonts as default directory

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
"
(cherry picked from commit afec80a73d4e7e4a3c6221f6214d32fb7223ca4f)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/codec/libass.c |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/modules/codec/libass.c b/modules/codec/libass.c
index a16609a..a1b75f6 100644
--- a/modules/codec/libass.c
+++ b/modules/codec/libass.c
@@ -43,6 +43,10 @@
 
 #include <ass/ass.h>
 
+#if defined(WIN32)
+#   include <vlc_charset.h>
+#endif
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -696,7 +700,31 @@ static ass_handle_t *AssHandleYield( 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 );




More information about the vlc-devel mailing list