From 2906447fefd258d4001855ee06c9c7bc40d011f0 Mon Sep 17 00:00:00 2001 From: Bakkeby Date: Sun, 28 Aug 2022 21:05:55 +0200 Subject: [PATCH] Adding use XftFontMatch patch --- README.md | 6 ++++++ patches.def.h | 14 ++++++++++++++ x.c | 12 ++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6af3a8d..fe63e5e 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: +2022-08-28 - Added the use XftFontMatch patch + 2022-08-24 - Added the no window decorations patch 2022-04-11 - Added the background image reload patch @@ -264,6 +266,10 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the - allows mouse scroll without modifier keys for regardless of alt screen using the external scroll program + - [use-XftFontMatch](https://git.suckless.org/st/commit/528241aa3835e2f1f052abeeaf891737712955a0.html) + - use XftFontMatch in place of FcFontMatch to allow font to scale with Xft.dpi resource + setting + - [vertcenter](https://st.suckless.org/patches/vertcenter/) - vertically center lines in the space available if you have set a larger chscale in config.h diff --git a/patches.def.h b/patches.def.h index 3f14745..26ae7e6 100644 --- a/patches.def.h +++ b/patches.def.h @@ -373,6 +373,20 @@ */ #define UNIVERSCROLL_PATCH 0 +/* Use XftFontMatch in place of FcFontMatch. + * + * XftFontMatch calls XftDefaultSubstitute which configures various match properties according + * to the user's configured Xft defaults (xrdb) as well as according to the current display and + * screen. Most importantly, the screen DPI is computed [1]. Without this, st uses a "default" + * DPI of 75 [2]. + * + * [1]: https://cgit.freedesktop.org/xorg/lib/libXft/tree/src/xftdpy.c?id=libXft-2.3.2#n535 + * [2]: https://cgit.freedesktop.org/fontconfig/tree/src/fcdefault.c?id=2.11.1#n255 + * + * https://git.suckless.org/st/commit/528241aa3835e2f1f052abeeaf891737712955a0.html + */ +#define USE_XFTFONTMATCH_PATCH 0 + /* Vertically center lines in the space available if you have set a larger chscale in config.h * https://st.suckless.org/patches/vertcenter/ */ diff --git a/x.c b/x.c index 2de3a1f..a05d9cb 100644 --- a/x.c +++ b/x.c @@ -1216,7 +1216,11 @@ xloadfont(Font *f, FcPattern *pattern) FcConfigSubstitute(NULL, configured, FcMatchPattern); XftDefaultSubstitute(xw.dpy, xw.scr, configured); + #if USE_XFTFONTMATCH_PATCH + match = XftFontMatch(xw.dpy, xw.scr, pattern, &result); + #else match = FcFontMatch(NULL, configured, &result); + #endif // USE_XFTFONTMATCH_PATCH if (!match) { FcPatternDestroy(configured); return 1; @@ -1735,12 +1739,12 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x fccharset); FcPatternAddBool(fcpattern, FC_SCALABLE, 1); - FcConfigSubstitute(0, fcpattern, - FcMatchPattern); + #if !USE_XFTFONTMATCH_PATCH + FcConfigSubstitute(0, fcpattern, FcMatchPattern); FcDefaultSubstitute(fcpattern); + #endif // USE_XFTFONTMATCH_PATCH - fontpattern = FcFontSetMatch(0, fcsets, 1, - fcpattern, &fcres); + fontpattern = FcFontSetMatch(0, fcsets, 1, fcpattern, &fcres); /* Allocate memory for the new cache entry. */ if (frclen >= frccap) {