Re: [hackers] Re: [libsl][PATCH] Workaround Xft BadLength X error

From: Thomas Spurden <>
Date: Sun, 17 Feb 2019 12:44:00 +0000

(CCed reporter of Debian compile issue)

Excerpts from Hiltjo Posthuma's message of February 17, 2019 10:37 am:
> On Sun, Feb 17, 2019 at 09:13:04AM +0000, Thomas Spurden wrote:
>> Excerpts from Thomas Spurden's message of January 16, 2019 9:51 pm:
>> > Modify the fontconfig pattern to prefer non-color fonts, and discard any
>> > selected font which has the color flag set. Using these fonts with Xft is just
>> > going to generate a BadLength X error.
>> I have received a report from a Debian user that dwm doesn't compile on Debian
>> stable with this change. It appears Debian 9 has a version of fontconfig
>> (2.11.0) from before FC_COLOR was added (2.11.91).
>> Surrounding the patched lines with #ifdef FC_COLOR would allow compilation with
>> these older versions of fontconfig, but I assume will mean that the original
>> issue (Xft crashing dwm/dmenu) will recur on those systems.
>> Is it preferred to:
>> a) fail to compile with the older versions of fontconfig (current behaviour)
>> b) compile but crash at runtime if a color font is selected for a character
>> ?
> I've already seen this on Devuan/Debian stable.
> It's up to you how to handle this. There will be no more #ifdefs for this crap.
> I'm already not happy with this workaround and how the upstream developers
> handle this bug. It is very stupid each application has to implement this
> workaround now.

I agree that this is rubbish - it's only worth considering because of the
severity of the result (window title causes window manager to crash).

> Note that there may be more generic ways in Freetype to filter functionality
> like on color (when supported), prgname and other "filters".

I had a quick look and saw the FC_COLOR tag is based on a property of the
FT_Face flags, this appears to suffice (instead of my original patch):

--- a/drw.c
+++ b/drw.c
_AT_@ -132,6 +132,14 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
                die("no font specified.");
+ FT_Face face = XftLockFace(xfont);
+ if(face->face_flags & FT_FACE_FLAG_COLOR) {
+ XftUnlockFace(xfont);
+ XftFontClose(drw->dpy, xfont);
+ return NULL;
+ }
+ XftUnlockFace(xfont);
        font = ecalloc(1, sizeof(Fnt));
        font->xfont = xfont;
        font->pattern = pattern;

(Only had cursory testing)

I am happy with the original fix as I am on a distro with non-ancient
fontconfig. Anyone who wants to take the above and make a proper patch of it is
of course welcome to do so.
Received on Sun Feb 17 2019 - 13:44:00 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 17 2019 - 13:48:22 CET