aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
Diffstat (limited to 'st.c')
-rw-r--r--st.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/st.c b/st.c
index c67623f..4d44388 100644
--- a/st.c
+++ b/st.c
@@ -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)) {