[vlc-commits] Move font defaults to platform_fonts.h
Jean-Baptiste Kempf
git at videolan.org
Sun Dec 15 16:33:58 CET 2013
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Dec 15 16:31:57 2013 +0100| [e8c013a18db80850b9feb08c42197a16fa7f3a44] | committer: Jean-Baptiste Kempf
Move font defaults to platform_fonts.h
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e8c013a18db80850b9feb08c42197a16fa7f3a44
---
modules/text_renderer/freetype.c | 44 ------------------------------
modules/text_renderer/platform_fonts.c | 12 ++++----
modules/text_renderer/platform_fonts.h | 47 +++++++++++++++++++++++++++++++-
3 files changed, 52 insertions(+), 51 deletions(-)
diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
index 5e0233b..feb69e0 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -43,50 +43,6 @@
#include <vlc_filter.h> /* filter_sys_t */
#include <vlc_text_style.h> /* text_style_t*/
-/* Default fonts */
-#ifdef __APPLE__
-# define SYSTEM_DEFAULT_FONT_FILE "/Library/Fonts/Arial Unicode.ttf"
-# define SYSTEM_DEFAULT_FAMILY "Arial Unicode MS"
-# define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/System/Library/Fonts/Monaco.dfont"
-# define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Monaco"
-#elif defined( _WIN32 )
-# define SYSTEM_DEFAULT_FONT_FILE "arial.ttf" /* Default path font found at run-time */
-# define SYSTEM_DEFAULT_FAMILY "Arial"
-# define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "cour.ttf"
-# define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Courier New"
-#elif defined( __OS2__ )
-# define SYSTEM_DEFAULT_FONT_FILE "/psfonts/tnrwt_k.ttf"
-# define SYSTEM_DEFAULT_FAMILY "Times New Roman WT K"
-# define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/psfonts/mtsansdk.ttf"
-# define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Monotype Sans Duospace WT K"
-#elif defined( __ANDROID__ )
-# define SYSTEM_DEFAULT_FONT_FILE "/system/fonts/DroidSans-Bold.ttf"
-# define SYSTEM_DEFAULT_FAMILY "Droid Sans Bold"
-# define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/system/fonts/DroidSansMono.ttf"
-# define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Droid Sans Mono"
-#else
-# define SYSTEM_DEFAULT_FONT_FILE "/usr/share/fonts/truetype/freefont/FreeSerifBold.ttf"
-# define SYSTEM_DEFAULT_FAMILY "Serif Bold"
-# define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/usr/share/fonts/truetype/freefont/FreeMono.ttf"
-# define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Monospace"
-#endif
-
-#ifndef DEFAULT_FONT_FILE
-#define DEFAULT_FONT_FILE SYSTEM_DEFAULT_FONT_FILE
-#endif
-
-#ifndef DEFAULT_FAMILY
-#define DEFAULT_FAMILY SYSTEM_DEFAULT_FAMILY
-#endif
-
-#ifndef DEFAULT_MONOSPACE_FONT_FILE
-#define DEFAULT_MONOSPACE_FONT_FILE SYSTEM_DEFAULT_MONOSPACE_FONT_FILE
-#endif
-
-#ifndef DEFAULT_MONOSPACE_FAMILY
-#define DEFAULT_MONOSPACE_FAMILY SYSTEM_DEFAULT_MONOSPACE_FAMILY
-#endif
-
/* Freetype */
#include <ft2build.h>
#include FT_FREETYPE_H
diff --git a/modules/text_renderer/platform_fonts.c b/modules/text_renderer/platform_fonts.c
index 8466ccc..b19b511 100644
--- a/modules/text_renderer/platform_fonts.c
+++ b/modules/text_renderer/platform_fonts.c
@@ -242,7 +242,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 +252,7 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *lpelfe, const NEWTEXTM
return GetFileFontByName( (LPCTSTR)lpelfe->elfFullName, (char **)lParam );
}
-char *GetWindowsFontPath()
+char* GetWindowsFontPath()
{
wchar_t wdir[MAX_PATH];
if( S_OK != SHGetFolderPathW( NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, wdir ) )
@@ -264,11 +263,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 +303,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 +320,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;
diff --git a/modules/text_renderer/platform_fonts.h b/modules/text_renderer/platform_fonts.h
index 87cea63..602ce5e 100644
--- a/modules/text_renderer/platform_fonts.h
+++ b/modules/text_renderer/platform_fonts.h
@@ -33,6 +33,51 @@
# include "config.h"
#endif
+/* Default fonts */
+#ifdef __APPLE__
+# define SYSTEM_DEFAULT_FONT_FILE "/Library/Fonts/Arial Unicode.ttf"
+# define SYSTEM_DEFAULT_FAMILY "Arial Unicode MS"
+# define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/System/Library/Fonts/Monaco.dfont"
+# define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Monaco"
+#elif defined( _WIN32 )
+# define SYSTEM_DEFAULT_FONT_FILE "arial.ttf" /* Default path font found at run-time */
+# define SYSTEM_DEFAULT_FAMILY "Arial"
+# define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "cour.ttf"
+# define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Courier New"
+#elif defined( __OS2__ )
+# define SYSTEM_DEFAULT_FONT_FILE "/psfonts/tnrwt_k.ttf"
+# define SYSTEM_DEFAULT_FAMILY "Times New Roman WT K"
+# define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/psfonts/mtsansdk.ttf"
+# define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Monotype Sans Duospace WT K"
+#elif defined( __ANDROID__ )
+# define SYSTEM_DEFAULT_FONT_FILE "/system/fonts/DroidSans-Bold.ttf"
+# define SYSTEM_DEFAULT_FAMILY "Droid Sans Bold"
+# define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/system/fonts/DroidSansMono.ttf"
+# define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Droid Sans Mono"
+#else
+# define SYSTEM_DEFAULT_FONT_FILE "/usr/share/fonts/truetype/freefont/FreeSerifBold.ttf"
+# define SYSTEM_DEFAULT_FAMILY "Serif Bold"
+# define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/usr/share/fonts/truetype/freefont/FreeMono.ttf"
+# define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Monospace"
+#endif
+
+#ifndef DEFAULT_FONT_FILE
+#define DEFAULT_FONT_FILE SYSTEM_DEFAULT_FONT_FILE
+#endif
+
+#ifndef DEFAULT_FAMILY
+#define DEFAULT_FAMILY SYSTEM_DEFAULT_FAMILY
+#endif
+
+#ifndef DEFAULT_MONOSPACE_FONT_FILE
+#define DEFAULT_MONOSPACE_FONT_FILE SYSTEM_DEFAULT_MONOSPACE_FONT_FILE
+#endif
+
+#ifndef DEFAULT_MONOSPACE_FAMILY
+#define DEFAULT_MONOSPACE_FAMILY SYSTEM_DEFAULT_MONOSPACE_FAMILY
+#endif
+
+
#ifdef HAVE_FONTCONFIG
char* FontConfig_Select( filter_t *p_filter, const char* family,
bool b_bold, bool b_italic, int i_size, int *i_idx );
@@ -41,7 +86,7 @@ void FontConfig_BuildCache( filter_t *p_filter );
#ifdef _WIN32
-char *GetWindowsFontPath();
+char* GetWindowsFontPath();
char* Win32_Select( filter_t *p_filter, const char* family,
bool b_bold, bool b_italic, int i_size, int *i_idx );
More information about the vlc-commits
mailing list