aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorSpencer Phippen <spencer.phippen@gmail.com>2016-11-23 19:17:59 +0100
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2016-11-24 20:20:45 +0100
commitfa9a4599720703932d1c4f16b9aeee1f91f96263 (patch)
tree12e9d6a0680f8603ca630dbfdaaac9807d26677d /st.c
parent740ada1447a0bf9eb7db327d9433fa0b96e0a4d8 (diff)
downloadst-fa9a4599720703932d1c4f16b9aeee1f91f96263.tar.gz
st-fa9a4599720703932d1c4f16b9aeee1f91f96263.zip
Fixed 'missing glyph doesn't use fontconfig config substitutions' bug
XftFontMatch does display-specific font configuration (commit 528241a). Nice. Unfortunately, when we switched from FcFontMatch, we also stopped storing the post-Fc{Config,Default}Substitute FcPattern for future lookups. The result is that if a glyph isn't found in the primary font, secondary font lookups use the original FcPattern, not the configured one. If you have custom fontconfig rules (like me), this can be disappointing. I basically just copied the guts out of XftFontMatch[1] and saved the intermediate configured FcPattern. Could be related to the bug that inspired commit 4242027. [1]: https://cgit.freedesktop.org/xorg/lib/libXft/tree/src/xftfont.c
Diffstat (limited to 'st.c')
-rw-r--r--st.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/st.c b/st.c
index e50e884..031272f 100644
--- a/st.c
+++ b/st.c
@@ -3373,16 +3373,32 @@ xgeommasktogravity(int mask)
3373int 3373int
3374xloadfont(Font *f, FcPattern *pattern) 3374xloadfont(Font *f, FcPattern *pattern)
3375{ 3375{
3376 FcPattern *configured;
3376 FcPattern *match; 3377 FcPattern *match;
3377 FcResult result; 3378 FcResult result;
3378 XGlyphInfo extents; 3379 XGlyphInfo extents;
3379 int wantattr, haveattr; 3380 int wantattr, haveattr;
3380 3381
3381 match = XftFontMatch(xw.dpy, xw.scr, pattern, &result); 3382 /*
3382 if (!match) 3383 * Manually configure instead of calling XftMatchFont
3384 * so that we can use the configured pattern for
3385 * "missing glyph" lookups.
3386 */
3387 configured = FcPatternDuplicate(pattern);
3388 if (!configured)
3389 return 1;
3390
3391 FcConfigSubstitute(NULL, configured, FcMatchPattern);
3392 XftDefaultSubstitute(xw.dpy, xw.scr, configured);
3393
3394 match = FcFontMatch(NULL, configured, &result);
3395 if (!match) {
3396 FcPatternDestroy(configured);
3383 return 1; 3397 return 1;
3398 }
3384 3399
3385 if (!(f->match = XftFontOpenPattern(xw.dpy, match))) { 3400 if (!(f->match = XftFontOpenPattern(xw.dpy, match))) {
3401 FcPatternDestroy(configured);
3386 FcPatternDestroy(match); 3402 FcPatternDestroy(match);
3387 return 1; 3403 return 1;
3388 } 3404 }
@@ -3414,7 +3430,7 @@ xloadfont(Font *f, FcPattern *pattern)
3414 strlen(ascii_printable), &extents); 3430 strlen(ascii_printable), &extents);
3415 3431
3416 f->set = NULL; 3432 f->set = NULL;
3417 f->pattern = FcPatternDuplicate(pattern); 3433 f->pattern = configured;
3418 3434
3419 f->ascent = f->match->ascent; 3435 f->ascent = f->match->ascent;
3420 f->descent = f->match->descent; 3436 f->descent = f->match->descent;