sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

st-vertcenter-20171207-0ac685f.diff (1969B)


      1 diff --git a/st.h b/st.h
      2 index 44d4938..a45202f 100644
      3 --- a/st.h
      4 +++ b/st.h
      5 @@ -134,6 +134,7 @@ typedef struct {
      6  	int w, h; /* window width and height */
      7  	int ch; /* char height */
      8  	int cw; /* char width  */
      9 +	int cyo; /* char y offset */
     10  	char state; /* focus, redraw, visible */
     11  	int cursor; /* cursor style */
     12  } TermWindow;
     13 diff --git a/x.c b/x.c
     14 index 191e5dc..063925a 100644
     15 --- a/x.c
     16 +++ b/x.c
     17 @@ -826,6 +826,7 @@ xloadfonts(char *fontstr, double fontsize)
     18  	/* Setting character width and height. */
     19  	win.cw = ceilf(dc.font.width * cwscale);
     20  	win.ch = ceilf(dc.font.height * chscale);
     21 +	win.cyo = ceilf(dc.font.height * (chscale - 1) / 2);
     22  
     23  	FcPatternDel(pattern, FC_SLANT);
     24  	FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
     25 @@ -999,7 +1000,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
     26  	FcCharSet *fccharset;
     27  	int i, f, numspecs = 0;
     28  
     29 -	for (i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) {
     30 +	for (i = 0, xp = winx, yp = winy + font->ascent + win.cyo; i < len; ++i) {
     31  		/* Fetch rune and mode for current glyph. */
     32  		rune = glyphs[i].u;
     33  		mode = glyphs[i].mode;
     34 @@ -1024,7 +1025,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
     35  				font = &dc.bfont;
     36  				frcflags = FRC_BOLD;
     37  			}
     38 -			yp = winy + font->ascent;
     39 +			yp = winy + font->ascent + win.cyo;
     40  		}
     41  
     42  		/* Lookup character index with default font. */
     43 @@ -1238,12 +1239,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
     44  
     45  	/* Render underline and strikethrough. */
     46  	if (base.mode & ATTR_UNDERLINE) {
     47 -		XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1,
     48 +		XftDrawRect(xw.draw, fg, winx, winy + win.cyo + dc.font.ascent + 1,
     49  				width, 1);
     50  	}
     51  
     52  	if (base.mode & ATTR_STRUCK) {
     53 -		XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3,
     54 +		XftDrawRect(xw.draw, fg, winx, winy + win.cyo + 2 * dc.font.ascent / 3,
     55  				width, 1);
     56  	}
     57