Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: lizardidi on November 01, 2024, 10:15:33 AM

Title: How to display chinese font in file manager?
Post by: lizardidi on November 01, 2024, 10:15:33 AM
Good day, TCL forum!

I have quite a few ebooks with chinese font file name. I already installed the flysung.tcz (correct me if misspelled)  and able to view chinese font fine in firefox.

However, in file manager those books name cannot display properly. I tried spacefm and Pcmanfm, the file appear as ??????.pdf.

Is there other .tcz i need to install in order to display them correctly?

My system is TCL 15 32bit on a intel atom netbook with 2 gb of ram.
Title: Re: How to display chinese font in file manager?
Post by: lizardidi on November 01, 2024, 10:21:53 AM
Sorry, what i meant is ? ? ? ? ?.pdf but it automatically turned into those emoji.
Title: Re: How to display chinese font in file manager?
Post by: Rich on November 01, 2024, 10:51:55 AM
Hi lizardidi
According to this:
http://ignorantguru.github.io/spacefm/spacefm-manual-en.html
there are a bunch of places for setting fonts. Open the manual
with your web browser and search for font.
Title: Re: How to display chinese font in file manager?
Post by: lizardidi on November 01, 2024, 11:44:54 AM
Hi lizardidi
According to this:
http://ignorantguru.github.io/spacefm/spacefm-manual-en.html
there are a bunch of places for setting fonts. Open the manual
with your web browser and search for font.

Thank you Rich!
Tried spacefm font option adjustments, unable to display chinese fonts.
I suspect this is not due to spacefm settings, because Pcmanfm also cannot display the file name correctly.

Maybe this is a system locale thing?

I tried to install getlocale.tcz then i set locale to zh_CN.UTF-8
Then i reboot and in terminal i type lang=zh_CN.UTF-8 ... Unsuccessful T.T



Title: Re: How to display chinese font in file manager?
Post by: GNUser on November 01, 2024, 12:57:53 PM
Pcmanfm also cannot display the file name correctly.

Hi lizardidi. I once had a similar issue, where I had loaded the fonts I needed and my locale was correct, but GUI file managers failed to display diacritical marks. For me what solved the problem was to add this:
Code: [Select]
G_FILENAME_ENCODING=@localeor this:
Code: [Select]
G_FILENAME_ENCODING=UTF-8to ~/.profile and reboot.
But before you try that, make sure your locale is correct by typing locale in a terminal.
Title: Re: How to display chinese font in file manager?
Post by: Rich on November 01, 2024, 01:12:29 PM
Hi lizardidi
This thread looks like it might be relevant, though it appears
to be a mix of Chinese and English so I can't read it:
https://forum.tinycorelinux.net/index.php/topic,4222.0.html

I also found this from polikuo:
I prefer unifont over fireflysung cause I've seen plenty of words missing with fireflysung.
However, unifont.tcz is slightly larger than fireflysung.tcz
Title: Re: How to display chinese font in file manager?
Post by: lizardidi on November 03, 2024, 03:01:32 AM
@Rich : Thanks for the referemce. That topic is about chinese input method. Whereas I just need to display chinese character file name... which is my pdf ebooks.

@GNUser : Tried your method, not working... However when I checked with 'locale' in terminal, it is LOCALE=C.. Which is weird.. I might have broken the Tiny Core system when I learn and trying lots of stuff here..For now I formatted the HDD and reverted to old system for daily chores.. Usually when I paste chinese .ttf font in /usr/share/fonts/ and restart X, the file name will display properly.. Will tinkering again next week.
Title: Re: How to display chinese font in file manager?
Post by: GNUser on November 03, 2024, 03:45:17 PM
when I checked with 'locale' in terminal, it is LOCALE=C
Hi lizrdidi. That's most likely the main problem. I think you'll have success if you follow these steps:

1. Load the extensions you need:
   tce-load -wi getlocale
   and either  tce-load -wi unifont  or  tce-load -wi fireflysung
   (note: I use TCL15 x86_64, which does not have fireflysung in the repo. Presumably your TCL version has it)
2. When prompted by getlocale, select your desired locale (zh_CN.UTF-8)
3. When getlocale is done, make sure it created /etc/sysconfig/tcedir/optional/mylocale.tcz
4. Make sure /etc/sysconfig/tcedir/onboot.lst contains this line (if this line does not exist in the file, add it):
Code: [Select]
mylocale.tcz5. If you see getlocale.tcz in /etc/sysconfig/tcedir/onboot.lst, it's okay to remove it
6. Add G_FILENAME_ENCODING=@locale to ~/.profile
7. Your bootloader entry for TCL has a linux line and an initrd line. The to the linux line you should add lang=zh_CN.UTF-8
My bootloader's TCL entry has this linux line, for example (UUID show below was edited for privacy):
Code: [Select]
linux /boot/vmlinuz64 tce=UUID="e473b991-b711-4ad0-bf79-d6aaaaabbbbb" opt=UUID="e473b991-b711-4ad0-bf79-d6aaaaabbbbb" tz=EST+5EDT,M3.2.0/2,M11.1.0/2 syslog lang=en_US.UTF-8 user=bruno
I think after all the above is in place, things will work as you expect after you reboot.
Title: Re: How to display chinese font in file manager?
Post by: lizardidi on November 07, 2024, 04:10:42 AM
I tried all steps above. Indeed the system font of pcmanfm switched to chinese... But the filename is unable to display (??????.pdf)

Tried 3 fresh installation 32bit and 64bit.. Spacefm.. Pcmanfm.. Nnn... MC.. Emelfm.. Emelfm2... U named it, tried all of them all unable to display file name. Not only that, when you try to create a new file name with chinese characters, an error "invalid filename" will occur. I installed all the locale.tcz for these file managers. Browsers can display chinese fonts without problem.

ONLY on rox filer the filename will display correctly, not as some blocks or random code. So I guess I will stick to Rox filer is my only option on tiny core.

Title: Re: How to display chinese font in file manager?
Post by: gadget42 on November 07, 2024, 06:58:55 AM
does anyone know how rox-filer displays this correctly? i have dug around and am here:

 https://github.com/rox-desktop/rox-filer/blob/dbc77943c043dba62d68f633757349c131d2fee8/ROX-Filer/src/Docs/Manual.xml#L2664

but it makes reference to "Open the Options box from the menu" then "Select a language from the list" then "Click on ok and restart the filer for the new setting to take full effect"

which "Options box" are they referring to?

full disclosure: i had the latest version of EasyOS at hand and knew it uses rox-filer so am currently on EasyOS LiveUSB and accessing /usr/local/apps/ROX-Filer/Help/Manual.html via chromium
Title: Re: How to display chinese font in file manager?
Post by: GNUser on November 07, 2024, 10:29:27 AM
Hi lizardidi. I'm sorry to hear you're still having problems.

Today I loaded pcmanfm to see if I can reproduce your problem. I found that pcmanfm can handle chinese characters in filenames just fine. My tests were with pcmanfm as it comes "out of the box" without any special configuration.

I use a UTF-8 locale (specifically, en_US.UTF-8). If no unicode font is loaded, pcmanfm shows chinese filenames as little boxes with numbers (humorously referred to as "tofus"). But if I load a suitable font (e.g., unifont.tcz), close pcmanfm, and reopen pcmanfm, then the chinese filename displays correctly. See the "withoutfont.jpg" and "withfont.jpg" screenshots (attached).

Please, what's the output of these commands?

Code: [Select]
$ locale
$ tce-status -i | grep font
$ tce-status -i | grep locale
$ ls -lh /etc/sysconfig/tcedir/optional/mylocale.tcz
$ echo $G_FILENAME_ENCODING
Title: Re: How to display chinese font in file manager?
Post by: lizardidi on November 08, 2024, 04:35:49 AM
https://ibb.co/jLkmmJQ (https://ibb.co/jLkmmJQ)

I attached my desktop here, showing Rox fm on the upper left displaying file name correctly. On the right, Pcmanfm.. Spacefm.. Xfe.. Mc.. Emelfm2... all unable to display the chinese font filename. Really weird behaviour.  :o :o :o

I only want to display filename correctly, without changing system language though..

Title: Re: How to display chinese font in file manager?
Post by: gadget42 on November 08, 2024, 05:23:21 AM
@lizardidi, thanks for that great screenshot! it definitely provides clarification regarding what you are experiencing. still investigating at this end. rox-filer is _doing_something_ or _has_something_ that the others don't. but what? and naturally it will be simple once we figure it out...lol...sigh...

@GNUser, looking at your first screenshot you show the results of "locale" but in the second we don't get to see if that changes in any way after loading unifont.tcz?
Title: Re: How to display chinese font in file manager?
Post by: gadget42 on November 08, 2024, 05:49:49 AM
@lizardidi, could you attach your small(230b) test file "test****.txt" so i can use the exact same file for testing at my end? thanks.
Title: Re: How to display chinese font in file manager?
Post by: GNUser on November 08, 2024, 07:51:31 AM
Hi gadget42. locale is the same in both screenshots.

Hi lizardidi. If you'd like to troubleshoot further, please post the output of the commands in my previous post. If you're happy with Rox and just want to move on, that's fine too :)
Title: Re: How to display chinese font in file manager?
Post by: lizardidi on November 08, 2024, 11:41:57 PM
@gadget42: of course a great shot! Taken with TCL 15!  ;D ;D

as attached is the test.txt file.

to @GNUser:
Quote
$ locale
Quote
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=

Quote
tc@box:~$ tce-status -i | grep font
Xorg-fonts
fontconfig
libXfont2
libfontenc
mononoki-ttf-fonts
notocjk-regular-fonts-ttc

Quote
tc@box:~$ tce-status -i | grep locale
getlocale
glibc_i18n_locale
libfm-locale
mc-locale
mylocale
pcmanfm-locale
rox-filer-locale

Quote
tc@box:~$ ls -lh /etc/sysconfig/tcedir/optional/mylocale.tcz
-rw-rw-r-- 1 tc staff 1.5M Nov  7 02:47 /etc/sysconfig/tcedir/optional/mylocale.tcz

Quote
tc@box:~$ echo $G_FILENAME_ENCODING
iso8859-1

As you all can see, do forgive me if the output is a total mess. As a seasoned Noob I can't completely recalled what else commands I throw at the terminal. 
Thank you all very, very much for showing great patience in assisting me!
Title: Re: How to display chinese font in file manager?
Post by: GNUser on November 09, 2024, 07:59:11 AM
Hi lizardidi. Thanks for the additional information. I did some tests and this is the bare minimum that pcmanfm needs to show chinese characters in filenames:

1. a good enough font
2. G_FILENAME_ENCODING set correctly

This should work for you:
Code: [Select]
$ tce-load -wi unifont
$ G_FILENAME_ENCODING=UTF-8 pcmanfm
If you don't want to specify G_FILENAME_ENCODING=UTF-8 each time you run pcmanfm, you can either add export G_FILENAME_ENCODING=UTF-8 to your ~/.profile or create a wrapper script for pcmanfm.

P.S. I noted that your locale is not set correctly, but you don't need to fix that to fix your file manager issue.
Title: Re: How to display chinese font in file manager?
Post by: gadget42 on November 09, 2024, 10:42:37 AM
latest report:
fresh TinyCorePure64-15.0.iso, good checksum, good dd to stick, booted on Lenovo Y580 laptop, mount stick with test???.txt file, no chinese font

connect to internet, loaded rox-filer-doc(no change naturally), loaded rox-filer(no change), loaded rox-filer-locale(no change...no chinese font)

all locale are "C"
tce-status -i | grep font reports fontconfig, libXfont, and libfontenc
tce-status -i | grep locale reports rox-filer-locale

so rox displaying chinese font doesn't originate in rox and/or it's dependencies, must be something else that was added.

it would be nice to figure out exactly which package is providing this functionality. we'll keep thinking and experimenting.
Title: Re: How to display chinese font in file manager?
Post by: Rich on November 09, 2024, 02:14:28 PM
Hi gadget42
... so rox displaying chinese font doesn't originate in rox and/or it's dependencies, must be something else that was added.

it would be nice to figure out exactly which package is providing this functionality. we'll keep thinking and experimenting.

My guess would be this package that includes Simplified/Traditional Chinese fonts:
...
Quote
tc@box:~$ tce-status -i | grep font

 ----- Snip -----

notocjk-regular-fonts-ttc
...
Title: Re: How to display chinese font in file manager?
Post by: polikuo on November 10, 2024, 04:31:52 AM
Hi all
Looks like I'm late to the party.

Generally speaking, to display Chinese characters, you'll need:
1. glibc locale support (get_locale.tcz)
2. global variable (export LC_ALL=zh_CN.utf8 or in bootloader lang=zh_CN.utf8)
3. proper font package (unifont.tcz), note that unifont is designed for utf8, if you need special encoding such as big5 or gb18030, you'll need dedicated fonts. (zh_CN.big5)
4. BTW, you'll need file managers that were compiled with font-config support, TC packages tend to aim for the minimum, dropping that is possible. (pcmanfm-locale.tcz looks promising)
5. Configure the system so that it knows where to find the fonts (TC standards: /usr/locale/share/fonts), which normally automatically configured when the font is loaded. (tce-load -i fontconfig; fc-cache -fv)

I don't have any x86_64 TC computer around at the moment, so I could only guess the start up scripts need some fixing.
Title: Re: How to display chinese font in file manager?
Post by: lizardidi on November 11, 2024, 06:49:16 AM
Big shoutout to everyone who helped me out! I reset my installation and have been fumbling around, trying other tcz. but your advice has been priceless. Seriously, thank you!