0001-Ignore-color-fonts-when-using-Xft.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. From f21fa142aca53e3de5783e1ce6fe1bf116174aeb Mon Sep 17 00:00:00 2001
  2. From: Robert Pluim <rpluim@gmail.com>
  3. Date: Tue, 3 Apr 2018 11:06:01 +0200
  4. Subject: [PATCH] Ignore color fonts when using Xft
  5. * src/font.c (syms_of_font): New configuration variable
  6. xft-ignore-color-fonts, default t.
  7. * src/ftfont.c (ftfont_spec_pattern): Tell fontconfig to ignore
  8. color fonts if xft-ignore-color-fonts is t. (Bug#30874, Bug#30045)
  9. * etc/NEWS: Document xft-ignore-color-fonts.
  10. ---
  11. etc/NEWS | 6 ++++++
  12. src/font.c | 7 +++++++
  13. src/ftfont.c | 7 +++++++
  14. 3 files changed, 20 insertions(+)
  15. diff --git a/etc/NEWS b/etc/NEWS
  16. index 873e2dfd1d..2bec8de0ea 100644
  17. --- a/etc/NEWS
  18. +++ b/etc/NEWS
  19. @@ -31,6 +31,12 @@ in its NEWS.)
  20. * Changes in Emacs 26.2
  21. +---
  22. +** New variable 'xft-ignore-color-fonts'.
  23. +Default t means don't try to load color fonts when using Xft, as they
  24. +often cause crashes. Set it to nil if you really need those fonts.
  25. +(Bug#30874)
  26. +
  27. * Editing Changes in Emacs 26.2
  28. diff --git a/src/font.c b/src/font.c
  29. index e53935a15c..305bb14576 100644
  30. --- a/src/font.c
  31. +++ b/src/font.c
  32. @@ -5476,6 +5476,13 @@ Disabling compaction of font caches might enlarge the Emacs memory
  33. footprint in sessions that use lots of different fonts. */);
  34. inhibit_compacting_font_caches = 0;
  35. + DEFVAR_BOOL ("xft-ignore-color-fonts",
  36. + Vxft_ignore_color_fonts,
  37. + doc: /*
  38. +Non-nil means don't query fontconfig for color fonts, since they often
  39. +cause Xft crashes. Only has an effect in Xft builds. */);
  40. + Vxft_ignore_color_fonts = 1;
  41. +
  42. #ifdef HAVE_WINDOW_SYSTEM
  43. #ifdef HAVE_FREETYPE
  44. syms_of_ftfont ();
  45. diff --git a/src/ftfont.c b/src/ftfont.c
  46. index c2e093e633..24a92dd52e 100644
  47. --- a/src/ftfont.c
  48. +++ b/src/ftfont.c
  49. @@ -764,6 +764,13 @@ ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **ots
  50. if (scalable >= 0
  51. && ! FcPatternAddBool (pattern, FC_SCALABLE, scalable ? FcTrue : FcFalse))
  52. goto err;
  53. +#ifdef HAVE_XFT
  54. + /* We really don't like color fonts, they cause Xft crashes. See
  55. + Bug#30874. */
  56. + if (Vxft_ignore_color_fonts
  57. + && ! FcPatternAddBool(pattern, FC_COLOR, FcFalse))
  58. + goto err;
  59. +#endif
  60. goto finish;
  61. --
  62. 2.17.1