[gtk+/gtk-3-14] GtkSettings: Consider default settings for font hinting and antialias



commit eb0a76439c8511b8b3cc1cc6de0fdd1bcdaae5ec
Author: Matias De lellis <mati86dl gmail com>
Date:   Tue Dec 2 21:09:38 2014 -0300

    GtkSettings: Consider default settings for font hinting and antialias
    
    Arrange things so that gtk-xdg-hinting==-1 and gtk-xfg-antialias==-1
    end up as CAIRO_HINT_STYLE_DEFAULT and CAIRO_ANTIALIAS_DEFAULT in the
    cairo font options.
    
    This will not change anything on Linux desktops where xsettings will
    always provide values different from -1. But on other platforms, we
    can benefit from getting the platform-specific defaults in cairo.
    
    Based on the first patch in:
    https://bugzilla.gnome.org/show_bug.cgi?id=735316

 gtk/gtksettings.c |   53 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 32 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index 2cb6a81..644df01 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -2884,11 +2884,11 @@ settings_update_font_options (GtkSettings *settings)
   GtkSettingsPrivate *priv = settings->priv;
   gint hinting;
   gchar *hint_style_str;
-  cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_NONE;
+  cairo_hint_style_t hint_style;
   gint antialias;
-  cairo_antialias_t antialias_mode = CAIRO_ANTIALIAS_GRAY;
+  cairo_antialias_t antialias_mode;
   gchar *rgba_str;
-  cairo_subpixel_order_t subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
+  cairo_subpixel_order_t subpixel_order;
   cairo_font_options_t *options;
 
   g_object_get (settings,
@@ -2902,26 +2902,31 @@ settings_update_font_options (GtkSettings *settings)
 
   cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
 
-  if (hinting >= 0 && !hinting)
+  hint_style = CAIRO_HINT_STYLE_DEFAULT;
+  if (hinting == 0)
     {
       hint_style = CAIRO_HINT_STYLE_NONE;
     }
-  else if (hint_style_str)
+  else if (hinting == 1)
     {
-      if (strcmp (hint_style_str, "hintnone") == 0)
-        hint_style = CAIRO_HINT_STYLE_NONE;
-      else if (strcmp (hint_style_str, "hintslight") == 0)
-        hint_style = CAIRO_HINT_STYLE_SLIGHT;
-      else if (strcmp (hint_style_str, "hintmedium") == 0)
-        hint_style = CAIRO_HINT_STYLE_MEDIUM;
-      else if (strcmp (hint_style_str, "hintfull") == 0)
-        hint_style = CAIRO_HINT_STYLE_FULL;
+      if (hint_style_str)
+        {
+          if (strcmp (hint_style_str, "hintnone") == 0)
+            hint_style = CAIRO_HINT_STYLE_NONE;
+          else if (strcmp (hint_style_str, "hintslight") == 0)
+            hint_style = CAIRO_HINT_STYLE_SLIGHT;
+          else if (strcmp (hint_style_str, "hintmedium") == 0)
+            hint_style = CAIRO_HINT_STYLE_MEDIUM;
+          else if (strcmp (hint_style_str, "hintfull") == 0)
+            hint_style = CAIRO_HINT_STYLE_FULL;
+        }
     }
 
   g_free (hint_style_str);
 
   cairo_font_options_set_hint_style (options, hint_style);
 
+  subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
   if (rgba_str)
     {
       if (strcmp (rgba_str, "rgb") == 0)
@@ -2932,18 +2937,24 @@ settings_update_font_options (GtkSettings *settings)
         subpixel_order = CAIRO_SUBPIXEL_ORDER_VRGB;
       else if (strcmp (rgba_str, "vbgr") == 0)
         subpixel_order = CAIRO_SUBPIXEL_ORDER_VBGR;
-
-      g_free (rgba_str);
     }
 
+  g_free (rgba_str);
+
   cairo_font_options_set_subpixel_order (options, subpixel_order);
 
-  if (antialias >= 0 && !antialias)
-    antialias_mode = CAIRO_ANTIALIAS_NONE;
-  else if (subpixel_order != CAIRO_SUBPIXEL_ORDER_DEFAULT)
-    antialias_mode = CAIRO_ANTIALIAS_SUBPIXEL;
-  else if (antialias >= 0)
-    antialias_mode = CAIRO_ANTIALIAS_GRAY;
+  antialias_mode = CAIRO_ANTIALIAS_DEFAULT;
+  if (antialias == 0)
+    {
+      antialias_mode = CAIRO_ANTIALIAS_NONE;
+    }
+  else if (antialias == 1)
+    {
+      if (subpixel_order != CAIRO_SUBPIXEL_ORDER_DEFAULT)
+        antialias_mode = CAIRO_ANTIALIAS_SUBPIXEL;
+      else
+        antialias_mode = CAIRO_ANTIALIAS_GRAY;
+    }
 
   cairo_font_options_set_antialias (options, antialias_mode);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]