[gtk+] css: Convert numbers with GTK's dpi
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] css: Convert numbers with GTK's dpi
- Date: Fri, 5 Feb 2016 13:53:24 +0000 (UTC)
commit 5444442974f55df857b0c5169e481ac8abc93ea7
Author: Benjamin Otte <otte redhat com>
Date: Fri Feb 5 14:50:37 2016 +0100
css: Convert numbers with GTK's dpi
Don't hardcode 96 for dpi, but instead use the value of the -gtk-dpi
property (that mirrors the GdkScreen's dpi if it wasn't set explicitly).
This makes these values scale when the large font setting in
control-center is enabled.
gtk/gtkcssnumbervalue.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkcssnumbervalue.c b/gtk/gtkcssnumbervalue.c
index 17322e3..d32bff5 100644
--- a/gtk/gtkcssnumbervalue.c
+++ b/gtk/gtkcssnumbervalue.c
@@ -53,7 +53,13 @@ get_base_font_size (guint property_id,
return _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_FONT_SIZE), 100);
}
-
+
+static double
+get_dpi (GtkCssStyle *style)
+{
+ return _gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_DPI), 96);
+}
+
static GtkCssValue *
gtk_css_value_number_compute (GtkCssValue *number,
guint property_id,
@@ -112,31 +118,31 @@ gtk_css_value_number_compute (GtkCssValue *number,
case GTK_CSS_S:
return _gtk_css_value_ref (number);
case GTK_CSS_PT:
- return _gtk_css_number_value_new (number->value * 96.0 / 72.0,
+ return _gtk_css_number_value_new (number->value * get_dpi (style) / 72.0,
GTK_CSS_PX);
case GTK_CSS_PC:
- return _gtk_css_number_value_new (number->value * 96.0 / 72.0 * 12.0,
+ return _gtk_css_number_value_new (number->value * get_dpi (style) / 72.0 * 12.0,
GTK_CSS_PX);
case GTK_CSS_IN:
- return _gtk_css_number_value_new (number->value * 96.0,
+ return _gtk_css_number_value_new (number->value * get_dpi (style),
GTK_CSS_PX);
case GTK_CSS_CM:
- return _gtk_css_number_value_new (number->value * 96.0 * 0.39370078740157477,
+ return _gtk_css_number_value_new (number->value * get_dpi (style) * 0.39370078740157477,
GTK_CSS_PX);
case GTK_CSS_MM:
- return _gtk_css_number_value_new (number->value * 96.0 * 0.039370078740157477,
+ return _gtk_css_number_value_new (number->value * get_dpi (style) * 0.039370078740157477,
GTK_CSS_PX);
case GTK_CSS_EM:
- return _gtk_css_number_value_new (number->value * 96.0 / 72.0 *
+ return _gtk_css_number_value_new (number->value * get_dpi (style) / 72.0 *
get_base_font_size (property_id, provider, style, parent_style),
GTK_CSS_PX);
case GTK_CSS_EX:
/* for now we pretend ex is half of em */
- return _gtk_css_number_value_new (number->value * 0.5 * 96.0 / 72.0 *
+ return _gtk_css_number_value_new (number->value * 0.5 * get_dpi (style) / 72.0 *
get_base_font_size (property_id, provider, style, parent_style),
GTK_CSS_PX);
case GTK_CSS_REM:
- return _gtk_css_number_value_new (number->value * 96.0 / 72.0 *
+ return _gtk_css_number_value_new (number->value * get_dpi (style) / 72.0 *
_gtk_css_font_size_get_default (provider),
GTK_CSS_PX);
case GTK_CSS_RAD:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]