]> git.sesse.net Git - vlc/blobdiff - modules/text_renderer/platform_fonts.c
MKV: A_MS/ACM is not packetized
[vlc] / modules / text_renderer / platform_fonts.c
index 8466ccc4111df6dfe8d9035ba54dadd980bd3337..7869dbaed4f507cd99a8a605f8cb2f9debdd7f35 100644 (file)
@@ -129,14 +129,9 @@ char* FontConfig_Select( filter_t *p_filter, const char* family,
     FcPatternAddBool( pat, FC_OUTLINE, FcTrue );
     FcPatternAddInteger( pat, FC_SLANT, b_italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN );
     FcPatternAddInteger( pat, FC_WEIGHT, b_bold ? FC_WEIGHT_EXTRABOLD : FC_WEIGHT_NORMAL );
-    if( i_size != -1 )
+    if( i_size > 0 )
     {
-        char *psz_fontsize;
-        if( asprintf( &psz_fontsize, "%d", i_size ) != -1 )
-        {
-            FcPatternAddString( pat, FC_SIZE, (const FcChar8 *)psz_fontsize );
-            free( psz_fontsize );
-        }
+        FcPatternAddDouble( pat, FC_SIZE, (double)i_size );
     }
 
     /* */
@@ -183,7 +178,7 @@ char* FontConfig_Select( filter_t *p_filter, const char* family,
 }
 #endif
 
-#ifdef _WIN32
+#if defined( _WIN32 ) && !VLC_WINSTORE_APP
 #define FONT_DIR_NT _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts")
 
 static int GetFileFontByName( LPCTSTR font_name, char **psz_filename )
@@ -242,7 +237,6 @@ static int GetFileFontByName( LPCTSTR font_name, char **psz_filename )
     return 0;
 }
 
-
 static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *lpelfe, const NEWTEXTMETRICEX *metric,
                                      DWORD type, LPARAM lParam)
 {
@@ -253,7 +247,7 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *lpelfe, const NEWTEXTM
     return GetFileFontByName( (LPCTSTR)lpelfe->elfFullName, (char **)lParam );
 }
 
-char *GetWindowsFontPath()
+static char* GetWindowsFontPath()
 {
     wchar_t wdir[MAX_PATH];
     if( S_OK != SHGetFolderPathW( NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, wdir ) )
@@ -264,11 +258,12 @@ char *GetWindowsFontPath()
     return FromWide( wdir );
 }
 
-
 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 );
+    VLC_UNUSED( i_idx );
+    VLC_UNUSED( p_filter );
 
     if( !family || strlen( family ) < 1 )
         goto fail;
@@ -303,7 +298,7 @@ char* Win32_Select( filter_t *p_filter, const char* family,
         else
         {
             /* Get Windows Font folder */
-            char psz_win_fonts_path = GetWindowsFontPath();
+            char *psz_win_fonts_path = GetWindowsFontPath();
             char *psz_tmp;
             if( asprintf( &psz_tmp, "%s\\%s", psz_win_fonts_path, psz_filename ) == -1 )
             {
@@ -320,9 +315,9 @@ char* Win32_Select( filter_t *p_filter, const char* family,
     else /* Let's take any font we can */
 fail:
     {
-        char psz_win_fonts_path = GetWindowsFontPath();
+        char *psz_win_fonts_path = GetWindowsFontPath();
         char *psz_tmp;
-        if( asprintf( &psz_tmp, "%s\\%s", psz_win_fonts_path, "arial.ttf" ) == -1 )
+        if( asprintf( &psz_tmp, "%s\\%s", psz_win_fonts_path, SYSTEM_DEFAULT_FONT_FILE ) == -1 )
             return NULL;
         else
             return psz_tmp;
@@ -413,3 +408,28 @@ char* MacLegacy_Select( filter_t *p_filter, const char* psz_fontname,
 #endif
 #endif
 
+char* Dummy_Select( filter_t *p_filter, const char* psz_font,
+                    bool b_bold, bool b_italic, int i_size, int *i_idx )
+{
+    VLC_UNUSED(p_filter);
+    VLC_UNUSED(b_bold);
+    VLC_UNUSED(b_italic);
+    VLC_UNUSED(i_size);
+    VLC_UNUSED(i_idx);
+
+    char *psz_fontname;
+# if defined( _WIN32 ) && !VLC_WINSTORE_APP
+    /* Get Windows Font folder */
+    char *psz_win_fonts_path = GetWindowsFontPath();
+    if( asprintf( &psz_fontname, "%s\\%s", psz_win_fonts_path, psz_font ) == -1 )
+    {
+        psz_fontname = NULL;
+        return NULL;
+    }
+    free(psz_win_fonts_path);
+# else
+    psz_fontname = strdup( psz_font );
+# endif
+
+    return psz_fontname;
+}