From 6ae224107fbc0589629e3368bd516e08ae4b5a54 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Sun, 28 Oct 2012 02:08:36 +0100 Subject: Use Consolas as the default font where available --- src/common/cfgfiles.c | 13 +++++++++++++ src/common/common-xp.vcxproj | 4 ++-- src/common/common.vcxproj | 4 ++-- src/common/util.c | 32 ++++++++++++++++++++++++++++++++ src/common/util.h | 1 + 5 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 2cd20ffb..cc5e0caa 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -789,8 +789,21 @@ load_config (void) #endif strcpy (prefs.hex_stamp_log_format, "%b %d %H:%M:%S "); strcpy (prefs.hex_stamp_text_format, "[%H:%M:%S] "); +#ifdef WIN32 + if (find_font ("Consolas")) + { + strcpy (prefs.hex_text_font, "Consolas 10"); + strcpy (prefs.hex_text_font_main, "Consolas 10"); + } + else + { + strcpy (prefs.hex_text_font, DEF_FONT); + strcpy (prefs.hex_text_font_main, DEF_FONT); + } +#else strcpy (prefs.hex_text_font, DEF_FONT); strcpy (prefs.hex_text_font_main, DEF_FONT); +#endif strcpy (prefs.hex_text_font_alternative, DEF_FONT_ALTER); strcpy (prefs.hex_text_spell_langs, g_getenv ("LC_ALL") ? g_getenv ("LC_ALL") : "en_US"); diff --git a/src/common/common-xp.vcxproj b/src/common/common-xp.vcxproj index 3d2e0bd1..047af55c 100644 --- a/src/common/common-xp.vcxproj +++ b/src/common/common-xp.vcxproj @@ -125,7 +125,7 @@ true true WIN32;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions) - $(DepsRoot)\include;$(Glib);%(AdditionalIncludeDirectories) + $(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories) true @@ -143,7 +143,7 @@ true true WIN32;_WIN64;_AMD64_;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions) - $(DepsRoot)\include;$(Glib);%(AdditionalIncludeDirectories) + $(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories) true diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj index 9f3c0990..30f5a009 100644 --- a/src/common/common.vcxproj +++ b/src/common/common.vcxproj @@ -122,7 +122,7 @@ true true WIN32;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions) - $(DepsRoot)\include;$(Glib);%(AdditionalIncludeDirectories) + $(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories) true @@ -140,7 +140,7 @@ true true WIN32;_WIN64;_AMD64_;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions) - $(DepsRoot)\include;$(Glib);%(AdditionalIncludeDirectories) + $(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories) true diff --git a/src/common/util.c b/src/common/util.c index cc5169c7..5980a791 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -32,6 +32,7 @@ #include #include #include +#include /* for find_font() */ #include "../dirent/dirent-win32.h" #include "../../config-win32.h" #else @@ -1986,3 +1987,34 @@ encode_sasl_pass (char *user, char *pass) return encoded; } + +#ifdef WIN32 +int +find_font (const char *fontname) +{ + int i; + int n_families; + const char *family_name; + PangoFontMap *fontmap; + PangoFontFamily *family; + PangoFontFamily **families; + + fontmap = pango_cairo_font_map_get_default (); + pango_font_map_list_families (fontmap, &families, &n_families); + + for (i = 0; i < n_families; i++) + { + family = families[i]; + family_name = pango_font_family_get_name (family); + + if (!g_ascii_strcasecmp (family_name, fontname)) + { + g_free (families); + return 1; + } + } + + g_free (families); + return 0; +} +#endif diff --git a/src/common/util.h b/src/common/util.h index b4185676..0ff32227 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -47,6 +47,7 @@ int waitline (int sok, char *buf, int bufsize, int); #ifdef WIN32 int waitline2 (GIOChannel *source, char *buf, int bufsize); int get_cpu_arch (void); +int find_font (const char *fontname); #else #define waitline2(source,buf,size) waitline(serv->childread,buf,size,0) #endif -- cgit 1.4.1