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.c4
-rw-r--r--src/fe-gtk/fe-gtk.vcxproj2
-rw-r--r--src/fe-gtk/joind.c2
-rw-r--r--src/fe-gtk/maingui.c30
-rw-r--r--src/fe-gtk/menu.c20
-rw-r--r--src/fe-gtk/meson.build13
-rw-r--r--src/fe-gtk/notifications/notifications-winrt.vcxproj126
-rw-r--r--src/fe-gtk/pixmaps.c22
-rw-r--r--src/fe-gtk/plugin-notification.c40
-rw-r--r--src/fe-gtk/xtext.c18
10 files changed, 193 insertions, 84 deletions
diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c
index 9d068a1b..ee3e847c 100644
--- a/src/fe-gtk/fe-gtk.c
+++ b/src/fe-gtk/fe-gtk.c
@@ -293,10 +293,10 @@ create_input_style (GtkStyle *style)
 		GtkSettings *settings = gtk_settings_get_default ();
 		char *theme_name;
 
-		/* gnome-themes-standard 3.20 relies on images to do theming
+		/* gnome-themes-standard 3.20+ relies on images to do theming
 		 * so we have to override that. */
 		g_object_get (settings, "gtk-theme-name", &theme_name, NULL);
-		if (g_str_has_prefix (theme_name, "Adwaita"))
+		if (g_str_has_prefix (theme_name, "Adwaita") || g_str_has_prefix (theme_name, "Yaru"))
 			gtk_rc_parse_string (adwaita_workaround_rc);
 		g_free (theme_name);
 
diff --git a/src/fe-gtk/fe-gtk.vcxproj b/src/fe-gtk/fe-gtk.vcxproj
index 61d0a074..06df36dc 100644
--- a/src/fe-gtk/fe-gtk.vcxproj
+++ b/src/fe-gtk/fe-gtk.vcxproj
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>

 <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

   <PropertyGroup Label="Configuration">

-    <PlatformToolset>v140</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

     <ConfigurationType>Application</ConfigurationType>

   </PropertyGroup>

   <ItemGroup Label="ProjectConfigurations">

diff --git a/src/fe-gtk/joind.c b/src/fe-gtk/joind.c
index f1d3da50..ce3cbcae 100644
--- a/src/fe-gtk/joind.c
+++ b/src/fe-gtk/joind.c
@@ -247,7 +247,7 @@ joind_show_dialog (server *serv)
 							G_CALLBACK (joind_ok_cb), serv);
 							
 	if (serv->network)
-		if (g_ascii_strcasecmp(((ircnet*)serv->network)->name, "freenode") == 0)
+		if (g_ascii_strcasecmp(((ircnet*)serv->network)->name, "Libera.Chat") == 0)
 		{
 			gtk_entry_set_text (GTK_ENTRY (entry1), "#hexchat");
 		}
diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c
index efeaaaeb..4e5baaa0 100644
--- a/src/fe-gtk/maingui.c
+++ b/src/fe-gtk/maingui.c
@@ -53,6 +53,10 @@
 #include "sexy-spell-entry.h"
 #include "gtkutil.h"
 
+#ifdef G_OS_WIN32
+#include <windows.h>
+#endif
+
 #define GUI_SPACING (3)
 #define GUI_BORDER (0)
 
@@ -1516,14 +1520,32 @@ static void
 mg_create_alertmenu (session *sess, GtkWidget *menu)
 {
 	GtkWidget *submenu;
+	int hex_balloon, hex_beep, hex_tray, hex_flash;
+
+
+	switch (sess->type) {
+		case SESS_DIALOG:
+			hex_balloon = prefs.hex_input_balloon_priv;
+			hex_beep = prefs.hex_input_beep_priv;
+			hex_tray = prefs.hex_input_tray_priv;
+			hex_flash = prefs.hex_input_flash_priv;
+			break;
+		default:
+			hex_balloon = prefs.hex_input_balloon_chans;
+			hex_beep = prefs.hex_input_beep_chans;
+			hex_tray = prefs.hex_input_tray_chans;
+			hex_flash = prefs.hex_input_flash_chans;
+	}
+
+	submenu = menu_quick_sub(_("_Extra Alerts"), menu, NULL, XCMENU_MNEMONIC, -1);
 
-	submenu = menu_quick_sub (_("_Extra Alerts"), menu, NULL, XCMENU_MNEMONIC, -1);
+	mg_perchan_menu_item(_("Show Notifications"), submenu, &sess->alert_balloon, hex_balloon);
 
-	mg_perchan_menu_item (_("Beep on _Message"), submenu, &sess->alert_beep, prefs.hex_input_beep_chans);
+	mg_perchan_menu_item(_("Beep on _Message"), submenu, &sess->alert_beep, hex_beep);
 
-	mg_perchan_menu_item (_("Blink Tray _Icon"), submenu, &sess->alert_tray, prefs.hex_input_tray_chans);
+	mg_perchan_menu_item(_("Blink Tray _Icon"), submenu, &sess->alert_tray, hex_tray);
 
-	mg_perchan_menu_item (_("Blink Task _Bar"), submenu, &sess->alert_taskbar, prefs.hex_input_flash_chans);
+	mg_perchan_menu_item(_("Blink Task _Bar"), submenu, &sess->alert_taskbar, hex_flash);
 }
 
 static void
diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c
index 097093b4..233715e5 100644
--- a/src/fe-gtk/menu.c
+++ b/src/fe-gtk/menu.c
@@ -1002,6 +1002,18 @@ menu_chan_part (GtkWidget * menu, char *chan)
 }
 
 static void
+menu_chan_focus (GtkWidget * menu, char *chan)
+{
+	char tbuf[256];
+
+	if (current_sess)
+	{
+		g_snprintf (tbuf, sizeof tbuf, "doat %s gui focus", chan);
+		handle_command (current_sess, tbuf, FALSE);
+	}
+}
+
+static void
 menu_chan_join (GtkWidget * menu, char *chan)
 {
 	char tbuf[256];
@@ -1018,8 +1030,11 @@ menu_chanmenu (struct session *sess, GdkEventButton * event, char *chan)
 {
 	GtkWidget *menu;
 	int is_joined = FALSE;
+	session * chan_session;
+
+	chan_session = find_channel (sess->server, chan);
 
-	if (find_channel (sess->server, chan))
+	if (chan_session)
 		is_joined = TRUE;
 
 	g_free (str_copy);
@@ -1035,6 +1050,9 @@ menu_chanmenu (struct session *sess, GdkEventButton * event, char *chan)
 												 str_copy);
 	else
 	{
+		if (chan_session != current_sess)
+			menu_quick_item_with_callback (menu_chan_focus, _("Focus Channel"), menu,
+													 str_copy);
 		menu_quick_item_with_callback (menu_chan_part, _("Part Channel"), menu,
 												 str_copy);
 		menu_quick_item_with_callback (menu_chan_cycle, _("Cycle Channel"), menu,
diff --git a/src/fe-gtk/meson.build b/src/fe-gtk/meson.build
index f11580bb..3dfc7427 100644
--- a/src/fe-gtk/meson.build
+++ b/src/fe-gtk/meson.build
@@ -39,13 +39,9 @@ if gtk_dep.get_pkgconfig_variable('target') == 'x11'
   hexchat_gtk_deps += dependency('x11')
 endif
 
-hexchat_gtk_cflags = [
-  '-fPIE'
-]
+hexchat_gtk_cflags = []
 
-hexchat_gtk_ldflags = [
-  '-pie'
-]
+hexchat_gtk_ldflags = []
 
 if get_option('with-libnotify')
   hexchat_gtk_sources += 'notifications/notification-libnotify.c'
@@ -84,11 +80,16 @@ resources = gnome.compile_resources('resources',
   extra_args: ['--manual-register']
 )
 
+if host_machine.system() == 'windows'
+  hexchat_gtk_ldflags += '-Wl,-e,mainCRTStartup'
+endif
+
 executable('hexchat',
   sources:  resources + hexchat_gtk_sources,
   dependencies: hexchat_gtk_deps,
   c_args: hexchat_gtk_cflags,
   link_args: hexchat_gtk_ldflags,
+  pie: true,
   install: true,
   gui_app: true,
 )
diff --git a/src/fe-gtk/notifications/notifications-winrt.vcxproj b/src/fe-gtk/notifications/notifications-winrt.vcxproj
index 1f392b6b..2f6ffc99 100644
--- a/src/fe-gtk/notifications/notifications-winrt.vcxproj
+++ b/src/fe-gtk/notifications/notifications-winrt.vcxproj
@@ -1,62 +1,64 @@
-<?xml version="1.0" encoding="utf-8"?>

-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

-  <ItemGroup Label="ProjectConfigurations">

-    <ProjectConfiguration Include="Release|Win32">

-      <Configuration>Release</Configuration>

-      <Platform>Win32</Platform>

-    </ProjectConfiguration>

-    <ProjectConfiguration Include="Release|x64">

-      <Configuration>Release</Configuration>

-      <Platform>x64</Platform>

-    </ProjectConfiguration>

-  </ItemGroup>

-  <ItemGroup>

-    <ClCompile Include="notification-winrt.cpp">

-      <CompileAsWinRT>true</CompileAsWinRT>

-    </ClCompile>

-  </ItemGroup>

-  <PropertyGroup Label="Globals">

-    <ProjectGuid>{C53145CC-D021-40C9-B97C-0249AB9A43C9}</ProjectGuid>

-    <Keyword>Win32Proj</Keyword>

-    <RootNamespace>notifications-winrt</RootNamespace>

-    <ProjectName>notifications-winrt</ProjectName>

-  </PropertyGroup>

-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

-  <PropertyGroup Label="Configuration">

-    <PlatformToolset>v140</PlatformToolset>

-    <ConfigurationType>DynamicLibrary</ConfigurationType>

-    <CharacterSet>Unicode</CharacterSet>

-  </PropertyGroup>

-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

-  <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />

-  <Import Project="..\..\..\win32\hexchat.props" />

-  <PropertyGroup>

-    <TargetName>hcnotifications-winrt</TargetName>

-    <OutDir>$(HexChatRel)plugins\</OutDir>

-  </PropertyGroup>

-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

-    <ClCompile>

-      <PreprocessorDefinitions>WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_MEMORY;_CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES_MEMORY;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT;NDEBUG;_WINDOWS;_USRDLL;NOTIFICATIONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

-      <SDLCheck>true</SDLCheck>

-      <AdditionalUsingDirectories>$(VCInstallDir)vcpackages;$(FrameworkSdkDir)References\CommonConfiguration\Neutral;%(AdditionalUsingDirectories)</AdditionalUsingDirectories>

-    </ClCompile>

-    <Link>

-      <AdditionalDependencies>$(DepLibs);mincore.lib;runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>

-      <MinimumRequiredVersion>6.03</MinimumRequiredVersion>

-      <AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

-    </Link>

-  </ItemDefinitionGroup>

-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">

-    <ClCompile>

-      <PreprocessorDefinitions>WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_MEMORY;_CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES_MEMORY;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT;NDEBUG;_WINDOWS;_USRDLL;NOTIFICATIONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>

-      <SDLCheck>true</SDLCheck>

-      <AdditionalUsingDirectories>$(VCInstallDir)vcpackages;$(FrameworkSdkDir)References\CommonConfiguration\Neutral;%(AdditionalUsingDirectories)</AdditionalUsingDirectories>

-    </ClCompile>

-    <Link>

-      <AdditionalDependencies>$(DepLibs);mincore.lib;runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>

-      <MinimumRequiredVersion>6.03</MinimumRequiredVersion>

-      <AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

-    </Link>

-  </ItemDefinitionGroup>

-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

-</Project>

+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="notification-winrt.cpp">
+      <CompileAsWinRT>true</CompileAsWinRT>
+    </ClCompile>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{C53145CC-D021-40C9-B97C-0249AB9A43C9}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>notifications-winrt</RootNamespace>
+    <ProjectName>notifications-winrt</ProjectName>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Label="Configuration">
+    <PlatformToolset>v142</PlatformToolset>
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  <Import Project="..\..\..\win32\hexchat.props" />
+  <PropertyGroup>
+    <TargetName>hcnotifications-winrt</TargetName>
+    <OutDir>$(HexChatRel)plugins\</OutDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <PreprocessorDefinitions>WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_MEMORY;_CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES_MEMORY;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT;NDEBUG;_WINDOWS;_USRDLL;NOTIFICATIONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <SDLCheck>true</SDLCheck>
+      <AdditionalUsingDirectories>$(VC_LibraryPath_VC_x86_Store)\references;$(WindowsSDK_UnionMetadataPath);$(VCInstallDir)vcpackages;$(FrameworkSdkDir)References\CommonConfiguration\Neutral;%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
+      <CompileAsWinRT>true</CompileAsWinRT>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>$(DepLibs);mincore.lib;runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <MinimumRequiredVersion>6.03</MinimumRequiredVersion>
+      <AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <PreprocessorDefinitions>WIN32;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_MEMORY;_CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES_MEMORY;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT;NDEBUG;_WINDOWS;_USRDLL;NOTIFICATIONS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <SDLCheck>true</SDLCheck>
+      <AdditionalUsingDirectories>$(VC_LibraryPath_VC_x86_Store)\references;$(WindowsSDK_UnionMetadataPath);$(VCInstallDir)vcpackages;$(FrameworkSdkDir)References\CommonConfiguration\Neutral;%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
+      <CompileAsWinRT>true</CompileAsWinRT>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>$(DepLibs);mincore.lib;runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <MinimumRequiredVersion>6.03</MinimumRequiredVersion>
+      <AdditionalLibraryDirectories>$(DepsRoot)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+    </Link>
+  </ItemDefinitionGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+</Project>
diff --git a/src/fe-gtk/pixmaps.c b/src/fe-gtk/pixmaps.c
index 6c6cfaeb..9bdf46fc 100644
--- a/src/fe-gtk/pixmaps.c
+++ b/src/fe-gtk/pixmaps.c
@@ -89,7 +89,9 @@ pixmap_load_from_file (char *filename)
 static GdkPixbuf *
 load_pixmap (const char *filename)
 {
-	GdkPixbuf *pixbuf;
+	GdkPixbuf *pixbuf, *scaledpixbuf;
+	const char *scale;
+	int iscale;
 
 	gchar *path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "icons" G_DIR_SEPARATOR_S "%s.png", get_xdir (), filename);
 	pixbuf = gdk_pixbuf_new_from_file (path, 0);
@@ -102,6 +104,24 @@ load_pixmap (const char *filename)
 		g_free (path);
 	}
 
+	// Hack to avoid unbearably tiny icons on HiDPI screens.
+	scale = g_getenv ("GDK_SCALE");
+	if (scale)
+	{
+		iscale = atoi (scale);
+		if (iscale > 0)
+		{
+			scaledpixbuf = gdk_pixbuf_scale_simple (pixbuf, gdk_pixbuf_get_width (pixbuf) * iscale,
+				gdk_pixbuf_get_height (pixbuf) * iscale, GDK_INTERP_BILINEAR);
+
+			if (scaledpixbuf)
+			{
+				g_object_unref (pixbuf);
+				pixbuf = scaledpixbuf;
+			}
+		}
+	}
+
 	g_warn_if_fail (pixbuf != NULL);
 
 	return pixbuf;
diff --git a/src/fe-gtk/plugin-notification.c b/src/fe-gtk/plugin-notification.c
index 3ac89244..29478d7a 100644
--- a/src/fe-gtk/plugin-notification.c
+++ b/src/fe-gtk/plugin-notification.c
@@ -25,6 +25,9 @@
 
 static hexchat_plugin *ph;
 
+const int CHANNEL_FLAG_BALLOON       = 1 << 21;
+const int CHANNEL_FLAG_BALLOON_UNSET = 1 << 22;
+
 static gboolean
 should_alert (void)
 {
@@ -117,10 +120,24 @@ static int
 incoming_message_cb (char *word[], gpointer userdata)
 {
 	int message;
+	int flags;
+	int alert = 0;
+
+	flags = hexchat_list_int(ph, NULL, "flags");
+
+	/* Let sure that can alert */
+	if (should_alert()) {
+		/* Follow the channel rules if set */
+		if (!(flags & CHANNEL_FLAG_BALLOON_UNSET)) {
+			alert = (flags & CHANNEL_FLAG_BALLOON);
+		} else {
+			/* Else follow global environment */
+			alert = (hexchat_get_prefs(ph, "input_balloon_chans", NULL, &message) == 3 && message);
+		}
+	}
 
-	if (hexchat_get_prefs (ph, "input_balloon_chans", NULL, &message) == 3 && message && should_alert ())
-	{
-		show_notificationf (word[2], _("Channel message from: %s (%s)"), word[1], hexchat_get_info (ph, "channel"));
+	if (alert) {
+		show_notificationf(word[2], _("Channel message from: %s (%s)"), word[1], hexchat_get_info(ph, "channel"));
 	}
 	return HEXCHAT_EAT_NONE;
 }
@@ -129,8 +146,23 @@ static int
 incoming_priv_cb (char *word[], gpointer userdata)
 {
 	int priv;
+	int flags;
+	int alert = 0;
+
+	flags = hexchat_list_int(ph, NULL, "flags");
+
+	/* Let sure that can alert */
+	if (should_alert()) {
+		/* Follow the private rules if set */
+		if (!(flags & CHANNEL_FLAG_BALLOON_UNSET)) {
+			alert = (flags & CHANNEL_FLAG_BALLOON);
+		} else {
+			/* Else follow global environment */
+			alert = (hexchat_get_prefs(ph, "input_balloon_priv", NULL, &priv) == 3 && priv);
+		}
+	}
 
-	if (hexchat_get_prefs (ph, "input_balloon_priv", NULL, &priv) == 3 && priv && should_alert ())
+	if (alert)
 	{
 		const char *network = hexchat_get_info (ph, "network");
 		if (!network)
diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c
index fac0c4e6..418bb4da 100644
--- a/src/fe-gtk/xtext.c
+++ b/src/fe-gtk/xtext.c
@@ -283,8 +283,24 @@ backend_font_open (GtkXText *xtext, char *name)
 	metrics = pango_context_get_metrics (context, xtext->font->font, lang);
 	xtext->font->ascent = pango_font_metrics_get_ascent (metrics) / PANGO_SCALE;
 	xtext->font->descent = pango_font_metrics_get_descent (metrics) / PANGO_SCALE;
+
+	/*
+	 * In later versions of pango, a font's height should be calculated like
+	 * this to account for line gap; a typical symptom of not doing so is
+	 * cutting off the underscore on some fonts.
+	 */
+#if PANGO_VERSION_CHECK(1, 44, 0)
+	xtext->fontsize = pango_font_metrics_get_height (metrics) / PANGO_SCALE + 1;
+
+	if (xtext->fontsize == 0)
+		xtext->fontsize = xtext->font->ascent + xtext->font->descent;
+#else
+	xtext->fontsize = xtext->font->ascent + xtext->font->descent;
+#endif
+
 	pango_font_metrics_unref (metrics);
 }
+
 static int
 backend_get_text_width_emph (GtkXText *xtext, guchar *str, int len, int emphasis)
 {
@@ -3479,8 +3495,6 @@ gtk_xtext_set_font (GtkXText *xtext, char *name)
 	if (xtext->font == NULL)
 		return FALSE;
 
-	xtext->fontsize = xtext->font->ascent + xtext->font->descent;
-
 	{
 		char *time_str;
 		int stamp_size = xtext_get_stamp_str (time(0), &time_str);