diff src/font.c @ 110989:36726f009542

Fix handling of font properties on Windows (bug#6303). * src/font.c (font_filter_properties): New function, refactored from ftfont_filter_properties. * src/font.h (font_filter_properties): Declare. * src/ftfont.c (ftfont_filter_properties): Use font_filter_properties. * src/w32font.c (w32font_booleans, w32font_non_booleans): New variables. (w32font_filter_properties): New function. (w32font_driver): Add w32font_filter_properties.
author Juanma Barranquero <lekktu@gmail.com>
date Wed, 13 Oct 2010 16:07:28 +0200
parents cda2045a5ee8
children b8fde5ef9e14 0c4c440f303c
line wrap: on
line diff
--- a/src/font.c	Tue Oct 12 20:05:22 2010 -0700
+++ b/src/font.c	Wed Oct 13 16:07:28 2010 +0200
@@ -3862,6 +3862,59 @@
 }
 
 
+/* 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)
+          {
+            const char *str = INTEGERP (val) ? (XINT (val) ? "true" : "false")
+	      : SYMBOLP (val) ? (const char *) SDATA (SYMBOL_NAME (val))
+	      : "true";
+
+            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;
+	    else
+              val = Qt;
+
+            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