Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CJK TW text is missing #149

Open
louies0623 opened this issue Nov 7, 2023 · 9 comments
Open

CJK TW text is missing #149

louies0623 opened this issue Nov 7, 2023 · 9 comments
Labels
enhancement New feature or request

Comments

@louies0623
Copy link

Debian 12
use install apt-get icewm

VirtualBox_PC-3_07_11_2023_15_16_33

@Code7R
Copy link
Contributor

Code7R commented Nov 7, 2023

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"

test-icewm-with-zh_TW

@Code7R Code7R added the enhancement New feature or request label Nov 7, 2023
@Code7R
Copy link
Contributor

Code7R commented Nov 7, 2023

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?

@louies0623
Copy link
Author

louies0623 commented Nov 7, 2023

Yes zh_TW
I'm pretty sure I have the fonts installed on the system, as shown in the picture
VirtualBox_PC-3_07_11_2023_17_22_37

The recommended system font is Noto Sans CJK TC and Noto serif CJK TC
Or Standard Unifont with full font range

@Code7R
Copy link
Contributor

Code7R commented Nov 7, 2023

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?

@louies0623
Copy link
Author

I hope your team can fix this, so I have no objections.

@gijsbers
Copy link
Contributor

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?

@gijsbers
Copy link
Contributor

@Code7R You mention LC_LANG, but this seems undefined and a typo?

@louies0623 Can you give me your values of LANG and LC_ALL? Like: set | grep -e LANG -e LC_ ?

Code7R added a commit to Code7R/icewm that referenced this issue Jan 2, 2024
This is not as smart as libpango and similar but should instruct Xft
sufficiently to select a Sans compatible font which actually brings the
required codeset.

Closes ice-wm/icewm#149
Code7R added a commit to Code7R/icewm that referenced this issue Jan 2, 2024
This is not as smart as libpango and similar but should instruct Xft
sufficiently to select a Sans compatible font which actually brings the
required codeset.

Closes ice-wm/icewm#149
@Code7R
Copy link
Contributor

Code7R commented Jan 2, 2024

@gijsbers Please have a look at bbidulock/icewm#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.

@gijsbers
Copy link
Contributor

Thanks! I wrote this patch, which is similar, but failed to notice an actual improvement.
yfontxft.cc.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants