diff options
| author | Benjamin Otte <otte@redhat.com> | 2019-09-24 22:37:48 +0200 |
|---|---|---|
| committer | Benjamin Otte <otte@redhat.com> | 2019-09-24 22:39:38 +0200 |
| commit | bdb96507bd59daf9f4002ea170dc4c05ed368a3c (patch) | |
| tree | 8df35860abe66ec36483d842cb7182077f2e5cfe | |
| parent | 5d23819c699dc5a297569bb1c48309646aca0b27 (diff) | |
| download | gtk+-wip/otte/for-gtk-3-24.tar.gz | |
CSS: Handle unknown resolutionwip/otte/for-gtk-3-24
gdk_screen_get_resolution() can return -1 when the resolution is
unknown. Catch that case and use the default resolution of 96, like in
every other case.
Fixes #2119
| -rw-r--r-- | gtk/gtkcssshorthandpropertyimpl.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c index d46be8bd0d..53465a988c 100644 --- a/gtk/gtkcssshorthandpropertyimpl.c +++ b/gtk/gtkcssshorthandpropertyimpl.c @@ -1118,7 +1118,12 @@ 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 * gdk_screen_get_resolution (gdk_screen_get_default ()) / 72.0; + { + double dpi = gdk_screen_get_resolution (gdk_screen_get_default ()); + if (dpi <= 0.0) + dpi = 96.0; + size = size * dpi / 72.0; + } g_value_set_double (&v, size); prop = _gtk_style_property_lookup ("font-size"); _gtk_style_property_assign (prop, props, state, &v); |
