Subject: bug#6303: W32 Antialiased fonts

From: Damyan Pepper <[email-masked]>
Date: Thu, 1 Jul 2010 17:07:11 +0100

> On Tue, Jun 29, 2010 at 10:38 AM, Juanma Barranquero <[email-masked]> wrote:
>> Send the refactored patch, so we don't need to test two different ones.

Attached is the refactored patch.

I've moved the implementation of ftfont_filter_properties into
font_filter_properties, also applying the cleanup you suggested.
ftfont_filter_properties now calls this new function. Added
w32font_filter_properties.

I'm afraid I've not been able to test this in an environment that uses ftfont.

Are you able to advise me on how to go about getting hold of the papers to sign?

Regards,

Damyan.
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: dpepper@sw-gbbr-brsd015-20100701155900-jpejfg0c2hm1ruhp
# target_branch: http://bzr.savannah.gnu.org/r/emacs/trunk/
# testament_sha1: 00e5e10c74ec1a385bf3916399c1c3a9b75cf656
# timestamp: 2010-07-01 17:00:50 +0100
# base_revision_id: [email-masked]
# 
# Begin patch
=== modified file 'src/ChangeLog'
--- src/ChangeLog	2010-06-29 09:49:20 +0000
+++ src/ChangeLog	2010-07-01 15:59:00 +0000
@@ -1,3 +1,11 @@
+2010-07-01  Damyan Pepper  <[email-masked]>
+
+	* gtfont.c (gtfont_filter_properties): Now calls
+	font_filter_properties.
+	* font.c (font_filter_properties): New function, refactored from
+	gtfont_filter_properties.
+	* w32font.c (w32font_filter_properties): New function (Bug#6303).
+
 2010-06-29  Jan Djärv  <[email-masked]>
 
 	* nsfns.m: extern declare Vmenu_bar_mode, Vtool_bar_mode.

=== modified file 'src/font.c'
--- src/font.c	2010-06-22 06:42:00 +0000
+++ src/font.c	2010-07-01 15:54:59 +0000
@@ -3895,6 +3895,62 @@
 }

+/* Sets attributes on a font.  Any properties that appear in ALIST and
+   BOOLEAN_PROPERTIES or NON_BOOLEAN_PROPERTIES are set on the font.
+   BOOLEAN_PROPERTIES and NON_BOOLEAN_PROPERTIES are NULL-terminated
+   arrays of strings.  This function is intended for use by the font
+   drivers to implement their specific font_filter_properties.  */
+void
+font_filter_properties (font, alist, boolean_properties, non_boolean_properties)
+     Lisp_Object font;
+     Lisp_Object alist;
+     const char *boolean_properties[];
+     const char *non_boolean_properties[];
+{
+  Lisp_Object it;
+  int i;
+
+  /* Set boolean values to Qt or Qnil */
+  for (i = 0; boolean_properties[i] != NULL; ++i)
+    for (it = alist; ! NILP (it); it = XCDR (it))
+      {
+        Lisp_Object key = XCAR (XCAR (it));
+        Lisp_Object val = XCDR (XCAR (it));
+        char *keystr = SDATA (SYMBOL_NAME (key));
+
+        if (strcmp (boolean_properties[i], keystr) == 0)
+          {
+            char *str;
+
+            if (INTEGERP (val)) 
+	      str = XINT (val) != 0 ? "true" : "false";
+	    else if (SYMBOLP (val))
+	      str = SDATA (SYMBOL_NAME (val));
+	    else
+	      str = "true";
+
+            val = Qt;
+            if (strcmp ("false", str) == 0 || strcmp ("False", str) == 0
+                || strcmp ("FALSE", str) == 0 || strcmp ("FcFalse", str) == 0
+                || strcmp ("off", str) == 0 || strcmp ("OFF", str) == 0
+                || strcmp ("Off", str) == 0)
+              val = Qnil;
+            Ffont_put (font, key, val);
+          }
+      }
+
+  for (i = 0; non_boolean_properties[i] != NULL; ++i)
+    for (it = alist; ! NILP (it); it = XCDR (it))
+      {
+        Lisp_Object key = XCAR (XCAR (it));
+        Lisp_Object val = XCDR (XCAR (it));
+        char *keystr = SDATA (SYMBOL_NAME (key));
+        if (strcmp (non_boolean_properties[i], keystr) == 0)
+          Ffont_put (font, key, val);
+      }
+}
+
+
 /* Return the font used to draw character C by FACE at buffer position
    POS in window W.  If STRING is non-nil, it is a string containing C
    at index POS.  If C is negative, get C from the current buffer or

=== modified file 'src/font.h'
--- src/font.h	2010-01-13 08:35:10 +0000
+++ src/font.h	2010-07-01 15:54:59 +0000
@@ -814,6 +814,11 @@
 extern void *font_get_frame_data P_ ((FRAME_PTR f,
 				      struct font_driver *driver));
 
+extern void font_filter_properties P_ ((Lisp_Object font,
+                                        Lisp_Object alist,
+                                        const char *boolean_properties[],
+                                        const char *non_boolean_properties[]));
+
 #ifdef HAVE_FREETYPE
 extern struct font_driver ftfont_driver;
 #endif	/* HAVE_FREETYPE */

=== modified file 'src/ftfont.c'
--- src/ftfont.c	2010-05-11 11:15:29 +0000
+++ src/ftfont.c	2010-07-01 15:54:59 +0000
@@ -2681,42 +2681,7 @@
      Lisp_Object font;
      Lisp_Object alist;
 {
-  Lisp_Object it;
-  int i;
-
-  /* Set boolean values to Qt or Qnil */
-  for (i = 0; ftfont_booleans[i] != NULL; ++i)
-    for (it = alist; ! NILP (it); it = XCDR (it))
-      {
-        Lisp_Object key = XCAR (XCAR (it));
-        Lisp_Object val = XCDR (XCAR (it));
-        char *keystr = SDATA (SYMBOL_NAME (key));
-
-        if (strcmp (ftfont_booleans[i], keystr) == 0)
-          {
-            char *str = SYMBOLP (val) ? SDATA (SYMBOL_NAME (val)) : NULL;
-            if (INTEGERP (val)) str = XINT (val) != 0 ? "true" : "false";
-            if (str == NULL) str = "true";
-
-            val = Qt;
-            if (strcmp ("false", str) == 0 || strcmp ("False", str) == 0
-                || strcmp ("FALSE", str) == 0 || strcmp ("FcFalse", str) == 0
-                || strcmp ("off", str) == 0 || strcmp ("OFF", str) == 0
-                || strcmp ("Off", str) == 0)
-              val = Qnil;
-            Ffont_put (font, key, val);
-          }
-      }
-
-  for (i = 0; ftfont_non_booleans[i] != NULL; ++i)
-    for (it = alist; ! NILP (it); it = XCDR (it))
-      {
-        Lisp_Object key = XCAR (XCAR (it));
-        Lisp_Object val = XCDR (XCAR (it));
-        char *keystr = SDATA (SYMBOL_NAME (key));
-        if (strcmp (ftfont_non_booleans[i], keystr) == 0)
-          Ffont_put (font, key, val);
-      }
+  font_filter_properties (font, alist, ftfont_booleans, ftfont_non_booleans);
 }

=== modified file 'src/w32font.c'
--- src/w32font.c	2010-01-13 08:35:10 +0000
+++ src/w32font.c	2010-07-01 15:54:59 +0000
@@ -2446,6 +2446,24 @@
   return DECODE_SYSTEM (build_string (buf));
 }
 
+static const char *w32font_booleans [] = {
+  NULL,
+};
+
+static const char *w32font_non_booleans [] = {
+  ":script",
+  ":antialias",
+  NULL,
+};
+
+static void
+w32font_filter_properties (font, alist)
+    Lisp_Object font;
+    Lisp_Object alist;
+{
+  font_filter_properties (font, alist, w32font_booleans, w32font_non_booleans);
+}
+
 struct font_driver w32font_driver =
   {
     0, /* Qgdi */
@@ -2475,7 +2493,7 @@
     NULL, /* shape */
     NULL, /* check */
     NULL, /* get_variation_glyphs */
-    NULL, /* filter_properties */
+    w32font_filter_properties,
   };

# Begin bundle