Dear fellow hackers,

this patch will hopefully resolve the many mails we get on dev@ and
hackers@ regarding crashes of st due to emoji-fonts triggering some
voodoo-condition in Xft.

I hope my port of Anselm's change to dwm to st is correct and would
love to hear feedback.

With best regards

Laslo Hunhold

-- 
Laslo Hunhold <d...@frign.de>
>From 69cfb2193f5e7bb8dda42b3dc5474e3d04170ad1 Mon Sep 17 00:00:00 2001
From: Laslo Hunhold <d...@frign.de>
Date: Tue, 23 Apr 2019 10:02:14 +0200
Subject: [PATCH] Work around BadLength error by disallowing color fonts

This problem has given us enough trouble on the ML alone and is a
bug in the Xft library that probably won't ever be fixed.

This change is a port of Anselm's commit to dwm
(cb3f58ad06993f7ef3a7d8f61468012e2b786cab).
---
 LICENSE |  4 ++--
 x.c     | 12 ++++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/LICENSE b/LICENSE
index c356c39..07518e3 100644
--- a/LICENSE
+++ b/LICENSE
@@ -4,7 +4,7 @@ MIT/X Consortium License
 © 2018 Devin J. Pohly <djpohly at gmail dot com>
 © 2014-2017 Quentin Rameau <quinq at fifth dot space>
 © 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
-© 2008-2017 Anselm R Garbe <garbeam at gmail dot com>
+© 2008-2019 Anselm R Garbe <garbeam at gmail dot com>
 © 2012-2017 Roberto E. Vargas Caballero <k0ga at shike2 dot com>
 © 2012-2016 Christoph Lohmann <20h at r-36 dot net>
 © 2013 Eon S. Jeon <esjeon at hyunmu dot am>
@@ -13,7 +13,7 @@ MIT/X Consortium License
 © 2013-2014 Eric Pruitt <eric.pruitt at gmail dot com>
 © 2013 Michael Forney <mforney at mforney dot org>
 © 2013-2014 Markus Teich <markus dot teich at stusta dot mhn dot de>
-© 2014-2015 Laslo Hunhold <dev at frign dot de>
+© 2014-2019 Laslo Hunhold <dev at frign dot de>
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the "Software"),
diff --git a/x.c b/x.c
index 5828a3b..074df47 100644
--- a/x.c
+++ b/x.c
@@ -837,12 +837,24 @@ xgeommasktogravity(int mask)
 int
 xloadfont(Font *f, FcPattern *pattern)
 {
+	FcBool iscol;
 	FcPattern *configured;
 	FcPattern *match;
 	FcResult result;
 	XGlyphInfo extents;
 	int wantattr, haveattr;
 
+	/* Do not allow using color fonts. This is a workaround for a BadLength
+	 * error from Xft with color glyphs. Modelled on the Xterm workaround. See
+	 * https://bugzilla.redhat.com/show_bug.cgi?id=1498269
+	 * https://lists.suckless.org/dev/1701/30932.html
+	 * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
+	 * and lots more all over the internet.
+	 */
+	if(FcPatternGetBool(pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
+		return 1;
+	}
+
 	/*
 	 * Manually configure instead of calling XftMatchFont
 	 * so that we can use the configured pattern for
-- 
2.21.0

Attachment: pgphRfiDcoPen.pgp
Description: PGP signature

Reply via email to