Linux中的中文字體總是顯示不正常,究其緣由是Linux系統默認情況下不會安裝中文宋體字體。因此瀏覽中文網站的時候基本上看到的都是些亂碼,系統裏的中文也全顯示爲小方塊的亂碼。將 windows xp 系統裏的宋體字體安裝到Linux系統中可以徹底解決該問題。
XP裏宋體字體文件的位置和文件名是:C:\WINDOWS\Fonts\simsun.ttc
把simsun.ttc文件複製到Linux系統中(我放在/bak/fonts 下)。
現將我完整的命令以及返回參數粘貼如下:
[root@localhost ~]# cd /usr/share/fonts
[root@localhost fonts]# mkdir cnfonts
[root@localhost fonts]# cd cnfonts
[root@localhost cnfonts]# mkdir simsun
[root@localhost cnfonts]# cp /bak/fonts/simsun.ttc /usr/share/fonts/cnfonts/simsun
[root@localhost cnfonts]# cd simsun
[root@localhost simsun]# ls -l
total 10284
-rw-r--r-- 1 root root 10512288 Apr 24 10:35 simsun.ttc
[root@localhost simsun]# mkfontscale
[root@localhost simsun]# ls -l
total 10288
-rw-r--r-- 1 root root 716 Apr 24 10:38 fonts.scale
-rw-r--r-- 1 root root 10512288 Apr 24 10:35 simsun.ttc
[root@localhost simsun]# mkfontdir
[root@localhost simsun]# ls -l
total 10292
-rw-r--r-- 1 root root 716 Apr 24 10:39 fonts.dir
-rw-r--r-- 1 root root 716 Apr 24 10:38 fonts.scale
-rw-r--r-- 1 root root 10512288 Apr 24 10:35 simsun.ttc
[root@localhost simsun]# pwd
/usr/share/fonts/cnfonts/simsun
[root@localhost simsun]# chkfontpath --add /usr/share/fonts/cnfonts/simsun/
[root@localhost simsun]# service xfs reload
Reloading xfs: [ OK ]
[root@localhost simsun]#
到此,字體安裝完畢,註銷Linux系統,使用Xwindow登錄,在登陸框將語言選擇爲“中文(大陸)”,再登陸系統就可以正常顯示中文了。
至於如何將XP系統裏的 simsun.ttc 文件複製到 Linux下面,各有各的方法。我是在虛擬機裏運行Linux的,所以直接在XP裏創建了FTP,在Linux裏面登錄xp的ftp把windows裏的文件複製到 Linux 裏面的。
XP裏宋體字體文件的位置和文件名是:C:\WINDOWS\Fonts\simsun.ttc
把simsun.ttc文件複製到Linux系統中(我放在/bak/fonts
現將我完整的命令以及返回參數粘貼如下:
[root@localhost ~]# cd /usr/share/fonts
[root@localhost fonts]# mkdir cnfonts
[root@localhost fonts]# cd cnfonts
[root@localhost cnfonts]# mkdir simsun
[root@localhost cnfonts]# cp /bak/fonts/simsun.ttc /usr/share/fonts/cnfonts/simsun
[root@localhost cnfonts]# cd simsun
[root@localhost simsun]# ls -l
total 10284
-rw-r--r-- 1 root root 10512288 Apr 24 10:35 simsun.ttc
[root@localhost simsun]# mkfontscale
[root@localhost simsun]# ls -l
total 10288
-rw-r--r-- 1 root root 716 Apr 24 10:38 fonts.scale
-rw-r--r-- 1 root root 10512288 Apr 24 10:35 simsun.ttc
[root@localhost simsun]# mkfontdir
[root@localhost simsun]# ls -l
total 10292
-rw-r--r-- 1 root root 716 Apr 24 10:39 fonts.dir
-rw-r--r-- 1 root root 716 Apr 24 10:38 fonts.scale
-rw-r--r-- 1 root root 10512288 Apr 24 10:35 simsun.ttc
[root@localhost simsun]# pwd
/usr/share/fonts/cnfonts/simsun
[root@localhost simsun]# chkfontpath --add /usr/share/fonts/cnfonts/simsun/
[root@localhost simsun]# service xfs reload
Reloading xfs: [ OK
[root@localhost simsun]#
到此,字體安裝完畢,註銷Linux系統,使用Xwindow登錄,在登陸框將語言選擇爲“中文(大陸)”,再登陸系統就可以正常顯示中文了。
至於如何將XP系統裏的 simsun.ttc 文件複製到 Linux下面,各有各的方法。我是在虛擬機裏運行Linux的,所以直接在XP裏創建了FTP,在Linux裏面登錄xp的ftp把windows裏的文件複製到 Linux 裏面的。
袁
浙工局·寧波
2009.4.24