summaryrefslogtreecommitdiff
path: root/x.c
diff options
context:
space:
mode:
authorroket1428 <meorhan@protonmail.com>2023-10-03 11:10:39 +0300
committerMarcelo Lira <setanta@gmail.com>2025-03-03 16:12:29 -0300
commit5d8c9d1f5183e56a8563fc93eba8d7d4a8f842dd (patch)
tree7a01086829a6102a26a239d26dbdc295ba5ffcdb /x.c
parent2cf04478a20133a13c364aeb1557e29004fd95c1 (diff)
vertcenter patch
Diffstat (limited to 'x.c')
-rw-r--r--x.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/x.c b/x.c
index 69bd37b..1fda75b 100644
--- a/x.c
+++ b/x.c
@@ -96,6 +96,7 @@ typedef struct {
int w, h; /* window width and height */
int ch; /* char height */
int cw; /* char width */
+ int cyo; /* char y offset */
int mode; /* window state/mode flags */
int cursor; /* cursor style */
} TermWindow;
@@ -1061,6 +1062,7 @@ xloadfonts(const char *fontstr, double fontsize)
/* Setting character width and height. */
win.cw = ceilf(dc.font.width * cwscale);
win.ch = ceilf(dc.font.height * chscale);
+ win.cyo = ceilf(dc.font.height * (chscale - 1) / 2);
FcPatternDel(pattern, FC_SLANT);
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
@@ -1397,7 +1399,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
FcCharSet *fccharset;
int i, f, numspecs = 0;
- for (i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) {
+ for (i = 0, xp = winx, yp = winy + font->ascent + win.cyo; i < len; ++i) {
/* Fetch rune and mode for current glyph. */
rune = glyphs[i].u;
mode = glyphs[i].mode;
@@ -1422,7 +1424,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
font = &dc.bfont;
frcflags = FRC_BOLD;
}
- yp = winy + font->ascent;
+ yp = winy + font->ascent + win.cyo;
}
/* Lookup character index with default font. */
@@ -1714,7 +1716,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
if (base.ustyle != 3) {
//XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1, width, 1);
XFillRectangle(xw.dpy, XftDrawDrawable(xw.draw), ugc, winx,
- winy + dc.font.ascent + 1, width, wlw);
+ winy + win.cyo + dc.font.ascent + 1, width, wlw);
} else if (base.ustyle == 3) {
int ww = win.cw;//width;
int wh = dc.font.descent - wlw/2 - 1;//r.height/7;
@@ -2026,7 +2028,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
}
if (base.mode & ATTR_STRUCK) {
- XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent * chscale / 3,
+ XftDrawRect(xw.draw, fg, winx, winy + win.cyo + 2 * dc.font.ascent * chscale / 3,
width, 1);
}