Fix color with FAINT attribute
[st.git] / x.c
diff --git a/x.c b/x.c
index 6474a01..c484dfc 100644 (file)
--- a/x.c
+++ b/x.c
@@ -88,7 +88,6 @@ static void xclear(int, int, int, int);
 static void xdrawcursor(void);
 static int xgeommasktogravity(int);
 static int xloadfont(Font *, FcPattern *);
-static void xsetsel(char *, Time);
 static void xunloadfont(Font *);
 
 static void expose(XEvent *);
@@ -1093,6 +1092,9 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
 
                        frc[frclen].font = XftFontOpenPattern(xw.dpy,
                                        fontpattern);
+                       if (!frc[frclen].font)
+                               die("XftFontOpenPattern failed seeking fallback font: %s\n",
+                                       strerror(errno));
                        frc[frclen].flags = frcflags;
                        frc[frclen].unicodep = rune;
 
@@ -1187,20 +1189,22 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
                }
        }
 
-       if (base.mode & ATTR_REVERSE) {
-               temp = fg;
-               fg = bg;
-               bg = temp;
-       }
-
        if ((base.mode & ATTR_BOLD_FAINT) == ATTR_FAINT) {
                colfg.red = fg->color.red / 2;
                colfg.green = fg->color.green / 2;
                colfg.blue = fg->color.blue / 2;
+               colfg.alpha = fg->color.alpha;
                XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, &revfg);
                fg = &revfg;
        }
 
+
+       if (base.mode & ATTR_REVERSE) {
+               temp = fg;
+               fg = bg;
+               bg = temp;
+       }
+
        if (base.mode & ATTR_BLINK && term.mode & MODE_BLINK)
                fg = bg;
 
@@ -1286,6 +1290,8 @@ xdrawcursor(void)
        xdrawglyph(og, oldx, oldy);
 
        g.u = term.line[term.c.y][term.c.x].u;
+       g.mode |= term.line[term.c.y][term.c.x].mode &
+                 (ATTR_BOLD | ATTR_ITALIC | ATTR_UNDERLINE | ATTR_STRUCK);
 
        /*
         * Select the right color for the right mode.