Skip to content

Instantly share code, notes, and snippets.

@Lense Lense/fix_bold.diff
Last active Feb 6, 2017

Embed
What would you like to do?
diff --git a/st.c b/st.c
index fbcd9e0..4c49420 100644
--- a/st.c
+++ b/st.c
@@ -354,8 +354,6 @@ typedef struct {
int width;
int ascent;
int descent;
- int badslant;
- int badweight;
short lbearing;
short rbearing;
XftFont *match;
@@ -3377,7 +3375,6 @@ xloadfont(Font *f, FcPattern *pattern)
FcPattern *match;
FcResult result;
XGlyphInfo extents;
- int wantattr, haveattr;
/*
* Manually configure instead of calling XftMatchFont
@@ -3403,28 +3400,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("st: 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("st: font weight does not match\n", stderr);
- }
- }
-
XftTextExtentsUtf8(xw.dpy, f->match,
(const FcChar8 *) ascii_printable,
strlen(ascii_printable), &extents);
@@ -3499,16 +3474,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("st: 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("st: 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("st: can't open font %s\n", fontstr);
@@ -3822,15 +3803,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
You can’t perform that action at this time.