Open louies0623 opened 10 months ago
What exactly does TW mean? You talk about zh_TW locale?
I cannot read ZH but I can tell you what seems to work for me, maybe this helps. Step by step:
a) make sure that you have general system support enabled (dpkg-reconfigure locales
). But I guess that is already there since you brought your icewm session into locale-aware state already.
b) make sure to have some CJK-offering fonts installed. Example:
fc-list | grep CJK
If nothing listed, install some, like: sudo apt install fonts-noto-cjk
c) locate your config folder. That is probably ~/.icewm or ~/.config/icewm .
d) in the config folder, create the prefoverride
file (for details, read the manpage, man icewm-prefoverride
)
e) get existing settings and adapt them to CJK specific fonts. Also get the fontconfig name of the font that you want:
icewm -p | grep Xft
fc-list | grep CJK
-> replace the regular font name with the font of your choice, then put this into the mentioned prefoverride file. You might also change size or add or remove bold attribute, to improve readability.
In my example (Noto fonts, see below), this looks like:
$ grep CJK .icewm/prefoverride
TitleFontNameXft="Noto Sans CJK JP:size=12"
MenuFontNameXft="Noto Sans CJK JP:size=10:bold"
StatusFontNameXft="Noto Sans CJK JP Mono:monospace:size=12:bold"
QuickSwitchFontNameXft="Noto Sans CJK JP Mono:monospace:size=12:bold"
NormalButtonFontNameXft="Noto Sans CJK JP:size=12"
ActiveButtonFontNameXft="Noto Sans CJK JP:size=12:bold"
NormalTaskBarFontNameXft="Noto Sans CJK JP:size=12"
ActiveTaskBarFontNameXft="Noto Sans CJK JP:size=12:bold"
ToolButtonFontNameXft="Noto Sans CJK JP:size=12"
NormalWorkspaceFontNameXft="Noto Sans CJK JP:size=12"
ActiveWorkspaceFontNameXft="Noto Sans CJK JP:size=12"
ListBoxFontNameXft="Noto Sans CJK JP:size=12"
ToolTipFontNameXft="Noto Sans CJK JP:size=12"
ClockFontNameXft="Noto Sans CJK JP Mono:monospace:size=12"
TempFontNameXft="Noto Sans CJK JP Mono:monospace:size=12"
ApmFontNameXft="Noto Sans CJK JP Mono:monospace:size=12"
InputFontNameXft="Noto Sans CJK JP:size=12:bold"
LabelFontNameXft="Noto Sans CJK JP:size=12"
Actually I could imagine creating a special icewm-cjk package in Debian, which would make such settings default. But it would be even better if icewm had a special feature, some kind of locale-specific trigger which would load a different subset of default settings. @gijsbers your opinion?
@louies0623 Can you recommend which fonts could be selected by default, i.e. which are typically present and would work best on a default Debian installation for zh_TW?
Yes zh_TW
I'm pretty sure I have the fonts installed on the system, as shown in the picture
The recommended system font is Noto Sans CJK TC and Noto serif CJK TC Or Standard Unifont with full font range
Okay. Then the suggested config change should work when Noto fonts are present. In the meantime I checked how we can automate the font selection. Qt and GTK have smart ways to match the font list against the locale (see screenshot of yours) but icewm does not. And using the Xft API alone seems not to respect the locale.
But it seems like one can enforce the font filtering for the locale by specifying it explicitly, and NOT specifying a custom font (which is currently the hardcoded setting). Like:
TitleFontNameXft="Sans:size=12::lang=zh-tw"
MenuFontNameXft="Sans:size=10:bold::lang=zh-tw"
StatusFontNameXft="Sans Mono:monospace:size=12:bold::lang=zh-tw"
QuickSwitchFontNameXft="Sans Mono:monospace:size=12:bold::lang=zh-tw"
NormalButtonFontNameXft="Sans:size=12::lang=zh-tw"
ActiveButtonFontNameXft="Sans:size=12:bold::lang=zh-tw"
NormalTaskBarFontNameXft="Sans:size=12::lang=zh-tw"
ActiveTaskBarFontNameXft="Sans:size=12:bold::lang=zh-tw"
ToolButtonFontNameXft="Sans:size=12::lang=zh-tw"
NormalWorkspaceFontNameXft="Sans:size=12::lang=zh-tw"
ActiveWorkspaceFontNameXft="Sans:size=12::lang=zh-tw"
ListBoxFontNameXft="Sans:size=12::lang=zh-tw"
ToolTipFontNameXft="Sans:size=12::lang=zh-tw"
ClockFontNameXft="Sans Mono:monospace:size=12::lang=zh-tw"
TempFontNameXft="Sans Mono:monospace:size=12::lang=zh-tw"
ApmFontNameXft="Sans Mono:monospace:size=12::lang=zh-tw"
InputFontNameXft="Sans:size=12:bold::lang=zh-tw"
LabelFontNameXft="Sans:size=12::lang=zh-tw"
Or if you need to find a matching font explicitly, try:
fc-list :lang=zh-tw
And change "Sans" to whatever you like.
@gijsbers We probably should automate this handling. I.e. remove the hardcoded font name, and if locale is not plain C and also when the font spec is not having a lang= string inside then add a such lang string (as shown above, with trivial character mapping from LC_CTYPE or LC_LANG); and only when no font can be resolved like that, only then fall back to the font spec without lang=. We could also have a fall-back scheme on top, for example have a way to specify a list of Xft setting (semicolon separated?) so that it would be possible to try both ways, i.e. first load "DejaVu Sans:..." and if that does not work then try with "Sans:...". I could actually try to implement this soon - any objections?
I hope your team can fix this, so I have no objections.
Yes, we could improve the current situation, but what is the source of the ":lang=%s" parameter? Where in the source do we have this? Why do you want to remove the hardcoded font name?
@Code7R You mention LC_LANG, but this seems undefined and a typo?
@louies0623 Can you give me your values of LANG and LCALL? Like: `set | grep -e LANG -e LC` ?
@gijsbers Please have a look at https://github.com/bbidulock/icewm/pull/762 , this should do the job. IMHO the setlocale call for LC_CTYPE should return you either the value of LC_CTYPE (if set) or fall back to the value of LANG. I.e. the normal behavior of locale() mechanism. So we get the lang/country part and amend it to get the Xft syntax.
Thanks! I wrote this patch, which is similar, but failed to notice an actual improvement. yfontxft.cc.txt
@gijsbers Sorry for the late reply, this is the result I got, and then the clock in the lower left corner doesn't display properly
Debian 12 use install apt-get icewm