sites

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

st-vertcenter-0.7.diff (1439B)


      1 --- a/st.c
      2 +++ b/st.c
      3 @@ -268,6 +268,7 @@ typedef struct {
      4  	int w, h; /* window width and height */
      5  	int ch; /* char height */
      6  	int cw; /* char width  */
      7 +	int cyo; /* char y offset */
      8  	char state; /* focus, redraw, visible */
      9  	int cursor; /* cursor style */
     10  } XWindow;
     11 @@ -3359,6 +3360,7 @@ xloadfonts(char *fontstr, double fontsize)
     12  	/* Setting character width and height. */
     13  	xw.cw = ceilf(dc.font.width * cwscale);
     14  	xw.ch = ceilf(dc.font.height * chscale);
     15 +	xw.cyo = ceilf(dc.font.height * (chscale - 1) / 2);
     16  
     17  	FcPatternDel(pattern, FC_SLANT);
     18  	FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
     19 @@ -3584,7 +3586,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
     20  				font = &dc.bfont;
     21  				frcflags = FRC_BOLD;
     22  			}
     23 -			yp = winy + font->ascent;
     24 +			yp = winy + font->ascent + xw.cyo;
     25  		}
     26  
     27  		/* Lookup character index with default font. */
     28 @@ -3796,12 +3798,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
     29  
     30  	/* Render underline and strikethrough. */
     31  	if (base.mode & ATTR_UNDERLINE) {
     32 -		XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1,
     33 +		XftDrawRect(xw.draw, fg, winx, winy + xw.cyo + dc.font.ascent + 1,
     34  				width, 1);
     35  	}
     36  
     37  	if (base.mode & ATTR_STRUCK) {
     38 -		XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3,
     39 +		XftDrawRect(xw.draw, fg, winx, winy + xw.cyo + 2 * dc.font.ascent / 3,
     40  				width, 1);
     41  	}
     42