[gtk+] Take font size also from the font description
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Take font size also from the font description
- Date: Tue, 13 Sep 2011 10:59:11 +0000 (UTC)
commit 71c16bad3353202ca55fe15a092b3bcf7085097e
Author: Christian Persch <chpe gnome org>
Date: Mon Sep 12 21:26:21 2011 +0200
Take font size also from the font description
gtk/gtkfontbutton.c | 5 +++++
gtk/gtkfontchooserwidget.c | 13 +++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkfontbutton.c b/gtk/gtkfontbutton.c
index d10de4c..5e65fb6 100644
--- a/gtk/gtkfontbutton.c
+++ b/gtk/gtkfontbutton.c
@@ -354,6 +354,11 @@ gtk_font_button_take_font_desc (GtkFontButton *font_button,
else
priv->font_desc = pango_font_description_from_string (_("Sans 12"));
+ if (pango_font_description_get_size_is_absolute (priv->font_desc))
+ priv->font_size = pango_font_description_get_size (priv->font_desc);
+ else
+ priv->font_size = pango_font_description_get_size (priv->font_desc) / PANGO_SCALE;
+
gtk_font_button_update_font_data (font_button);
gtk_font_button_update_font_info (font_button);
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index 4302285..af4bda5 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -320,17 +320,19 @@ spin_change_cb (GtkAdjustment *adjustment,
GtkFontChooserWidget *fontchooser = (GtkFontChooserWidget*)user_data;
GtkFontChooserWidgetPrivate *priv = fontchooser->priv;
GtkAdjustment *slider_adj = gtk_range_get_adjustment (GTK_RANGE (priv->size_slider));
-
gdouble size = gtk_adjustment_get_value (adjustment);
+
priv->size = ((gint)size) * PANGO_SCALE;
desc = pango_context_get_font_description (gtk_widget_get_pango_context (priv->preview));
pango_font_description_set_size (desc, priv->size);
gtk_widget_override_font (priv->preview, desc);
- g_object_notify (G_OBJECT (fontchooser), "font");
- g_object_notify (G_OBJECT (fontchooser), "font-desc");
-
+ if (pango_font_description_get_size_is_absolute (priv->font_desc))
+ pango_font_description_set_absolute_size (priv->font_desc, size);
+ else
+ pango_font_description_set_size (priv->font_desc, priv->size);
+
/* If the new value is lower than the lower bound of the slider, we set
* the slider adjustment to the lower bound value if it is not already set
*/
@@ -350,6 +352,9 @@ spin_change_cb (GtkAdjustment *adjustment,
gtk_adjustment_set_value (slider_adj, size);
gtk_widget_queue_draw (priv->preview);
+
+ g_object_notify (G_OBJECT (fontchooser), "font");
+ g_object_notify (G_OBJECT (fontchooser), "font-desc");
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]