hi. i was trying to figure out which font st(1) was using in some
configuration i was running it in.
i created the following (INCOMPLETE!!) patch to print out messages when
what the user requested and what is ended up being used are different.
for example, with the patch
----
st fc4* ❯ ./st -f adflkjdsf
font mismatch: instead of family "adflkjdsf"; we got family "Noto Sans"
font mismatch: instead of family "adflkjdsf"; we got family "Noto Sans"
font mismatch: instead of family "adflkjdsf"; we got family "Noto Sans"
font mismatch: instead of family "adflkjdsf"; we got family "Noto Sans"
----
the incompleteness is, at least partially, from these issues:
- should it always check? #ifdef? command line option?
- what fields should it look at?
- currently it looks at "familiy", "style", and "size". there are
many others
- possibly, one can look at the user's pattern and use some FcP...()
routine to extract *all* the fields the user specified, and look at
those
- when during the start up should it be called? (maybe there's
somewhere where it won't report the same information four times, for
example.)
- *how* should it present any discrepancies it finds to the user?
- right now, it does `fprintf(stderr...)`. that isn't likely of much
help, especially if launched from a window manager (where stderr
probably doesn't get shown to the user, sadly)
- and, obviously, is this even useful.
cheers, Greg
>From 180a8cc19ea81a2dfa346391966e7789aaf2552a Mon Sep 17 00:00:00 2001
From: Greg Minshall <[email protected]>
Date: Mon, 23 Sep 2024 11:34:42 +0300
Subject: [PATCH] Squashed commit of the following:
commit f01dcfd062507433e99cfbd74f4a625a97c74350
Author: Greg Minshall <[email protected]>
Date: Mon Sep 23 11:21:43 2024 +0300
Revert "Merge branch 'st-keyboard_select-20200617-9ba7ecf' into mine"
This reverts commit 022aa3577dc1358704ff7a5df0d4c4e5c4852777, reversing
changes made to c0c621a757232df438b536d1c9695b828a0efe8b.
commit 12c10a45697808ed9f446339247220e6dc5ad052
Author: Greg Minshall <[email protected]>
Date: Mon Sep 23 11:11:05 2024 +0300
config.h: delete file polluting this branch
i really messed up, back in c0c621a757232df438b536d1c9695b828a0efe8b
or 5d5227df18084aff0b35e9a839a0fd9b71313567.
probably i created the `fontcheck` branch from `mine`, rather than
`master` (not sure if git can tell me that).
commit b718fe43aa5fdaf190f800ed73c5bec5ddac369b
Author: Greg Minshall <[email protected]>
Date: Mon Sep 23 10:21:33 2024 +0300
this should not have been in this branch
Revert "onfig.h: add in keycode C-S-Esc for keyboard select"
This reverts commit d2dd3aea58a4e042c4e869eececd2c028d23b431.
commit 75c162ed4528041142b7aac763e1dd9fd26432c0
Author: Greg Minshall <[email protected]>
Date: Mon Sep 23 10:00:19 2024 +0300
x.c: implement xrfmatch(), xrfprint()
commit c8813931f2299d8b97b4a2d3d4b80a44192d3f92
Author: Greg Minshall <[email protected]>
Date: Sun Sep 22 20:14:30 2024 +0300
x.c: looking at chekckng how close resulting font is
commit c8dfb8cffa1f8cf95e3d08de7ea19c25efbae84b
Author: Greg Minshall <[email protected]>
Date: Sun Sep 22 16:16:19 2024 +0300
remove files accidentally added to git
st
st-nordtheme-0.8.5.diff
st.o
x.o
commit d2dd3aea58a4e042c4e869eececd2c028d23b431
Author: Greg Minshall <[email protected]>
Date: Sun Sep 22 16:11:50 2024 +0300
onfig.h: add in keycode C-S-Esc for keyboard select
commit 022aa3577dc1358704ff7a5df0d4c4e5c4852777
Merge: c0c621a 8c7ee5d
Author: Greg Minshall <[email protected]>
Date: Sun Sep 22 13:44:10 2024 +0300
Merge branch 'st-keyboard_select-20200617-9ba7ecf' into mine
commit 8c7ee5dbeda99708a86796dacf4cebd0d0ba8e8d
Author: Greg Minshall <[email protected]>
Date: Sun Sep 22 13:32:02 2024 +0300
trying to update st-keyboard_select-20200617-9ba7ecf.diff
commit c0c621a757232df438b536d1c9695b828a0efe8b
Author: Greg Minshall <[email protected]>
Date: Sun Sep 22 11:47:44 2024 +0300
onfig.h: reverse "nordic-theme" patch
commit 6b48bec205a09afca8dc477ab87ea2f83ff9002f
Author: Greg Minshall <[email protected]>
Date: Sun Sep 22 11:33:14 2024 +0300
Revert "Use nord-theme"
This reverts commit 9616e00cc46fe949d0e49e35befc8f521cefaf43.
commit 5d5227df18084aff0b35e9a839a0fd9b71313567
Author: Greg Minshall <[email protected]>
Date: Sun Sep 22 11:05:51 2024 +0300
config.h: copy from most recent config.def.h
commit 84ee2a419efbb41e3aff70373cec254362141337
Merge: 9616e00 a0274bc
Author: Greg Minshall <[email protected]>
Date: Sat Sep 21 18:59:08 2024 +0300
track upstream
commit 9616e00cc46fe949d0e49e35befc8f521cefaf43
Author: aleks <[email protected]>
Date: Tue May 31 13:09:47 2022 +0200
Use nord-theme
*"Inspired by the beauty of the arctic, the colors reflect the cold, yet
harmonious world of ice and the colorfulness of the Aurora Borealis."* -
[Nord Theme](https://www.nordtheme.com/)
The default behaviour of st is to reverse the fore- and background
colors of each selected cell. If you don't want the selection-colors to
be reveresed but instead have fixed fore- and background colors apply on
top of this patch the [selectioncolors](../selectioncolors/)-patch. Then
set the following settings in your config.h:
unsigned int selectionbg = 0;
unsigned int selectionfg = 256;
commit 62dc5b10ee0468dbf94b873b14dbe1ca5a5f0371
Author: Greg Minshall <[email protected]>
Date: Wed Sep 28 10:46:22 2022 +0300
config.h: use DejaVu font, size 13
commit aaab5605a255aca811aefdd8cf3106bb31961514
Author: Greg Minshall <[email protected]>
Date: Wed Sep 28 10:44:01 2022 +0300
config.h: as from git repo config.def.h
---
x.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 107 insertions(+), 1 deletion(-)
diff --git a/x.c b/x.c
index d73152b..23b5519 100644
--- a/x.c
+++ b/x.c
@@ -1,5 +1,6 @@
/* See LICENSE for license details. */
#include <errno.h>
+#include <fontconfig/fontconfig.h>
#include <math.h>
#include <limits.h>
#include <locale.h>
@@ -907,6 +908,111 @@ xgeommasktogravity(int mask)
return SouthEastGravity;
}
+
+/*
+ * check that the contents of two fields are the same
+ * -- return 1 if so, 0 otherwise
+ *
+ * there is asymmetry here: pattern A is considered more important.
+ * if FIELD exists (as a string or integer) in A, then FIELD
+ * is checked in B. in this case, the inequality of A and B
+ * or the non-existence of FIELD in B, are considered "not
+ * matches", and a zero is returned.
+ *
+ * the idea is that A should be something closer to what the
+ * user requested, and B something closer to what the system
+ * decided to provide. only the things the user requested should be
+ compared.
+ *
+ * and, we just try string first, not requiring the caller
+ * to specify the type of the field.
+ */
+int
+xrfmatch(char *field, FcPattern *a, FcPattern *b) {
+ FcChar8 *astr, *bstr;
+ int aint, bint;
+
+ if (FcPatternGetString(a, field, 0, &astr) == FcResultMatch) {
+ if (FcPatternGetString(b, field, 0, &bstr) != FcResultMatch) {
+ /* so, a is found and is a string, but not b */
+ return 0;
+ }
+ return !FcStrCmpIgnoreCase(astr, bstr);
+ } else if (FcPatternGetInteger(a, field, 0, &aint) == FcResultMatch) {
+ if (FcPatternGetInteger(b, field, 0, &bint) != FcResultMatch) {
+ /* so, a is found and is an int, but not b */
+ return 0; /* type 1, type 2 errors */
+ }
+ return aint == bint;
+ } else {
+ /* oh, well */
+ return 1;
+ }
+}
+
+
+/* print out a (string or integer) field from a pattern */
+void
+xrfprint(char *field, FcPattern *pattern) {
+ FcChar8 *str;
+ int num;
+ if (FcPatternGetString(pattern, field, 0, &str) == FcResultMatch) {
+ fprintf(stderr, " %s \"%s\"", field, str);
+ } else if (FcPatternGetInteger(pattern, field, 0, &num) == FcResultMatch) {
+ fprintf(stderr, " %s %d", field, num);
+ } else {
+ /* ??? */
+ fprintf(stderr, " coding error: %s (%s) is neither string nor integer\n",
+ field, field);
+ }
+}
+
+
+
+/*
+ * check the user's requested font with the font the system provided.
+ *
+ * XXX i don't know how to get any output here in front of the user's
+ * face, so i'm just using `fprintf(stderr, ...)` which the user will
+ * see, if at all, will see late, after closing st.
+ *
+ * NB: we only care about the qualities the user specified.
+ *
+ * XXX i just chose FAMILY, STYLE, SIZE as they were the ones that
+ occured to me.
+ */
+
+void
+xrightfont(FcPattern *pattern, FcPattern *match, FcPattern *got) {
+ if (xrfmatch(FC_FAMILY, pattern, got) &&
+ xrfmatch(FC_STYLE, pattern, got) &&
+ xrfmatch(FC_SIZE, pattern, got)) {
+ return; /* everything is good */
+ } else { /* right here in River City */
+ fprintf(stderr, "font mismatch: instead of");
+ if (!xrfmatch(FC_FAMILY, pattern, got)) {
+ xrfprint(FC_FAMILY, pattern);
+ }
+ if (!xrfmatch(FC_STYLE, pattern, got)) {
+ xrfprint(FC_STYLE, pattern);
+ }
+ if (!xrfmatch(FC_SIZE, pattern, got)) {
+ xrfprint(FC_SIZE, pattern);
+ }
+ fprintf(stderr, "; we got");
+ if (!xrfmatch(FC_FAMILY, pattern, got)) {
+ xrfprint(FC_FAMILY, got);
+ }
+ if (!xrfmatch(FC_STYLE, pattern, got)) {
+ xrfprint(FC_STYLE, got);
+ }
+ if (!xrfmatch(FC_SIZE, pattern, got)) {
+ xrfprint(FC_SIZE, got);
+ }
+ fprintf(stderr, "\n");
+ }
+}
+
int
xloadfont(Font *f, FcPattern *pattern)
{
@@ -939,7 +1045,7 @@ xloadfont(Font *f, FcPattern *pattern)
FcPatternDestroy(match);
return 1;
}
-
+ xrightfont(pattern, match, f->match->pattern);
if ((XftPatternGetInteger(pattern, "slant", 0, &wantattr) ==
XftResultMatch)) {
/*
--
2.46.1