summaryrefslogtreecommitdiff
path: root/src/font.c
diff options
context:
space:
mode:
authorDamyan Pepper <damyanp@gmail.com>2010-10-13 16:07:28 +0200
committerJuanma Barranquero <lekktu@gmail.com>2010-10-13 16:07:28 +0200
commit9fa828240d621736a61f5938f78cc98805fdcf56 (patch)
tree799e6075c0e1a467522070c065165b5aeac32f95 /src/font.c
parent7163badd35f9dc49dc5c0a26d2c037f8d4fb5ee7 (diff)
downloademacs-9fa828240d621736a61f5938f78cc98805fdcf56.tar.gz
emacs-9fa828240d621736a61f5938f78cc98805fdcf56.tar.bz2
emacs-9fa828240d621736a61f5938f78cc98805fdcf56.zip
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.
Diffstat (limited to 'src/font.c')
-rw-r--r--src/font.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/font.c b/src/font.c
index c72f189d87f..77f43c81d71 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3862,6 +3862,59 @@ font_get_frame_data (f, driver)
}
+/* 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