summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/common/cfgfiles.c16
-rw-r--r--src/common/fe.h1
-rw-r--r--src/common/util.c32
-rw-r--r--src/common/util.h1
-rw-r--r--src/fe-gtk/fe-gtk.c17
-rw-r--r--src/fe-gtk/gtkutil.c33
-rw-r--r--src/fe-gtk/gtkutil.h4
-rw-r--r--src/fe-text/fe-text.c5
8 files changed, 67 insertions, 42 deletions
diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c
index b7a8beda..68f4126e 100644
--- a/src/common/cfgfiles.c
+++ b/src/common/cfgfiles.c
@@ -731,7 +731,7 @@ get_default_spell_languages (void)
 void
 load_default_config(void)
 {
-	const char *username, *realname;
+	const char *username, *realname, *font;
 	char *sp;
 #ifdef WIN32
 	char out[256];
@@ -891,21 +891,19 @@ load_default_config(void)
 	strcpy (prefs.hex_irc_user_name, username);
 	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"))
+
+	font = fe_get_default_font ();
+	if (font)
 	{
-		strcpy (prefs.hex_text_font, "Consolas 10");
-		strcpy (prefs.hex_text_font_main, "Consolas 10");
+		strcpy (prefs.hex_text_font, font);
+		strcpy (prefs.hex_text_font_main, font);
 	}
 	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, get_default_spell_languages ());
 
diff --git a/src/common/fe.h b/src/common/fe.h
index cd8ecef9..b67329ec 100644
--- a/src/common/fe.h
+++ b/src/common/fe.h
@@ -180,5 +180,6 @@ void fe_tray_set_icon (feicon icon);
 void fe_tray_set_tooltip (const char *text);
 void fe_tray_set_balloon (const char *title, const char *text);
 void fe_open_chan_list (server *serv, char *filter, int do_refresh);
+const char *fe_get_default_font ();
 
 #endif
diff --git a/src/common/util.c b/src/common/util.c
index f999e61f..6ba2d34a 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -33,7 +33,6 @@
 #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
@@ -2180,37 +2179,6 @@ end:
 }
 #endif
 
-#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
-
 #ifdef USE_OPENSSL
 static char *
 str_sha256hash (char *string)
diff --git a/src/common/util.h b/src/common/util.h
index 0c54411b..453388cd 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -65,7 +65,6 @@ 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
diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c
index ae68bb79..c0e7f53f 100644
--- a/src/fe-gtk/fe-gtk.c
+++ b/src/fe-gtk/fe-gtk.c
@@ -1113,3 +1113,20 @@ fe_open_chan_list (server *serv, char *filter, int do_refresh)
 {
 	chanlist_opengui (serv, do_refresh);
 }
+
+const char *
+fe_get_default_font (void)
+{
+#ifdef WIN32
+	if (gtkutil_find_font ("Consolas"))
+		return "Consolas 10";
+	else
+#else
+#ifdef __APPLE__
+	if (gtkutil_find_font ("Menlo"))
+		return "Menlo 13";
+	else
+#endif
+#endif
+		return NULL;
+}
diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c
index 79b71233..282b952c 100644
--- a/src/fe-gtk/gtkutil.c
+++ b/src/fe-gtk/gtkutil.c
@@ -27,6 +27,9 @@
 #include "fe-gtk.h"
 
 #include <gdk/gdkkeysyms.h>
+#if defined (WIN32) || defined (__APPLE__)
+#include <pango/pangocairo.h>
+#endif
 
 #include "../common/hexchat.h"
 #include "../common/fe.h"
@@ -722,3 +725,33 @@ gtkutil_treeview_get_selected (GtkTreeView *view, GtkTreeIter *iter_ret, ...)
 	return has_selected;
 }
 
+#if defined (WIN32) || defined (__APPLE__)
+gboolean
+gtkutil_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 TRUE;
+		}
+	}
+
+	g_free (families);
+	return FALSE;
+}
+#endif
diff --git a/src/fe-gtk/gtkutil.h b/src/fe-gtk/gtkutil.h
index cd7d9e80..87beed08 100644
--- a/src/fe-gtk/gtkutil.h
+++ b/src/fe-gtk/gtkutil.h
@@ -52,4 +52,8 @@ gboolean gtkutil_treemodel_string_to_iter (GtkTreeModel *model, gchar *pathstr,
 gboolean gtkutil_treeview_get_selected_iter (GtkTreeView *view, GtkTreeIter *iter_ret);
 gboolean gtkutil_treeview_get_selected (GtkTreeView *view, GtkTreeIter *iter_ret, ...);
 
+#if defined (WIN32) || defined (__APPLE__)
+gboolean gtkutil_find_font (const char *fontname);
+#endif
+
 #endif
diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c
index 06b58e05..341272f4 100644
--- a/src/fe-text/fe-text.c
+++ b/src/fe-text/fe-text.c
@@ -913,3 +913,8 @@ fe_open_chan_list (server *serv, char *filter, int do_refresh)
 {
 	serv->p_list_channels (serv, filter, 1);
 }
+const char *
+fe_get_default_font (void)
+{
+	return NULL;
+}