bbidulock / icewm

A window manager designed for speed, usability, and consistency
Other
577 stars 98 forks source link

Font changes depending on NLS support #613

Closed qsmodo closed 2 years ago

qsmodo commented 2 years ago

In a Gentoo system, below is icewm --configured, 1st line with nls USE flag and 2nd line without it.

1. icewm configured options: alsa corefonts fdomenus gdkpixbuf i18n librsvg libxpm nls session shape xrandr
2. icewm configured options: alsa corefonts fdomenus gdkpixbuf librsvg libxpm session shape xrandr

The font I set for the clock is

$ icewm -p | grep ClockFont
ClockFontName="-*-unifont-*-*-*-*-*-*-*-*-*-*-*-*"
ClockFontNameXft=""

Now, with NLS I get a font, and without it I get another:

  1. nls
  2. nonls
gijsbers commented 2 years ago

Yes, these code paths are less well trodden. I suppose we like a consistent and predictable behavior. Low pri.

gijsbers commented 2 years ago

If you set MultiByte=0 then they should look the same.

gijsbers commented 2 years ago

If there are missing codesets, then icewm constructs its own fontset, if i18n is enabled. The unifont family may not have many options, hence the diversion.

gijsbers commented 2 years ago

I made many changes to font handling and also to these corefonts settings. If you like, you could help me by testing and giving feedback on the current state of affairs.

gijsbers commented 2 years ago

I forgot to mention that there is now more detailed font logging with Trace=font. This shows for corefonts MultiByte=1 which fonts are loaded and their sizes.

qsmodo commented 2 years ago

Given these settings,

$ icewm -p | grep -Ei 'terminus|unifont|prefer|byte'
MultiByte=1
PreferFreetypeFonts=0
TitleFontName="-*-unifont-*"
NormalButtonFontName="-*-unifont-*"
NormalTaskBarFontName="-*-terminus-*-*-*-*-18-*"

If I compile with --disable-nls --disable-xfreetype, then indeed I verify what you said: The terminus font is loaded, but not unifont. If I disable MultiByte, then both fonts are loaded.

Now, with --disable-nls only, no matter what, neither terminus nor unifont are loaded: I guess only Freetype fonts are allowed in this case. From the Trace=font:

13:32:28.813: IceWM: font open: monospace:size=12 ascent=15,descent=4 
13:32:28.822: IceWM: font open: sans-serif:size=12:bold ascent=15,descent=4 
13:32:28.824: IceWM: font open: sans-serif:size=12 ascent=15,descent=4 
13:32:31.283: IceWM: font open: sans-serif:size=10:bold ascent=13,descent=4 
gijsbers commented 2 years ago

This unifont may not be defined or configured very well. What output gives xlsfonts on this? Can you xfd with several different sizes? The only size I can get is 16.

When MultiByte=1 then XCreateFontSet is used:

   The XCreateFontSet function creates a font set for the specified display.
   The font set is bound to the current locale when XCreateFontSet is called.
   The font set may be used in subsequent calls to obtain font and character
   information and to image text in the locale of the font set.

So your current locale must match the font you want to be loaded.

For freetype fonts each FontName must be written as FontNameXft.

--disable-nls has no relevance to this issue.

qsmodo commented 2 years ago

Yes, the Unifont bitmap only supports size 16. Furthermore, I have had problems with that font in some applications, e.g., Gvim, so I reckon your initial assumption about its incompleteness is right.

However, the Terminus bitmap always works fine with me. And even if I put another XLFD (e.g. *-fixed-*) it doesn't work. All in all, it seems no XLFD works if xfreetype is enabled (only Xft fonts are accepted apparently), and that independently of the value of MultiByte.

$ xlsfonts -fn '-*-unifont-*'
-gnu-unifont-medium-r-normal-sans-0-0-75-75-c-0-iso10646-1
-gnu-unifont-medium-r-normal-sans-16-160-75-75-c-80-iso10646-1
$ xlsfonts '*-terminus-*'
-xos4-terminus-bold-r-normal--0-0-72-72-c-0-iso10646-1
-xos4-terminus-bold-r-normal--12-120-72-72-c-60-iso10646-1
-xos4-terminus-bold-r-normal--14-140-72-72-c-80-iso10646-1
-xos4-terminus-bold-r-normal--16-160-72-72-c-80-iso10646-1
-xos4-terminus-bold-r-normal--18-180-72-72-c-100-iso10646-1
-xos4-terminus-bold-r-normal--20-200-72-72-c-100-iso10646-1
-xos4-terminus-bold-r-normal--22-220-72-72-c-110-iso10646-1
-xos4-terminus-bold-r-normal--24-240-72-72-c-120-iso10646-1
-xos4-terminus-bold-r-normal--28-280-72-72-c-140-iso10646-1
-xos4-terminus-bold-r-normal--32-320-72-72-c-160-iso10646-1
-xos4-terminus-medium-r-normal--0-0-72-72-c-0-iso10646-1
-xos4-terminus-medium-r-normal--12-120-72-72-c-60-iso10646-1
-xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso10646-1
-xos4-terminus-medium-r-normal--16-160-72-72-c-80-iso10646-1
-xos4-terminus-medium-r-normal--18-180-72-72-c-100-iso10646-1
-xos4-terminus-medium-r-normal--20-200-72-72-c-100-iso10646-1
-xos4-terminus-medium-r-normal--22-220-72-72-c-110-iso10646-1
-xos4-terminus-medium-r-normal--24-240-72-72-c-120-iso10646-1
-xos4-terminus-medium-r-normal--28-280-72-72-c-140-iso10646-1
-xos4-terminus-medium-r-normal--32-320-72-72-c-160-iso10646-1
$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE=C
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
gijsbers commented 2 years ago

Again, this makes sense, if you read and understand the manpage for XCreateFontSet. Your terminus font is a iso10646 font, while your locale specifies UTF-8. See https://en.wikipedia.org/wiki/Universal_Coded_Character_Set.

qsmodo commented 2 years ago

I don't understand why the fact that XLFD is ignored, even if it specifies an appropriate font (ISO10646) for the locale (en_US.UTF-8), makes sense.

I observe that if Icewm is compiled with xfreetype, XFLD is never used, only Xft. Are we on the same page about this? If yes, what is the point of "PreferFreetypeFonts"? It does not seem to change anything.

gijsbers commented 2 years ago

I dug deeper and found that XCreateFontSet reorders the loaded fonts at will, which doesn't seem to be documented anywhere. Icewm loads additional fonts in a fontset when codesets are missing, but this makes your specified terminus font unused, due to the undocument fontset reordering. I have now restricted the loading of additional fonts to the same font family. When i18n this is now fully disabled, so you will only get what you specify. Can you try again?

gijsbers commented 2 years ago

@qsmodo The terminus font is now the only loaded font. See: terminus