[gtk+/gtk-3-22] css: Add a workaround for gtk_widget_override_font()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-22] css: Add a workaround for gtk_widget_override_font()
- Date: Mon, 5 Feb 2018 17:59:19 +0000 (UTC)
commit 6ff326a82f1f7f13f8e0822576f19bb53c7b1fd8
Author: Benjamin Otte <otte redhat com>
Date: Tue Nov 14 04:03:57 2017 +0100
css: Add a workaround for gtk_widget_override_font()
The problem here is that the CSS machinery expects font sizes to be in
pixels, but gtk_widget_override_font() provides a value in point and the
CSS machinery has no ability to query the DPI and convert.
This patch changes the dconversion DPI we use from a hardcoded 96 to the
default screen's DPI, which should work better than before.
This will of course not listen to changes in the default screen's DPI,
but that shouldn't be a problem.
People who want to workaround this should use gtk_widget_override_font()
with a font that has an absolute size set via
pango_font_description_set_absolute_size (size * PANGO_SCALE *
gdk_screen_get_resolution (screen));
https://bugzilla.gnome.org/show_bug.cgi?id=774248
gtk/gtkcssshorthandpropertyimpl.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c
index 3931363..dc67a64 100644
--- a/gtk/gtkcssshorthandpropertyimpl.c
+++ b/gtk/gtkcssshorthandpropertyimpl.c
@@ -1118,7 +1118,7 @@ unpack_font_description (GtkCssShorthandProperty *shorthand,
g_value_init (&v, G_TYPE_DOUBLE);
size = pango_font_description_get_size (description) / PANGO_SCALE;
if (!pango_font_description_get_size_is_absolute (description))
- size = size * 96.0 / 72.0;
+ size = size * gdk_screen_get_resolution (gdk_screen_get_default ()) / 72.0;
g_value_set_double (&v, size);
prop = _gtk_style_property_lookup ("font-size");
_gtk_style_property_assign (prop, props, state, &v);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]