sites

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

commit 15db3b7fe53fdac789545632a851855862824214
parent 48263a781ea60559d2fc559e831e69c13f78139a
Author: Zacchary Dempsey-Plante <zacc@ztdp.ca>
Date:   Fri, 11 Mar 2022 04:37:42 -0500

[PATCH][st] charoffsets

Add support for configurable character rendering offsets.

Diffstat:
Ast.suckless.org/patches/charoffsets/index.md | 35+++++++++++++++++++++++++++++++++++
Ast.suckless.org/patches/charoffsets/st-charoffsets-20220311-0.8.5.diff | 43+++++++++++++++++++++++++++++++++++++++++++
Ast.suckless.org/patches/charoffsets/vertical-gaps.png | 0
3 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/st.suckless.org/patches/charoffsets/index.md b/st.suckless.org/patches/charoffsets/index.md @@ -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@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 @@ -0,0 +1,43 @@ +From 944b234710e2fc00ea6e9ce9d925dc85514ac9c3 Mon Sep 17 00:00:00 2001 +From: Zacchary Dempsey-Plante <zacc@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 +@@ -28,6 +28,9 @@ char *vtiden = "\033[?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 +@@ -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 Binary files differ.