[dev] [st] [PATCH] Make missing attribute fallback color optional

From: Eric Pruitt <eric.pruitt_AT_gmail.com>
Date: Wed, 14 Dec 2016 19:53:57 -0800

I wasted an hour trying to figure out why st on different hosts using
the exact same terminfo configuration and statically compiled tmux was
displaying some text in yellow. The hosts where this produced yellow
text were using an Ubuntu-based Linux distro while the hosts where st
continued to work as it always had were using Debian 8. I didn't dig
into the problem too much after I narrowed down the problem to a
specific commit, so I don't know which attributes st was unable to find.
However, the output rendered on the hosts that st's font selection
thought had incorrect attributes is almost a pixel perfect match for the
hosts where st was able to find a font that was an exact match which
makes this fallback color a false-positive for all practical intents. I
have modified st to make the fallback coloring optional because I'm sure
this is going to surprise someone else in the future, too.
---
 config.def.h | 2 +-
 st.c         | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git config.def.h config.def.h
index 32d107d..2e29064 100644
--- config.def.h
+++ config.def.h
_AT_@ -139,7 +139,7 @@ static unsigned int mousebg = 0;
 
 /*
  * Color used to display font attributes when fontconfig selected a font which
- * doesn't match the ones requested.
+ * doesn't match the ones requested. Set this to 0 to disable this feature.
  */
 static unsigned int defaultattr = 11;
 
diff --git st.c st.c
index d6fe58a..2ee04fa 100644
--- st.c
+++ st.c
_AT_@ -3824,10 +3824,10 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
 
 	/* Fallback on color display for attributes not supported by the font */
 	if (base.mode & ATTR_ITALIC && base.mode & ATTR_BOLD) {
-		if (dc.ibfont.badslant || dc.ibfont.badweight)
+		if (defaultattr && (dc.ibfont.badslant || dc.ibfont.badweight))
 			base.fg = defaultattr;
-	} else if ((base.mode & ATTR_ITALIC && dc.ifont.badslant) ||
-	    (base.mode & ATTR_BOLD && dc.bfont.badweight)) {
+	} else if (defaultattr && ((base.mode & ATTR_ITALIC && dc.ifont.badslant) ||
+	    (base.mode & ATTR_BOLD && dc.bfont.badweight))) {
 		base.fg = defaultattr;
 	}
 
-- 
2.1.4
Received on Thu Dec 15 2016 - 04:53:57 CET

This archive was generated by hypermail 2.3.0 : Thu Dec 15 2016 - 05:00:15 CET