因為在安裝linux(redhat enterprise linux 5.0)的過程中忘記了選擇支持中文,所以機器在安裝完之後從Mozzila訪問中文網站全是亂碼,在「查看」菜單中即使選擇GBK的編碼字符集或其他中文字符集也無效,另外在shell中的中文也為亂碼。
重裝機器,個人覺得比較煩,不想那樣做。於是我選擇了對其進行漢化,就在網上找了半天些資料,(現在可以顯示中文了,但還有些亂碼,有時間盡量去解決,這裡先分享!-見笑!)另外,大家可別在真正的伺服器上做這個實驗,要做也可以,出問題了別找我!
第一步:
修改文件/etc/sysconfig/i18n。將裡面的en:US.UTF8修改成zh_CN.GB18030,修改後的內容如下:
LANG="zh_CN.GB18030"
LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"
SUPPORTED="zh_CN.GB18030:zh_CN:zh"
SYSFONT="lat0-sun16"
SYSFONTACM="8859-15"
第二步:
安裝中文字型檔。字型檔文件一般是獨立於系統的,所以我選擇了將windows下的字型檔文件安裝到linux中去,大家可以到網上找找看,我最終選擇的是windows中的字型檔文件位於C:\WINDOWS\Fonts下,選擇其中的三個文件(simsun.ttc,tahoma.ttf ,tahomabd.ttf)。
首先,逐個創建文件夾,直到擁有/usr/share/fonts/default/TrueType。然後,想辦法將這三個字型檔文件直接複製到linux分區的/usr/share/fonts/default/TrueType。
其次我們要配置顯卡文件/etc/X11/XF86Config——我裝的這個系統沒有這個文件,可以從其他地方獲取一個,我是從redhat linux 9.0中copy的!X中可以支持TrueType字體(一種可縮放的矢量字體,這些字體需要字體渲染引擎來讀取。字體渲染引擎有很多種,我們現在就是要配置指定用xtt這個字體渲染引擎去/usr/share/fonts/default/TrueType目錄讀取上面的三個字體文件的信息(如大小,分辯率,編碼等)。修改其中的Section "Module"處,加入Load 「xtt」讓其用使用xtt這個引擎,並註釋掉與其衝突的#Load "freetype"與 #Load "type1"。
另外,在Section "Files"處加入FontPath 「/usr/share/fonts/default/TrueType」一句讓xtt引擎去這個目錄去找字型檔文件。修改後的部分文件如下:
Section "Files"
# RgbPath is the location of the RGB database. Note, this is the name of the
# file minus the extension (like ".txt" or ".db"). There is normally
# no need to change the default.
# Multiple FontPath entries are allowed (they are concatenated together)
# By default, Red Hat 6.0 and later now use a font server independent of
# the X server to render fonts.
RgbPath "/usr/X11R6/lib/X11/rgb"
FontPath "unix/:7100"
FontPath 「/usr/share/fonts/default/TrueType」
EndSection
Section "Module"
Load "dbe"
Load "extmod"
Load "fbdevhw"
Load "glx"
Load "record"
#Load "freetype"
#Load "type1"
Load "dri"
Load 「xtt」
EndSection
最後,建立配置文件fonts.dir與fonts.scale。方法很簡單,在/usr/share/fonts/default/TrueType運行命令ttmkfdir > fonts.dir即可生成一個有內容的fonts.scale的文件與一個空的fonts.dir。然後在fonts.scale中加入一行(別忘了修改第一行的那個數字):
ds=y:ai=0.3:SimSun.ttf ?misc-SimSun-bold-i-normal ?-0-0-0-0-p-0-gbk-0
接著,將fonts.scale複製一份到fonts.dir即可。(運行命令cp fonts.scale fonts.dir)
最後,將/usr/x11R6/lib/X11/fonts/encodings/encoding.dir(這個文件也是從別出cp過來的)複製到/usr/share/fonts/default/TrueType中。
重啟機器,OK。
[火星人
]
在linux中安裝字型檔已經有1291次圍觀
http://coctec.com/docs/linux/show-post-201329.html