[wiki] [sites] [PATCH][st] charoffsets || Zacchary Dempsey-Plante

From: <git_AT_suckless.org>
Date: Fri, 11 Mar 2022 10:40:47 +0100

commit 15db3b7fe53fdac789545632a851855862824214
Author: Zacchary Dempsey-Plante <zacc_AT_ztdp.ca>
Date: Fri Mar 11 04:37:42 2022 -0500

    [PATCH][st] charoffsets
    
    Add support for configurable character rendering offsets.

diff --git a/st.suckless.org/patches/charoffsets/index.md b/st.suckless.org/patches/charoffsets/index.md
new file mode 100644
index 00000000..34aa08f2
--- /dev/null
+++ b/st.suckless.org/patches/charoffsets/index.md
_AT_@ -0,0 +1,35 @@
+charoffsets
+=========
+
+Description
+-----------
+Some fonts seem to misreport their height, which leads to unsightly vertical
+gaps appearing between rows of text with characters that are supposed to fill
+the vertical space, like box-drawing characters.
+
+This is because the character height that st uses is off from the actual glyph
+height, so there's a gap of bg space above and below each glyph. This can be
+adjusted by modifying the `chscale` value, but reducing that value alone just
+clips the bottom of the glyphs.
+
+This patch simply adds a `cyoffset` value (and a corresponding `cxoffset`) to
+allow you to adjust the glyph position, so it doesn't get clipped short when
+you reduce the `chscale`. You'll have to play with the values to get it to
+look right with your font choice.
+
+Example
+-------
+Note the vertical gaps between the lines in the box art, and the raised part
+that sticks out on the time display.
+
+Taken with Pragmata Pro with a few font patches applied.
+
+[![An example of the vertical gaps.](vertical-gaps.png)](vertical-gaps.png)
+
+Download
+--------
+* [st-charoffsets-20220311-0.8.5.diff](st-charoffsets-20220311-0.8.5.diff)
+
+Authors
+-------
+* Zacchary Dempsey-Plante - <zacc_AT_ztdp.ca>
diff --git a/st.suckless.org/patches/charoffsets/st-charoffsets-20220311-0.8.5.diff b/st.suckless.org/patches/charoffsets/st-charoffsets-20220311-0.8.5.diff
new file mode 100644
index 00000000..4034d3f7
--- /dev/null
+++ b/st.suckless.org/patches/charoffsets/st-charoffsets-20220311-0.8.5.diff
_AT_@ -0,0 +1,43 @@
+From 944b234710e2fc00ea6e9ce9d925dc85514ac9c3 Mon Sep 17 00:00:00 2001
+From: Zacchary Dempsey-Plante <zacc_AT_ztdp.ca>
+Date: Fri, 11 Mar 2022 01:33:05 -0500
+Subject: [PATCH] Added character rendering offsets for correcting different
+ font dimensions.
+
+---
+ config.def.h | 3 +++
+ x.c | 4 ++--
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 91ab8ca..8877e5c 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -28,6 +28,9 @@ char *vtiden = "[?6c";
+ /* Kerning / character bounding-box multipliers */
+ static float cwscale = 1.0;
+ static float chscale = 1.0;
++/* Character rendering offsets in pixels */
++static short cxoffset = 0;
++static short cyoffset = 0;
+
+ /*
+ * word delimiter string
+diff --git a/x.c b/x.c
+index cd96575..6983743 100644
+--- a/x.c
++++ b/x.c
+_AT_@ -1288,8 +1288,8 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
+ if (glyphidx) {
+ specs[numspecs].font = font->match;
+ specs[numspecs].glyph = glyphidx;
+- specs[numspecs].x = (short)xp;
+- specs[numspecs].y = (short)yp;
++ specs[numspecs].x = (short)xp + cxoffset;
++ specs[numspecs].y = (short)yp + cyoffset;
+ xp += runewidth;
+ numspecs++;
+ continue;
+--
+2.35.1
+
diff --git a/st.suckless.org/patches/charoffsets/vertical-gaps.png b/st.suckless.org/patches/charoffsets/vertical-gaps.png
new file mode 100644
index 00000000..e3f251cf
Binary files /dev/null and b/st.suckless.org/patches/charoffsets/vertical-gaps.png differ
Received on Fri Mar 11 2022 - 10:40:47 CET

This archive was generated by hypermail 2.3.0 : Fri Mar 11 2022 - 10:48:51 CET