diff options
| -rw-r--r-- | config.def.h | 8 | ||||
| -rw-r--r-- | st.c | 40 |
2 files changed, 35 insertions, 13 deletions
diff --git a/config.def.h b/config.def.h index c2e4ffd..7f465d1 100644 --- a/config.def.h +++ b/config.def.h | |||
| @@ -138,12 +138,10 @@ static unsigned int mousefg = 7; | |||
| 138 | static unsigned int mousebg = 0; | 138 | static unsigned int mousebg = 0; |
| 139 | 139 | ||
| 140 | /* | 140 | /* |
| 141 | * Colors used, when the specific fg == defaultfg. So in reverse mode this | 141 | * Color used to display font attributes when fontconfig selected a font which |
| 142 | * will reverse too. Another logic would only make the simple feature too | 142 | * doesn't match the ones requested. |
| 143 | * complex. | ||
| 144 | */ | 143 | */ |
| 145 | static unsigned int defaultitalic = 11; | 144 | static unsigned int defaultattr = 11; |
| 146 | static unsigned int defaultunderline = 7; | ||
| 147 | 145 | ||
| 148 | /* | 146 | /* |
| 149 | * Internal mouse shortcuts. | 147 | * Internal mouse shortcuts. |
| @@ -354,6 +354,8 @@ typedef struct { | |||
| 354 | int width; | 354 | int width; |
| 355 | int ascent; | 355 | int ascent; |
| 356 | int descent; | 356 | int descent; |
| 357 | int badslant; | ||
| 358 | int badweight; | ||
| 357 | short lbearing; | 359 | short lbearing; |
| 358 | short rbearing; | 360 | short rbearing; |
| 359 | XftFont *match; | 361 | XftFont *match; |
| @@ -3373,6 +3375,7 @@ xloadfont(Font *f, FcPattern *pattern) | |||
| 3373 | FcPattern *match; | 3375 | FcPattern *match; |
| 3374 | FcResult result; | 3376 | FcResult result; |
| 3375 | XGlyphInfo extents; | 3377 | XGlyphInfo extents; |
| 3378 | int wantattr, haveattr; | ||
| 3376 | 3379 | ||
| 3377 | match = XftFontMatch(xw.dpy, xw.scr, pattern, &result); | 3380 | match = XftFontMatch(xw.dpy, xw.scr, pattern, &result); |
| 3378 | if (!match) | 3381 | if (!match) |
| @@ -3383,6 +3386,28 @@ xloadfont(Font *f, FcPattern *pattern) | |||
| 3383 | return 1; | 3386 | return 1; |
| 3384 | } | 3387 | } |
| 3385 | 3388 | ||
| 3389 | if ((XftPatternGetInteger(pattern, "slant", 0, &wantattr) == | ||
| 3390 | XftResultMatch)) { | ||
| 3391 | /* | ||
| 3392 | * Check if xft was unable to find a font with the appropriate | ||
| 3393 | * slant but gave us one anyway. Try to mitigate. | ||
| 3394 | */ | ||
| 3395 | if ((XftPatternGetInteger(f->match->pattern, "slant", 0, | ||
| 3396 | &haveattr) != XftResultMatch) || haveattr < wantattr) { | ||
| 3397 | f->badslant = 1; | ||
| 3398 | fputs("st: font slant does not match\n", stderr); | ||
| 3399 | } | ||
| 3400 | } | ||
| 3401 | |||
| 3402 | if ((XftPatternGetInteger(pattern, "weight", 0, &wantattr) == | ||
| 3403 | XftResultMatch)) { | ||
| 3404 | if ((XftPatternGetInteger(f->match->pattern, "weight", 0, | ||
| 3405 | &haveattr) != XftResultMatch) || haveattr != wantattr) { | ||
| 3406 | f->badweight = 1; | ||
| 3407 | fputs("st: font weight does not match\n", stderr); | ||
| 3408 | } | ||
| 3409 | } | ||
| 3410 | |||
| 3386 | XftTextExtentsUtf8(xw.dpy, f->match, | 3411 | XftTextExtentsUtf8(xw.dpy, f->match, |
| 3387 | (const FcChar8 *) ascii_printable, | 3412 | (const FcChar8 *) ascii_printable, |
| 3388 | strlen(ascii_printable), &extents); | 3413 | strlen(ascii_printable), &extents); |
| @@ -3780,14 +3805,13 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i | |||
| 3780 | XRenderColor colfg, colbg; | 3805 | XRenderColor colfg, colbg; |
| 3781 | XRectangle r; | 3806 | XRectangle r; |
| 3782 | 3807 | ||
| 3783 | /* Determine foreground and background colors based on mode. */ | 3808 | /* Fallback on color display for attributes not supported by the font */ |
| 3784 | if (base.fg == defaultfg) { | 3809 | if (base.mode & ATTR_ITALIC && base.mode & ATTR_BOLD) { |
| 3785 | if (base.mode & ATTR_ITALIC) | 3810 | if (dc.ibfont.badslant || dc.ibfont.badweight) |
| 3786 | base.fg = defaultitalic; | 3811 | base.fg = defaultattr; |
| 3787 | else if ((base.mode & ATTR_ITALIC) && (base.mode & ATTR_BOLD)) | 3812 | } else if ((base.mode & ATTR_ITALIC && dc.ifont.badslant) || |
| 3788 | base.fg = defaultitalic; | 3813 | (base.mode & ATTR_BOLD && dc.bfont.badweight)) { |
| 3789 | else if (base.mode & ATTR_UNDERLINE) | 3814 | base.fg = defaultattr; |
| 3790 | base.fg = defaultunderline; | ||
| 3791 | } | 3815 | } |
| 3792 | 3816 | ||
| 3793 | if (IS_TRUECOL(base.fg)) { | 3817 | if (IS_TRUECOL(base.fg)) { |
