From 08f137a8a094728b1b5613b987704d164d96bfcd Mon Sep 17 00:00:00 2001 From: bakkeby Date: Wed, 21 Apr 2021 15:48:31 +0200 Subject: [PATCH] Adding workaround for Variable Fonts causing too wide letter spacing --- README.md | 8 ++++++++ patches.def.h | 10 ++++++++++ x.c | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 84e1dd4..9ad1ad1 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the ### Changelog: +2021-04-21 - Added (temporary?) hack for Variable Fonts (VT) support + 2021-03-10 - Added sixel support 2021-02-26 - Added the dynamic cursor color patch @@ -172,6 +174,12 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the - [wide-glyphs](https://www.reddit.com/r/suckless/comments/jt90ai/update_support_for_proper_glyph_rendering_in_st/) - adds proper support for wide glyphs, as opposed to rendering smaller or cut glyphs + - [wide-glyph-spacing](https://github.com/googlefonts/Inconsolata/issues/42#issuecomment-737508890) + - there is a known issue that Google's Variable Fonts (VF) can end up with letter spacing + that is too wide in programs that use Xft, for example Inconsolata v3.000 + - this is intended as a temporary workaround / patch / hack until (if) this is fixed in the + Xft library itself + - [workingdir](https://st.suckless.org/patches/workingdir/) - allows user to specify the initial path st should use as the working directory diff --git a/patches.def.h b/patches.def.h index 2789516..3d7acd7 100644 --- a/patches.def.h +++ b/patches.def.h @@ -272,6 +272,16 @@ */ #define WIDE_GLYPHS_PATCH 0 +/* There is a known issue that Google's Variable Fonts (VF) can end up with letter spacing + * that is too wide in programs that use Xft, for example Inconsolata v3.000. + * + * This is intended as a temporary patch / hack until (if) this is fixed in the Xft library + * itself. + * + * https://github.com/googlefonts/Inconsolata/issues/42#issuecomment-737508890 + */ +#define WIDE_GLYPH_SPACING_PATCH 0 + /* This patch allows user to specify the initial path st should use as the working directory. * https://st.suckless.org/patches/workingdir/ */ diff --git a/x.c b/x.c index d0802cb..43e28b4 100644 --- a/x.c +++ b/x.c @@ -1025,7 +1025,11 @@ xloadfont(Font *f, FcPattern *pattern) f->rbearing = f->match->max_advance_width; f->height = f->ascent + f->descent; + #if WIDE_GLYPH_SPACING_PATCH + f->width = DIVCEIL(extents.xOff > 18 ? extents.xOff / 3 : extents.xOff, strlen(ascii_printable)); + #else f->width = DIVCEIL(extents.xOff, strlen(ascii_printable)); + #endif //WIDE_GLYPH_SPACING_PATCH return 0; }