summary refs log tree commit diff stats
path: root/src/fe-gtk
diff options
context:
space:
mode:
Diffstat (limited to 'src/fe-gtk')
-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
3 files changed, 54 insertions, 0 deletions
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