summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorBerke Viktor <bviktor@hexchat.org>2012-10-28 02:08:36 +0100
committerBerke Viktor <bviktor@hexchat.org>2012-10-28 02:08:36 +0100
commit6ae224107fbc0589629e3368bd516e08ae4b5a54 (patch)
tree4f39345cfcbefdff8005cc912ee89723f49b8c99 /src
parente0f61605de13844e17caa25722ec13a08cf743b6 (diff)
Use Consolas as the default font where available
Diffstat (limited to 'src')
-rw-r--r--src/common/cfgfiles.c13
-rw-r--r--src/common/common-xp.vcxproj4
-rw-r--r--src/common/common.vcxproj4
-rw-r--r--src/common/util.c32
-rw-r--r--src/common/util.h1
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 @@
       <FunctionLevelLinking>true</FunctionLevelLinking>

       <IntrinsicFunctions>true</IntrinsicFunctions>

       <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>

-      <AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

+      <AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

       <MultiProcessorCompilation>true</MultiProcessorCompilation>

     </ClCompile>

     <Link>

@@ -143,7 +143,7 @@
       <FunctionLevelLinking>true</FunctionLevelLinking>

       <IntrinsicFunctions>true</IntrinsicFunctions>

       <PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>

-      <AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

+      <AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

       <MultiProcessorCompilation>true</MultiProcessorCompilation>

     </ClCompile>

     <Link>

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 @@
       <FunctionLevelLinking>true</FunctionLevelLinking>

       <IntrinsicFunctions>true</IntrinsicFunctions>

       <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>

-      <AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

+      <AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

       <MultiProcessorCompilation>true</MultiProcessorCompilation>

     </ClCompile>

     <Link>

@@ -140,7 +140,7 @@
       <FunctionLevelLinking>true</FunctionLevelLinking>

       <IntrinsicFunctions>true</IntrinsicFunctions>

       <PreprocessorDefinitions>WIN32;_WIN64;_AMD64_;NDEBUG;_LIB;$(OwnFlags);%(PreprocessorDefinitions)</PreprocessorDefinitions>

-      <AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

+      <AdditionalIncludeDirectories>$(DepsRoot)\include;$(Glib);$(Gtk);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

       <MultiProcessorCompilation>true</MultiProcessorCompilation>

     </ClCompile>

     <Link>

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 <sys/timeb.h>
 #include <process.h>
 #include <io.h>
+#include <pango/pangocairo.h>		/* 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