2009-01-15

「手把手」告別你的Wine中文亂碼-Wine二部曲

想想還是先讓你們搞定中文亂碼好了,此方法不用幫Wine打補丁,中文就可以正常囉,告別亂碼吧!

以下我選用Google提供字型Droid,當然你也可以使用別的字型替代,甚至從安裝好的Windows把字型Copy到Wine。





  • 假設你已經造著我寫的裝好了Droid字型,在把字型連結到Wine

ln -s ~/.fonts/droid/DroidSansFallback.ttf ~/.wine/drive_c/windows/Fonts/
  • 首先要新增一個reg登錄檔
    注意:存檔時字元編碼選則為BIG5,否則匯入後新細明體那欄會變亂碼。



gedit ~/font.reg

把底下內容存進font.reg


REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontLink]
"FontLinkControl"=dword:00004000
"FontLinkDefaultChar"=dword:00003000
/* 平滑化(anti-alias) */
/* 如果覺得開了之後字體難看,把三個Y改成N */
[HKEY_CURRENT_USER\Software\Wine\X11 Driver]
"ClientSideAntiAliasWithCore"="Y"
"ClientSideAntiAliasWithRender"="Y"
"ClientSideWithRender"="Y"
/* 平滑字型 */
[HKEY_CURRENT_USER\Control Panel\Desktop]
"FontSmoothing"="2"
/* 替換字型1 */
/* 安裝Wine不會提供字型,所以需要替換字型,我以Droid Sans Fallback替換 */
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontSubstitutes]
"Arial Baltic,186"="Droid Sans Fallback,186"
"Arial CE,238"="Droid Sans Fallback,238"
"Arial CYR,204"="Droid Sans Fallback,204"
"Arial Greek,161"="Droid Sans Fallback,161"
"Arial TUR,162"="Droid Sans Fallback,162"
"Courier New Baltic,186"="Droid Sans Fallback,186"
"Courier New CE,238"="Droid Sans Fallback,238"
"Courier New CYR,204"="Droid Sans Fallback,204"
"Courier New Greek,161"="Droid Sans Fallback,161"
"Courier New TUR,162"="Droid Sans Fallback,162"
"Helv"="Droid Sans Fallback"
"Helvetica"="Droid Sans Fallback"
"MS Shell Dlg"="Droid Sans Fallback"
"MS Shell Dlg 2"="Droid Sans Fallback"
"PMingLiU"="Droid Sans Fallback"
"新細明體"="Droid Sans Fallback"
"Tahoma"="Droid Sans Fallback"
"Times"="Droid Sans Fallback"
"Times New Roman Baltic,186"="Droid Sans Fallback,186"
"Times New Roman CE,238"="Droid Sans Fallback,238"
"Times New Roman CYR,204"="Droid Sans Fallback,204"
"Times New Roman Greek,161"="Droid Sans Fallback,161"
"Times New Roman TUR,162"="Droid Sans Fallback,162"
"Tms Rmn"="Droid Sans Fallback"
/* 替換字型2 */
[HKEY_CURRENT_USER\Software\Wine\Fonts\Replacements]
@="Droid Sans Fallback"
"Arial"="Droid Sans Fallback"
"Fixedsys"="Droid Sans Fallback"
"Microsoft Sans Serif"="Droid Sans Fallback"
"MingLiU"="Droid Sans Fallback"
"MS UI Gothic"="Droid Sans Fallback"
"PMingLiU"="Droid Sans Fallback"
"Simsun"="Droid Sans Fallback"
"Songti"="Droid Sans Fallback"
"System"="Droid Sans Fallback"
"Tahoma"="Droid Sans Fallback"
"Terminal"="Droid Sans Fallback"
/* 取代字型 */
/* Wine 1.1.12 打補丁後也會有亂碼,所以要修改這裡 */
/* Wine 1.1.12 之前可以不用修改,改了應該也沒關係 */
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink]
"Microsoft Sans Serif"="DroidSansFallback.ttf,Droid Sans Fallback"
"SimSun"="DroidSansFallback.ttf,Droid Sans Fallback"
"Tahoma"="DroidSansFallback.ttf,Droid Sans Fallback"
"PMingLiU"="DroidSansFallback.ttf,Droid Sans Fallback"
"Lucida Sans Unicode"="DroidSansFallback.ttf,Droid Sans Fallback"
[HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics]

"BorderWidth"="1"

"CaptionFont"=hex:f0,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,00,00,00,00,88,00,00,00,22,44,00,72,00,6f,00,69,00,64,00,20,00,53,00,61,00,6e,00,73,00,20,00,46,00,61,00,6c,00,6c,00,62,00,61,00,63,00,6b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

"CaptionHeight"="18"

"CaptionWidth"="18"

"MenuFont"=hex:f0,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,00,00,00,00,88,00,00,00,22,44,00,72,00,6f,00,69,00,64,00,20,00,53,00,61,00,6e,00,73,00,20,00,46,00,61,00,6c,00,6c,00,62,00,61,00,63,00,6b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

"MenuHeight"="18"

"MenuWidth"="18"

"MessageFont"=hex:f0,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,00,00,00,00,88,00,00,00,22,44,00,72,00,6f,00,69,00,64,00,20,00,53,00,61,00,6e,00,73,00,20,00,46,00,61,00,6c,00,6c,00,62,00,61,00,63,00,6b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

"ScrollHeight"="16"

"ScrollWidth"="16"

"Shell Icon Size"="32"

"SmCaptionFont"=hex:f4,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,90,01,00,00,00,00,00,88,00,00,00,00,4d,00,53,00,20,00,53,00,68,00,65,00,6c,00,6c,00,20,00,44,00,6c,00,67,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00

"SmCaptionHeight"="18"

"SmCaptionWidth"="13"

"StatusFont"=hex:f0,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,00,00,00,00,88,00,00,00,22,44,00,72,00,6f,00,69,00,64,00,20,00,53,00,61,00,6e,00,73,00,20,00,46,00,61,00,6c,00,6c,00,62,00,61,00,63,00,6b,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00



  • 匯入登錄檔

regedit

開啟註冊表編輯器註冊表導入註冊表檔案選則font.reg開啟關閉註冊表編輯器



  • 修改預設字型、字體大小

gedit ~/.wine/drive_c/windows/win.ini

把以下內容插入檔案底部存檔


[Desktop]
IconTitleFaceName=Droid Sans Fallback
menufontsize=13
messagefontsize=13
statusfontsize=13
IconTitleSize=13


備註
如想瞭解什麼叫平滑化可參考平滑化(anti-alias)

上圖為有開,下圖為沒開,取決於你所使用的字型,請自行測試看那種較為美觀。



2009.1.28更新

在Nelson寫的教學瞄到還要在改一個地方﹙不改也沒關係﹚,可以調整文字大小。

進入Wine設定畫面
winecfg
選擇桌面整合,分別調整Message Box Text、功能表文字、提示區文字、當前標題欄文字這四個字型與字體大小。



一樣我有調好的登錄檔可以直接使用,我設定這四個為Droid Sans Fallback大小為12,如覺不適合請自行調整囉。



參考資料:
Wine / Crossover Office / Picasa Linux 繁體中文設置 UPDATED!!
wine中文字體設置及字體美化
cxoffice 中文調整