When we encounter some Chinese display garbled problems, it may be because the server does not install Chinese fonts
1. View system fonts
Before starting the installation, we first check the installed fonts in the system. To view the installed fonts in the system, we can use the
fc-listIf there is no command in the system, we need to install the relevant software package first.
On CentOS, use the following command to install:
yum install -y fontconfig mkfontscale
2. After installation, we can check the fonts installed in the system
[[email protected] php]# fc-list /usr/share/fonts/urw-base35/NimbusMonoPS-Italic.otf: Nimbus Mono PS:style=Italic /usr/share/fonts/urw-base35/D050000L.t1: D050000L:style=Regular ...
3. To view the Chinese fonts installed in the system, we can use the following command
[[email protected] php]# fc-list :lang=zh
From the above figure, we can see that there is no Chinese font in the system
4. We go to the Windows font directory
5. Will simfang.ttf Copy fonts remotely or put them into the server’s font directory in other ways
//Remote replication scp simfang.ttf [email protected]:/usr/share/fonts
6. Then the font index information is established and the font cache is updated
cd /usr/share/fonts/ mkfontscale mkfontdir fc-cache
7. At this point, the font has been installed. Now let’s check whether the Chinese font is installed successfully
[[email protected] php]# fc-list :lang=zh /usr/share/fonts/ simfang.ttf : Fangsong, Fangsong: style = regular, normal, oby TCH ejn é, standard, Γ νιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιι
From the above figure, we can clearly see that the Chinese font has been successfully installed.
This work adoptsCC agreementThe author and the link to this article must be indicated in the reprint