After upgrading my workstation to Debian 10, changes in Fontconfig and/or DejaVu Sans Mono have changed the values of dc.font.height in my st build. The characters themselves seem to be near pixel-perfect matches. I "fixed" the problem by adjusting the chscale configuration variable to shave a pixel off the bounding box, but since this depends on the character height, I would need to use a separate configuration for my laptop which still runs Debian 9. This patch allows the specification of bounding boxes using either absolute dimensions or the original scaling factors to mitigate that issue. --- config.def.h | 11 ++++++++++- x.c | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h index 482901e..47c4004 100644 --- a/config.def.h +++ b/config.def.h @@ -23,10 +23,19 @@ char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400"; /* identification sequence returned in DA and DECID */ char *vtiden = "\033[?6c"; -/* Kerning / character bounding-box multipliers */ +/* Kerning / character bounding-box configuration. There are two ways to + * configure this: using scaling factors (cwscale and chscale) in which the + * bounding box is computed by multiplying the dimensions returned by + * Fontconfig by the scaling factors or absolute dimensions in pixels (cwidth + * and cheight). The cwscale factor is only used if cwidth is 0, and the + * chscale factor is only used if cheight is 0. + */ static float cwscale = 1.0; static float chscale = 1.0; +static unsigned int cwidth = 0; +static unsigned int cheight = 0; + /* * word delimiter string * diff --git a/x.c b/x.c index 5828a3b..b55b5ad 100644 --- a/x.c +++ b/x.c @@ -956,8 +956,8 @@ xloadfonts(char *fontstr, double fontsize) } /* Setting character width and height. */ - win.cw = ceilf(dc.font.width * cwscale); - win.ch = ceilf(dc.font.height * chscale); + win.cw = ceilf(cwidth ? cwidth : dc.font.width * cwscale); + win.ch = ceilf(cheight ? cheight : dc.font.height * chscale); FcPatternDel(pattern, FC_SLANT); FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); -- 2.20.1