raboof / notion

Tiling tabbed window manager
https://notionwm.net/
GNU Lesser General Public License v2.1
268 stars 63 forks source link

Requesting invalid xft fonts doesn't generate an error message #318

Open dkogan opened 3 years ago

dkogan commented 3 years ago

Hi. Somebody just asked for xft support in the Debian notion package, so I rebuilt it, and ran some tests. The xft support works, but the error reporting isn't working properly. If I ask for a font "xft:bogus" which doesn't exist, I get SOME xft font (presumably a fall-back), but notion doesn't report the failure anywhere. This makes it difficult to know when it "worked", and when it didn't. Errors loading non-xft fonts ARE reported in the logs, in ~/.xsession-errors on Debian.

Thanks.

wilhelmy commented 3 years ago

I took a look at the code. Xft fonts are loaded along the other fonts in in de/font.c and it seems like XftFontOpenName does not return NULL in case an invalid Xft font specifier is found.

    if(strncmp(fontname, "xft:", 4)==0){
        font=XftFontOpenName(ioncore_g.dpy, DefaultScreen(ioncore_g.dpy), fontname+4);
    // some lines omitted
    if(font==NULL){

This thread suggests ditching Xft altogether and using cairo/pango or harfbuzz instead: https://xorg.freedesktop.narkive.com/4nxqqQiX/xft-problem-with-xftfontopenname-and-xftfontopen-functions

However I'm not sure whether that's the solution someone here will be eager to go for.

https://www.x.org/releases/X11R7.6/doc/man/man3/Xft.3.xhtml does not seem to mention anything about fallback fonts...

raboof commented 3 years ago

This thread suggests ditching Xft altogether and using cairo/pango or harfbuzz instead

Hmm, I'd prefer not to add further dependencies, and we haven't noticed much of the limitations of using xft directly...

wilhelmy commented 3 years ago

Haven't seen buggy window titles even with UTF-8 involved in a while, so maybe harfbuzz/pango are overrated. :)

I've definitely seen the fallback font behaviour with other software that uses Xft (urxvt). Not sure how to work around it. Asked on Freenode #xorg-devel but no response so far.