st-vertcenter-20231003-eb3b894.diff (2209B)
1 From c85891b21261b68b09ed9ae6a1ca18655ef19e69 Mon Sep 17 00:00:00 2001 2 From: roket1428 <meorhan@protonmail.com> 3 Date: Tue, 3 Oct 2023 11:10:39 +0300 4 Subject: [PATCH] vertcenter patch 5 6 --- 7 x.c | 10 ++++++---- 8 1 file changed, 6 insertions(+), 4 deletions(-) 9 10 diff --git a/x.c b/x.c 11 index aa09997..9ecb46e 100644 12 --- a/x.c 13 +++ b/x.c 14 @@ -83,6 +83,7 @@ typedef struct { 15 int w, h; /* window width and height */ 16 int ch; /* char height */ 17 int cw; /* char width */ 18 + int cyo; /* char y offset */ 19 int mode; /* window state/mode flags */ 20 int cursor; /* cursor style */ 21 } TermWindow; 22 @@ -1031,6 +1032,7 @@ xloadfonts(const char *fontstr, double fontsize) 23 /* Setting character width and height. */ 24 win.cw = ceilf(dc.font.width * cwscale); 25 win.ch = ceilf(dc.font.height * chscale); 26 + win.cyo = ceilf(dc.font.height * (chscale - 1) / 2); 27 28 FcPatternDel(pattern, FC_SLANT); 29 FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); 30 @@ -1255,7 +1257,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x 31 FcCharSet *fccharset; 32 int i, f, numspecs = 0; 33 34 - for (i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) { 35 + for (i = 0, xp = winx, yp = winy + font->ascent + win.cyo; i < len; ++i) { 36 /* Fetch rune and mode for current glyph. */ 37 rune = glyphs[i].u; 38 mode = glyphs[i].mode; 39 @@ -1280,7 +1282,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x 40 font = &dc.bfont; 41 frcflags = FRC_BOLD; 42 } 43 - yp = winy + font->ascent; 44 + yp = winy + font->ascent + win.cyo; 45 } 46 47 /* Lookup character index with default font. */ 48 @@ -1493,12 +1495,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i 49 50 /* Render underline and strikethrough. */ 51 if (base.mode & ATTR_UNDERLINE) { 52 - XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent * chscale + 1, 53 + XftDrawRect(xw.draw, fg, winx, winy + win.cyo + dc.font.ascent * chscale + 1, 54 width, 1); 55 } 56 57 if (base.mode & ATTR_STRUCK) { 58 - XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent * chscale / 3, 59 + XftDrawRect(xw.draw, fg, winx, winy + win.cyo + 2 * dc.font.ascent * chscale / 3, 60 width, 1); 61 } 62 63 -- 64 2.42.0 65