Re: font selection, particularly for the Identify and About windows

Rhialto <[email protected]> Mon, 21 Oct 2024 18:48:04 +0200
Newsgroups gmane.comp.window-managers.ctwm
Message-ID <[email protected]>

--bzH/L+JzMD9kTBr2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun 20 Oct 2024 at 16:01:43 -0700, Greg A. Woods wrote:
> However I have only briefly, and using magic I did not understand or
> correctly record, managed to get the font in the Identify and About
> windows to scale properly.

Concentrating on the Identify window, I looked though the source and
this is what I found. It is drawn in functions_identify.c
draw_info_window() where it calls

XmbDrawString(dpy, Scr->InfoWindow.win, Scr->DefaultFont.font_set,

So where is DefaultFont set? In util.c there is

CreateFonts(ScreenInfo *scr)
{
#define LOADFONT(fld) (GetFont(&scr->fld##Font))
=2E..
    LOADFONT(Default);

GetFont() uses

    char *deffontname =3D "fixed,*";

    asprintf(&basename2, "%s,*", font->basename);
    if((font->font_set =3D XCreateFontSet(dpy, basename2, ...

        fprintf(stderr, "Failed to get fontset %s\n", basename2);

        if(Scr->DefaultFont.basename) {
            deffontname =3D Scr->DefaultFont.basename;
        }

        if((font->font_set =3D XCreateFontSet(dpy, deffontname,

but Scr->DefaultFont.basename never seems to be set anywhere (unlike, for
example,  TitleBarFont.basename).

So it looks like those windows will always use the font named "fixed".
(or a FontSet based on that; I never looked much at FontSets much
really)

I don't know if that somehow can automatically scale with the DPI.  But
it sounds like it would be nice to make it configurable anyway. I see in
your dotfiles repo that you already realised that setting DefaultFont is
missing, so I must guess that the fix you mentioned must have helped
here. For others, if they want, they can try the following patch which I
am considering to commit. I gave it a quick test and it appears to work:


=3D=3D=3D modified file 'doc/manual/ctwm.1.adoc'
--- old/doc/manual/ctwm.1.adoc	2022-12-15 03:08:02 +0000
+++ new/doc/manual/ctwm.1.adoc	2024-10-21 15:02:49 +0000
@@ -755,6 +755,10 @@
   This variable specifies the background color to be used for sizing and
   information windows.  The default is ``white''.
=20
+DefaultFont `string`::
+  This variable specifies the font to be used in the Info and About window=
s,
+  and as a general fallback font.  The default is ``fixed''.
+
 DefaultForeground `string`::
   This variable specifies the foreground color to be used for sizing and
   information windows.  The default is ``black''.

=3D=3D=3D modified file 'parse_be.c'
--- old/parse_be.c	2022-11-05 01:32:18 +0000
+++ new/parse_be.c	2024-10-21 14:55:08 +0000
@@ -153,6 +153,7 @@
 #define kws_IconifyStyle                19
 #define kws_IconSize                    20
 #define kws_RplaySoundHost              21
+#define kws_DefaultFont                 22
=20
 #define kwss_RandomPlacement            1
=20
@@ -267,6 +268,7 @@
 	{ "darkshadowcontrast",     NKEYWORD, kwn_DarkShadowContrast },
 	{ "decoratetransients",     KEYWORD, kw0_DecorateTransients },
 	{ "defaultbackground",      CKEYWORD, kwc_DefaultBackground },
+	{ "defaultfont",            SKEYWORD, kws_DefaultFont },
 	{ "defaultforeground",      CKEYWORD, kwc_DefaultForeground },
 	{ "defaultfunction",        DEFAULT_FUNCTION, 0 },
 	{ "deiconifyfunction",      DEICONIFY_FUNCTION, 0 },
@@ -969,6 +971,12 @@
 			return true;
 		}
=20
+		case kws_DefaultFont:
+			if(!Scr->HaveFonts) {
+				Scr->DefaultFont.basename =3D s;
+			}
+			return true;
+
 		case kws_IconFont:
 			if(!Scr->HaveFonts) {
 				Scr->IconFont.basename =3D s;


-Olaf.
--=20
___ Olaf 'Rhialto' Seibert                            <rhialto/at/falu.nl>
\X/ There is no AI. There is just someone else's work.           --I. Rose

--bzH/L+JzMD9kTBr2
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEFVAhiiWjqgwBVdQAmYnGRWHD+9MFAmcWhb8ACgkQmYnGRWHD
+9P0Hgf+JDhgI9LD3lkXXJ/CrIyBQhhShAfCTxwaWYX56Xy4ciJHRaKXPLYAoBM8
c1G+7jLIEeXaxF9iESkmdXb/MeEDDZfTabqKjngVuR4fRRm/iFD8GBCx3I87T+z0
RHGTL/1V/a/zF70wPptoQ7bwGMelvdcY6hLXtfiP5yuAzDz/3dGwX/zYY2O7TZAA
0VXW8HWAPDTJMmAL/p2cFDLr9A1NNsNH431eyxa8MjPhN6nUhhvjwJZJBp4TwARQ
+rHpvekb5CPCABuA//hEKn3SXH6xwPYK9y8c9kOpjy6LYW/fgND6ikUEdimrTyfM
W5DIyaXDYiZ/5zKqf1vFtnRVEFqieA==
=7tqW
-----END PGP SIGNATURE-----

--bzH/L+JzMD9kTBr2--