Skip to content

Instantly share code, notes, and snippets.

@Lense
Last active October 12, 2019 19:25
Show Gist options
  • Save Lense/ee3e68fd16b60e396e5a1eba02971b30 to your computer and use it in GitHub Desktop.
Save Lense/ee3e68fd16b60e396e5a1eba02971b30 to your computer and use it in GitHub Desktop.
Updated for st 0.8.2 commit 2b8333f553c14c15398e810353e192eb05938580
diff --git a/x.c b/x.c
index 5828a3b..ace044f 100644
--- a/x.c
+++ b/x.c
@@ -116,8 +116,6 @@ typedef struct {
int width;
int ascent;
int descent;
- int badslant;
- int badweight;
short lbearing;
short rbearing;
XftFont *match;
@@ -841,7 +839,6 @@ xloadfont(Font *f, FcPattern *pattern)
FcPattern *match;
FcResult result;
XGlyphInfo extents;
- int wantattr, haveattr;
/*
* Manually configure instead of calling XftMatchFont
@@ -867,28 +864,6 @@ xloadfont(Font *f, FcPattern *pattern)
return 1;
}
- if ((XftPatternGetInteger(pattern, "slant", 0, &wantattr) ==
- XftResultMatch)) {
- /*
- * Check if xft was unable to find a font with the appropriate
- * slant but gave us one anyway. Try to mitigate.
- */
- if ((XftPatternGetInteger(f->match->pattern, "slant", 0,
- &haveattr) != XftResultMatch) || haveattr < wantattr) {
- f->badslant = 1;
- fputs("font slant does not match\n", stderr);
- }
- }
-
- if ((XftPatternGetInteger(pattern, "weight", 0, &wantattr) ==
- XftResultMatch)) {
- if ((XftPatternGetInteger(f->match->pattern, "weight", 0,
- &haveattr) != XftResultMatch) || haveattr != wantattr) {
- f->badweight = 1;
- fputs("font weight does not match\n", stderr);
- }
- }
-
XftTextExtentsUtf8(xw.dpy, f->match,
(const FcChar8 *) ascii_printable,
strlen(ascii_printable), &extents);
@@ -961,16 +936,22 @@ xloadfonts(char *fontstr, double fontsize)
FcPatternDel(pattern, FC_SLANT);
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
+ FcPatternDel(pattern, FC_STYLE);
+ FcPatternAddString(pattern, FC_STYLE, (FcChar8*)"Italic");
if (xloadfont(&dc.ifont, pattern))
die("can't open font %s\n", fontstr);
FcPatternDel(pattern, FC_WEIGHT);
FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
+ FcPatternDel(pattern, FC_STYLE);
+ FcPatternAddString(pattern, FC_STYLE, (FcChar8*)"Bold Italic");
if (xloadfont(&dc.ibfont, pattern))
die("can't open font %s\n", fontstr);
FcPatternDel(pattern, FC_SLANT);
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN);
+ FcPatternDel(pattern, FC_STYLE);
+ FcPatternAddString(pattern, FC_STYLE, (FcChar8*)"Bold");
if (xloadfont(&dc.bfont, pattern))
die("can't open font %s\n", fontstr);
@@ -1287,15 +1268,6 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
XRenderColor colfg, colbg;
XRectangle r;
- /* 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)
- base.fg = defaultattr;
- } else if ((base.mode & ATTR_ITALIC && dc.ifont.badslant) ||
- (base.mode & ATTR_BOLD && dc.bfont.badweight)) {
- base.fg = defaultattr;
- }
-
if (IS_TRUECOL(base.fg)) {
colfg.alpha = 0xffff;
colfg.red = TRUERED(base.fg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment