Jan Synacek 0a11a4
commit 408bf21a8c8b5bf5a78785608255463ad1038871
Jan Synacek 0a11a4
Author: Robert Pluim <rpluim@gmail.com>
Jan Synacek 0a11a4
Date:   Tue Apr 3 11:06:01 2018 +0200
Jan Synacek 0a11a4
Jan Synacek 0a11a4
    Ignore color fonts when using Xft
Jan Synacek 0a11a4
    
Jan Synacek 0a11a4
    * src/font.c (syms_of_font): New configuration variable
Jan Synacek 0a11a4
    xft-ignore-color-fonts, default t.
Jan Synacek 0a11a4
    * src/ftfont.c (ftfont_spec_pattern): Tell fontconfig to ignore
Jan Synacek 0a11a4
    color fonts if xft-ignore-color-fonts is t.  (Bug#30874, Bug#30045)
Jan Synacek 0a11a4
    * etc/NEWS: Document xft-ignore-color-fonts.
Jan Synacek 0a11a4
Jan Synacek 0a11a4
diff --git a/src/font.c b/src/font.c
Jan Synacek 0a11a4
index a6d3f5d479..ef3f92b594 100644
Jan Synacek 0a11a4
--- a/src/font.c
Jan Synacek 0a11a4
+++ b/src/font.c
Jan Synacek 0a11a4
@@ -5473,6 +5473,13 @@ Disabling compaction of font caches might enlarge the Emacs memory
Jan Synacek 0a11a4
 footprint in sessions that use lots of different fonts.  */);
Jan Synacek 0a11a4
   inhibit_compacting_font_caches = 0;
Jan Synacek 0a11a4
 
Jan Synacek 0a11a4
+  DEFVAR_BOOL ("xft-ignore-color-fonts",
Jan Synacek 0a11a4
+	       Vxft_ignore_color_fonts,
Jan Synacek 0a11a4
+	       doc: /*
Jan Synacek 0a11a4
+Non-nil means don't query fontconfig for color fonts, since they often
Jan Synacek 0a11a4
+cause Xft crashes.  Only has an effect in Xft builds.  */);
Jan Synacek 0a11a4
+  Vxft_ignore_color_fonts = 1;
Jan Synacek 0a11a4
+
Jan Synacek 0a11a4
 #ifdef HAVE_WINDOW_SYSTEM
Jan Synacek 0a11a4
 #ifdef HAVE_FREETYPE
Jan Synacek 0a11a4
   syms_of_ftfont ();
Jan Synacek 0a11a4
diff --git a/src/ftfont.c b/src/ftfont.c
Jan Synacek 0a11a4
index c2e093e633..24a92dd52e 100644
Jan Synacek 0a11a4
--- a/src/ftfont.c
Jan Synacek 0a11a4
+++ b/src/ftfont.c
Jan Synacek 0a11a4
@@ -764,6 +764,13 @@ ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **ots
Jan Synacek 0a11a4
   if (scalable >= 0
Jan Synacek 0a11a4
       && ! FcPatternAddBool (pattern, FC_SCALABLE, scalable ? FcTrue : FcFalse))
Jan Synacek 0a11a4
     goto err;
Jan Synacek 0a11a4
+#ifdef HAVE_XFT
Jan Synacek 0a11a4
+  /* We really don't like color fonts, they cause Xft crashes.  See
Jan Synacek 0a11a4
+     Bug#30874.  */
Jan Synacek 0a11a4
+  if (Vxft_ignore_color_fonts
Jan Synacek 0a11a4
+      && ! FcPatternAddBool(pattern, FC_COLOR, FcFalse))
Jan Synacek 0a11a4
+    goto err;
Jan Synacek 0a11a4
+#endif
Jan Synacek 0a11a4
 
Jan Synacek 0a11a4
   goto finish;
Jan Synacek 0a11a4