centos7下安裝中文字型

slnngk發表於2024-05-28

1.安裝fontconfig
yum -y install fontconfig

2.建立chinesem目錄
/usr/shared/fonts目錄下新建一個目錄chinese
#cd /usr/share/fonts
#mkdir chinese

3.上傳如下兩個檔案到目錄/usr/share/fonts/chinese
simhei.ttf
simsun.ttc
宋體和黑體

這兩個檔案在windows下的C:\Windows\fonts下可以找到

cp /tmp/simhei.ttf /usr/share/fonts/chinese/
cp /tmp/simsun.ttc /usr/share/fonts/chinese/

4.修改許可權
#chmod -R 755 /usr/share/fonts/chinese

5.安裝ttmkfdir
yum -y install ttmkfdir

6.執行如下命令
ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir

7.修改/etc/fonts/fonts.conf檔案
vi /etc/fonts/fonts.conf

<!-- Font directory list -->

        <dir>/usr/share/fonts</dir>
        <dir>/usr/share/X11/fonts/Type1</dir> <dir>/usr/share/X11/fonts/TTF</dir> <dir>/usr/local/share/fonts</dir>
        <dir>/usr/share/fonts/chinese</dir>
        <dir prefix="xdg">fonts</dir>
        <!-- the following element will be removed in the future -->
        <dir>~/.fonts</dir>

8.執行如下命令
#fc-cache

9.檢視

[root@hxl-hangzhou-db-backup001 fonts]# fc-list
/usr/share/fonts/dejavu/DejaVuSansCondensed-Oblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique
/usr/share/fonts/dejavu/DejaVuSansCondensed-Bold.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold,Bold
/usr/share/fonts/chinese/simsun.ttc: SimSun,宋體:style=Regular,常規
/usr/share/fonts/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book
/usr/share/fonts/chinese/simsun.ttc: NSimSun,新宋體:style=Regular,常規
/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
/usr/share/fonts/dejavu/DejaVuSansCondensed.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed,Book
/usr/share/fonts/dejavu/DejaVuSans-ExtraLight.ttf: DejaVu Sans,DejaVu Sans Light:style=ExtraLight
/usr/share/fonts/chinese/simhei.ttf: SimHei:style=Normal
/usr/share/fonts/dejavu/DejaVuSansCondensed-BoldOblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold Oblique,Bold Oblique
/usr/share/fonts/dejavu/DejaVuSans-Oblique.ttf: DejaVu Sans:style=Oblique
/usr/share/fonts/dejavu/DejaVuSans-BoldOblique.ttf: DejaVu Sans:style=Bold Oblique

相關文章