diff options
author | Matthias Clasen <mclasen@redhat.com> | 2016-05-01 01:10:59 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2016-05-01 01:10:59 -0400 |
commit | 309c6dfaf8a081166e28e4109db96c2292151edd (patch) | |
tree | 18a310c88c434301f9d1815a4197e76b68c18da2 /gtk/gtkcssenumvalue.c | |
parent | 71d68168171fb49f6436ca94eb0a87fe5a17c107 (diff) | |
download | gtk+-309c6dfaf8a081166e28e4109db96c2292151edd.tar.gz |
css: Use setters for font size and family
This avoid creating pango font descriptions all the time, when
the gtk-font-name setting hasn't actually changed.
Diffstat (limited to 'gtk/gtkcssenumvalue.c')
-rw-r--r-- | gtk/gtkcssenumvalue.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c index 7cb0adc4a2..607b7c13a0 100644 --- a/gtk/gtkcssenumvalue.c +++ b/gtk/gtkcssenumvalue.c @@ -144,30 +144,19 @@ gtk_css_font_size_get_default_px (GtkStyleProviderPrivate *provider, { GtkSettings *settings; PangoFontDescription *description; - char *font_name; - double font_size; + int font_size; settings = _gtk_style_provider_private_get_settings (provider); if (settings == NULL) return DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0; - - g_object_get (settings, "gtk-font-name", &font_name, NULL); - description = pango_font_description_from_string (font_name); - g_free (font_name); - if (description == NULL) - return DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0; - if (pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_SIZE) - { - font_size = (double) pango_font_description_get_size (description) / PANGO_SCALE; - if (!pango_font_description_get_size_is_absolute (description)) - font_size = font_size * get_dpi (style) / 72.0; - } + font_size = gtk_settings_get_font_size (settings); + if (font_size == 0) + return DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0; + else if (gtk_settings_get_font_size_is_absolute (settings)) + return (double) font_size / PANGO_SCALE; else - font_size = DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0; - - pango_font_description_free (description); - return font_size; + return ((double) font_size / PANGO_SCALE) * get_dpi (style) / 72.0; } static GtkCssValue * |