Commit 55d71d51 authored by Cosimo Cecchi's avatar Cosimo Cecchi
Browse files

window: ensure we actually set a monospace font description

We were calling gtk_widget_modify_font() with the monospace font
description and then immediately calling
gtk_widget_create_pango_context() to query its pango description,
assuming it was the same we just set.
Since this assumption is not true anymore with recent GTK, own the
monospace pango description ourselves and always query from that.
parent 60f31e4a
......@@ -43,6 +43,8 @@ struct _LogviewWindowPrivate {
GtkActionGroup *action_group;
GtkActionGroup *filter_action_group;
PangoFontDescription *monospace_description;
GtkWidget *find_bar;
GtkWidget *loglist;
GtkWidget *sidebar;
......@@ -229,29 +231,30 @@ static void
logview_set_font (LogviewWindow *logview,
const char *fontname)
{
PangoFontDescription *font_desc;
LogviewWindowPrivate *priv = logview->priv;
if (fontname == NULL)
fontname = DEFAULT_LOGVIEW_FONT;
font_desc = pango_font_description_from_string (fontname);
if (font_desc) {
gtk_widget_modify_font (logview->priv->text_view, font_desc);
pango_font_description_free (font_desc);
}
if (priv->monospace_description != NULL)
pango_font_description_free (priv->monospace_description);
priv->monospace_description = pango_font_description_from_string (fontname);
gtk_widget_override_font (priv->text_view, priv->monospace_description);
/* remember the original font size */
priv->original_fontsize =
pango_font_description_get_size (priv->monospace_description) / PANGO_SCALE;
}
static void
logview_set_fontsize (LogviewWindow *logview, gboolean store)
{
PangoFontDescription *fontdesc;
PangoContext *context;
LogviewWindowPrivate *priv = logview->priv;
context = gtk_widget_get_pango_context (priv->text_view);
fontdesc = pango_context_get_font_description (context);
pango_font_description_set_size (fontdesc, (priv->fontsize) * PANGO_SCALE);
gtk_widget_modify_font (priv->text_view, fontdesc);
pango_font_description_set_size (priv->monospace_description,
(priv->fontsize) * PANGO_SCALE);
gtk_widget_override_font (priv->text_view, priv->monospace_description);
if (store) {
logview_prefs_store_fontsize (logview->priv->prefs, priv->fontsize);
......@@ -1186,6 +1189,8 @@ logview_window_finalize (GObject *object)
LogviewWindow *logview = LOGVIEW_WINDOW (object);
g_object_unref (logview->priv->ui_manager);
pango_font_description_free (logview->priv->monospace_description);
G_OBJECT_CLASS (logview_window_parent_class)->finalize (object);
}
......@@ -1196,8 +1201,6 @@ logview_window_init (LogviewWindow *logview)
GtkAccelGroup *accel_group;
GError *error = NULL;
GtkWidget *hpaned, *main_view, *vbox, *w;
PangoContext *context;
PangoFontDescription *fontdesc;
gchar *monospace_font_name;
LogviewWindowPrivate *priv;
int width, height;
......@@ -1305,11 +1308,6 @@ logview_window_init (LogviewWindow *logview)
logview_set_font (logview, monospace_font_name);
g_free (monospace_font_name);
/* remember the original font size */
context = gtk_widget_get_pango_context (priv->text_view);
fontdesc = pango_context_get_font_description (context);
priv->original_fontsize = pango_font_description_get_size (fontdesc) / PANGO_SCALE;
/* restore saved zoom */
priv->fontsize = logview_prefs_get_stored_fontsize (priv->prefs);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment