手動美化 Linux 中文環境
时间:2004-11-24
来源:互联网
http://gary1984.blogspot.com/2004/11/linux.html
應該還會繼續 update ,如果我有時間的話。 ^^"
大陸的 ISP 擋掉了 google 的 blog ,只好出此下策了! (格式跑掉了)
(希望大陸的 ISP 能解除封鎖, blog 應該不用鎖吧)
Author: Gary Chang
Update: 11/24/2004
0.
http://gary1984.blogspot.com/2004/11/linux.html
歡迎 "原文" 轉載,建議使用 Firefox 閱讀
1. Preface
網路上大部份的中文美化教學不是殘缺不全,就是教大家裝上打過 firefly patch 的
package 。可是當新的版本發行時,美化的 package ?K不會馬上出現,還要等個幾天,甚
至幾個星期。就算裝上美化的 package ,又可能會有 dependence 的問題,導致要安裝或
移除許多套件。基於這幾個理由,小弟經過許多嘗試,成功地在 Mandrakelinux 10.0
Official 下使用 fontconfig, freetype 等 source tarball 再利用 firefly 的 patch
完成 Linux 的中文美化。也就是說,以後不必等別人製作出 package ,就可以自己動手
完成中文美化,而且沒有 dependence 的問題。
在假設大家都對 Linux 操作有一定的認知之下,許多地方都很快帶過,給大家的大都是概
念;如有不懂的地方,請多 google 或 man 。所以,我想這個手動中文美化的方法在各
version 及 distro 應該都適用。
2. Preparation
2.1 下載 source
2.1.1 到 http://www.freetype.org/ 下載 freetype-2.1.7.tar.bz2 。
2.1.2 到 http://freedesktop.org/wiki/Software_2fFontconfigDevel 下載
fontconfig 2.2.96 。
P.S.
小弟是用 http://rpmfind.net/ 搜尋 fontconfig ?K下載 cooker 最新的 srpm 。
(fontconfig-2.2.96-8mdk.src.rpm)
2.1.3 到 freebsd 的 posts 下載
ftp://ftp.freebsd.org/pub/FreeBSD/po...t-2.1.6.tar.gz
2.1.4 下載 ftp://mdk.linux.org.tw/pub/3rd-*****.../shiva/xttmgr/ \
xttmgr-0.9.7.pre3-1mdk.shiva.src.rpm
2.2 下載 patch
到 http://firefly.idv.tw/setfont-xft/patches/ ,
在 fontconfig/2.2.3/ 下抓 fontconfig-2.2.3-*.patch ,
在 freetype/ 下抓 freetype-2.1.*.patch ,
在 libXft/ 下抓 libXft-2.1.2-*.patch 。
P.S.
freetype 的 cjk patch 已不再維護,但熱心的網友可能會根據舊的 patch 為 least
release 做出 patch ,所以可以試著找找看。
2.3 所以現在抓到的檔案有
fontconfig-2.2.3-add_extra_option-20041114.patch
fontconfig-2.2.3-alllang-20041114.patch
fontconfig-2.2.3-default_config-20041114.patch
fontconfig-2.2.3-fakestyle-20041117.patch
fontconfig-2.2.3-include_CJK_charmaps-20041114.patch
fontconfig-2.2.3-multifamily-20041117.patch
fontconfig-2.2.96-8mdk.src.rpm
freetype-2.1.6-enable_bytecode.patch
freetype-2.1.7-autohint-cjkfonts-20031121.patch
freetype-2.1.7.tar.bz2
libXft-2.1.2-add_ft2build_header.patch
libXft-2.1.2-CJK-extra-20031217.patch
libXft-2.1.6.tar.gz
xttmgr-0.9.7.pre3-1mdk.shiva.src.rpm
3. Patch
3.1 在 /usr/src/ 解壓縮 freetype-2.1.7.tar.bz2 ,?K打上補丁 。
(freetype-2.1.*.patch)
3.2 在 /usr/src/ 解壓縮 fontconfig 的 source ,?K打上補丁。
(fontconfig-2.2.3-*.patch)
P.S.
我抓的 source 是? srpm 而?恚詧绦
rpmcpio fontconfig-2.2.96-8mdk.src.rpm | cpio -id
?淼玫 source 。在 srpm 裡的 patch 要不要 apply , it's up to you !
3.3 在 /usr/src/ 解壓縮 libXft-2.1.6.tar.gz ,?K打上補丁。
(libXft-2.1.2-CJK-extra-20031217.patch)
P.S.
如果 libXft 是 2.1.2 ,就需要再打上補丁
(libXft-2.1.2-add_ft2build_header.patch)
3.4 執行
rpm2cpio xttmgr-0.9.7.pre3-1mdk.shiva.src.rpm | cpio -id
得到 xttmgr-0.9.7.pre3.tar.gz ,接著在 /usr/src/ 解壓縮,?K apply 下面這個
patch 。
diff -ur xttmgr-0.9.7.pre2.old/Makefile xttmgr-0.9.7.pre2/Makefile --- xttmgr-0.9.7.pre2.old/Makefile 2004-07-22 23:02:05.000000000 +0800 +++ xttmgr-0.9.7.pre2/Makefile 2004-07-29 11:48:24.978094576 +0800 @@ -4,13 +4,14 @@ prefix=/usr CC=gcc -CFLAGS=$(RPM_OPT_FLAGS) -Wall -pedantic -I$(FREETYPE_INCL) +CFLAGS=-s -O2 -Os $(RPM_OPT_FLAGS) -Wall -pedantic -I$(FREETYPE_INCL) LDFALGS=-L$(FREETYPE_LIB) -lfreetype -lz all: xttmgr xttmgr: xttmgr.o $(CC) -o $@ $< $(LDFALGS) + -strip xttmgr xttmgr.o: xttmgr.c diff -ur xttmgr-0.9.7.pre2.old/xttmgr.c xttmgr-0.9.7.pre2/xttmgr.c --- xttmgr-0.9.7.pre2.old/xttmgr.c 2004-07-23 00:07:04.000000000 +0800 +++ xttmgr-0.9.7.pre2/xttmgr.c 2004-07-29 11:49:27.920525872 +0800 @@ -4,6 +4,8 @@ * 修改 : Shiva Huang ( [email protected] ) *******************************************************************/ +#define VERSION "0.9.7-pre3" + #include <ft2build.h> #include FT_FREETYPE_H #include FT_MODULE_H @@ -60,20 +62,20 @@ static int have_module = 0; /* 系統預設的 encoding 表格指引檔位置 */ -static char *encodings_path= "/usr/X11R6/lib/X11/fonts/encodings/encodings.dir"; +static char *encodings_path= "/etc/X11/encodings.dir"; /* XFree86 的設定檔 */ static char *conf3_path = "/etc/X11/XF86Config"; static char *conf_path = "/etc/X11/XF86Config-4"; /* xfs 的字型設定檔 */ static char *fsconfig = "/etc/X11/fs/config"; /* 所管理的字型存放位置 */ -static char *font_path = "/usr/X11R6/lib/X11/fonts/TrueType/"; +static char *font_path = "/usr/share/fonts/myfonts/"; /* 真?字型檔放置位置 */ -static char *base_path = "/usr/share/fonts/ttf/xttmgr/"; +static char *base_path = "/usr/share/fonts/myfonts/"; /* fonts.dir 所在位置 */ -static char *font_dir = "/usr/X11R6/lib/X11/fonts/TrueType/fonts.dir"; +static char *font_dir = "/usr/share/fonts/myfonts/fonts.dir"; /* fonts.scale 所在位置 */ -static char *font_scale = "/usr/X11R6/lib/X11/fonts/TrueType/fonts.scale"; +static char *font_scale = "/usr/share/fonts/myfonts/fonts.scale"; /* 暫存檔檔名 */ static char *temp_file = "/tmp/_xttmgr.tmp"; @@ -152,6 +154,7 @@ if ( ProgName[0] == '/' ) ProgName ++; /* 檢查使用者是否為 root ? */ +/* if ( uid != 0 ) { fprintf( stderr, "%s: This program is used only for 'root'\n", ProgName ); exit (1); @@ -166,6 +169,7 @@ fprintf( stderr, "%s: Can not create \"%s\".\n", ProgName, base_path ); exit(1); } +*/ /* 初始 Freetype library */ if ( FT_Init_FreeType( &library ) ) { @@ -303,7 +307,7 @@ static void Usage( void ) { - printf( "\nX-TrueType Font Manager 0.9.7-pre3\n" ); + printf( "\nX-TrueType Font Manager "VERSION"\n" ); printf( "\nUsage: %s [option]\n", ProgName ); printf( "option:\n" ); printf( " --add <filename.[ttf|ttc]> Add new TrueType font\n" ); @@ -1224,10 +1228,10 @@ char fn[64]; int wcnt, scnt; int num_lines; - FILE *fontdirfp, *fontscalefp; + FILE *fontdirfp; FILE *tmpfp; char buffer[512]; - char f_dir[256], f_scale[256]; + char f_dir[256]; int i; char bw[10]; @@ -1238,7 +1242,6 @@ } strcpy( f_dir, path ); strcat( f_dir, "fonts.dir" ); - strcpy( f_scale, path ); strcat( f_scale, "fonts.scale" ); if ( File_Exist( f_dir ) ) { fontdirfp = fopen( f_dir, "r+" ); @@ -1296,16 +1299,17 @@ /* 將原?淼 fonts.dir 內容清空 */ fontdirfp = fopen( f_dir, "w" ); - fontscalefp = fopen( f_scale, "w" ); fprintf( fontdirfp, "%d\n", num_lines ); - fprintf( fontscalefp, "%d\n", num_lines ); while ( fgets( buffer, 512, tmpfp ) ) { fputs( buffer, fontdirfp ); - fputs( buffer, fontscalefp ); } - fclose( tmpfp ); fclose( fontdirfp ); fclose( fontscalefp ); + fclose( tmpfp ); fclose( fontdirfp ); + + if(! File_Exist(font_scale)) + symlink( "fonts.dir", font_scale ); + remove( temp_file ); /* 移除暫存檔案 */ return 0; } @@ -1318,7 +1322,6 @@ static int Remove_Font( char *filename ) { FILE *fontdirfp; - FILE *fontscalefp; FILE *tmpfp; char *base_name; char *link_name; @@ -1361,23 +1364,22 @@ /* */ rewind( tmpfp ); fontdirfp = fopen( font_dir, "w" ); - fontscalefp = fopen( font_scale, "w" ); - if ( fontdirfp && fontscalefp) { + if ( fontdirfp ) { fprintf( fontdirfp, "%d\n", num_lines ); - fprintf( fontscalefp, "%d\n", num_lines ); while ( fgets( buffer, 512, tmpfp ) ) { fputs( buffer, fontdirfp ); - fputs( buffer, fontscalefp ); } fclose( fontdirfp ); - fclose( fontscalefp ); } fclose( tmpfp ); remove( temp_file ); /* 移除暫存檔案 */ remove( link_name ); /* 移除連結*/ + if(! File_Exist(font_scale)) + symlink( "fonts.dir", font_scale ); + printf( "\"%s\" has removed OK.\n", base_name ); free( base_name ); free( link_name );
小弟對 0.9.7-pre3 做了一點修改 (path, symlink) ,之後的設定也是用這個修改後的路
?健K裕孕袇⒖伎纯窗桑
4. Compilation
*務必依照 4.1 - 4.4 的順序編譯
*建議在編譯前先備份 /etc/fonts/
4.1 在 /usr/src/freetype-2.1.7/ 執行
./configure --prefix=/usr
make
make install
4.2 在 /usr/src/fontconfig-2.2.96/ 執行
./configure --with-confdir=/etc/fonts \
--with-add-fonts=/usr/X11R6/lib/X11/fonts --prefix=/usr
make
make install
4.3 在 /usr/src/libXft-2.1.6/ 執行
./configure --prefix=/usr/X11R6
make
make install
P.S.
這些 prefix, dir 都是利用這個方法查出?淼
ex. urpmq -lry fontconf
所以這樣安裝會把原?淼臋n案 overwrite ;如果不知道要加那些參數,可以去 cooker 抓
srpm ,看一下 spec 就知道了。
4.4 在 /usr/src/xttmgr-0.9.6/ 執行
make
make install
5. Setup
5.1 新增字型
5.1.1 使用 xttmgr 新增字型
ex. xttmgr --addlink /mnt/win_c/windows/fonts/mingliu.ttc
simsun 字型也可以如法*製。
5.1.2 使用 fc-cache 新增字型
將字型 copy 或 symlink 到 /usr/share/fonts/myfonts/ ,最後執行 fc-cache ,完成
字型安裝。
P.S.
gtk1 的字型是用 xttmgr 管理, gtk2 的字型則是用 fontconfig 管理,所以兩者是分開
的。
5.2 編輯 /etc/X11/XF86Config-4 或 /etc/X11/Xorg.conf
5.2.1 在 Section "Files" 的下一行加入
fontpath "/usr/share/fonts/myfonts"
5.2.2 在 Section "Module" 中修改
# Load "type1"
# Load "freetype"
load "xtt"
5.3 在 /etc/gtk/gtkrc.zh_TW.big5 的 fontset 中加入下面這一行
-DynaLab-PMingLiU-medium-r-normal--0-0-0-0-c-0-big5-0,\
CN 的朋友可能要在 /etc/gtk/gtkrc.zh_CN 的 fontset 中加入下面這一行
-misc-SimSun-medium-r-normal--0-0-0-0-c-0-gb2312.1980-0,\
P.S.
使用 UTF8 的人可能需要改 gtkrc.zh_TW.utf8 或 gtkrc.zh_CN.utf8
5.4 編輯 /etc/fonts/local.conf ,加入
<dir>/usr/share/fonts/myfonts</dir> <alias> <family>sans-serif</family> <prefer> <family>Bitstream Vera Sans</family> <family>PMingLiU</family> <family>SimSun</family> </prefer> </alias> <alias> <family>serif</family> <prefer> <family>Bitstream Vera Sans</family> <family>PMingLiU</family> <family>SimSun</family> </prefer> </alias> <alias> <family>monospace</family> <prefer> <family>Bitstream Vera Sans Mono</family> <family>MingLiU</family> <family>NSimSun</family> </prefer> </alias> <match target="pattern"> <test name="family"> <string>MingLiU</string> </test> <edit name="family"> <string>PMingLiU</string> </edit> </match> <match target="pattern"> <test name="family"> <string>NSimSun</string> </test> <edit name="family"> <string>SimSun</string> </edit> </match> <!-- <match target="font"> <test name="family"> <string>PMingLiU</string> </test> <test name="size" compare="less_eq"> <int>12</int> </test> <edit name="antialias"> <bool>f</bool> </edit> </match> <match target="font"> <test name="family"> <string>SimSun</string> </test> <test name="size" compare="less_eq"> <int>12</int> </test> <edit name="antialias"> <bool>f</bool> </edit> </match> -->
查閱相關說明,請 man fonts-conf 。小弟用 PMingLiU 覆蓋 MingLiU ,是為了解決中英
文字等寬的問題。我猜 SimSun 可能也有這個問題,所以也這樣設定。後面那段 comment
掉的,可以參考看看。
6. Chinese related
6.1 mrxvt 設定
6.1.1
mrxvt -ls -sr -fg gray -bg black -bc -xft -xftfm "PMingLiU" \
-xftfn "Bitstream Vera Sans Mono" -xftsz 10 -xftaa -xftht -xftah
mrxvt -ls -sr -fg gray -bg black -bc -xft -xftfm "SimSun" \
-xftfn "Bitstream Vera Sans Mono" -xftsz 10 -xftaa -xftht -xftah
6.1.2 (這部份, rxvt 也適用)
mrxvt -ls -sr -fg gray -bg black -bc \
-fm "-et-fixed-medium-r-normal--16-160-72-72-c-160-big5.et-0"
mrxvt -ls -sr -fg gray -bg black -bc -fm "kc15j"
P.S.
big5 和 unicode 相較, big5 的集合比 unicode 大,所以有時候我會用 -et-fixed 而
不是用 pmingliu 。
6.2 vi `which crxvt`
# LANG=zh_TW.Big5
# LANGUAGE="zh_TW.Big5:zh_TW:zh"
# LANG=zh_CN.GB2312
# LANGUAGE=zh_CN.GB2312:zh_CN:zh
6.3 /etc/sysconfig/i18n (英文環境,但可以顯示、輸入中文)
LANG=en_US
LANGUAGE=en_US
LC_CTYPE=zh_TW
XIM_PROGRAM=gcin
XMODIFIERS=@im=xcin
6.4 /opt/OpenOffice.org1.1.3/share/fonts/truetype/
可以把字型 copy 到這裡,單獨給 OO.o 用。
7. Final
如果不是很在意粗體斜體的人,那就只需要裝上 freetype
(打上 freetype-2.1.6-enable_bytecode.patch) ,再把 simsun 和 pmingliu 的
antialias 關掉就可以了。這個 patch 只是打開 include/freetype/config/ftoption.h
的 BYTECODE 。
當然,不一定要用 pmingliu 或 simsun 作為主要顯示字體,也可以用其他字體。但我覺
得還是 mingliu 和 simsun 最好看。
最後,感謝各位看完小弟詞不達意的文章,希望 cjk 的問題能早日解決,?K整合到各
distro 中。
8. Resource
Xft
http://freedesktop.org/wiki/Software_2fXft
Fontconfig
http://freedesktop.org/wiki/Software_2ffontconfig
firefly 論壇
http://firefly.idv.tw/test/Forum.php?Board=1
http://fractal.csie.org/~eric/fontconfig/
free fonts
ftp://cle.linux.org.tw/pub/fonts/
作者: garychang 发布时间: 2004-11-24
作者: L0veyou 发布时间: 2004-11-24
作者: garychang 发布时间: 2004-11-24
作者: zhaozhh02 发布时间: 2004-11-24
http://gary1984.blogspot.com/ 進不去嗎?
這是 google 的免費 blog ,怎麼會打不開?
有沒有人打的開?有沒有人能解釋一下?
(不是小弟不願意貼過?恚皇怯锌赡軙 update ,及有 patch ,所以給連結比較好)
作者: garychang 发布时间: 2004-11-24
作者: leros_H 发布时间: 2004-11-24
作者: fundawang 发布时间: 2004-11-24
作者: garychang 发布时间: 2004-11-25
作者: garychang 发布时间: 2004-11-27
作者: sangompmax 发布时间: 2004-11-27
得到 xttmgr-0.9.7.pre3.tar.gz ,接著在 /usr/src/ 解壓縮,?K apply 下面這個patch 。
得到 xttmgr-0.9.7.pre3.tar.gz之后怎么做?看不明白。。
作者: sangompmax 发布时间: 2004-11-27
最初由 sangompmax 发表 如何做patch啊?给个操作命令方法看一下。谢谢了 |
cd /usr/src/freetype-2.1.7/
patch -p1 < freetype-2.1.7-autohint-cjkfonts-20031121.patch
notice the output message.
如果沒有出現 FAIL 的話,應該就表示 patch 成功
最初由 sangompmax 发表 rpm2cpio xttmgr-0.9.7.pre3-1mdk.shiva.src.rpm | cpio -id 得到 xttmgr-0.9.7.pre3.tar.gz ,接著在 /usr/src/ 解壓縮,?K apply 下面這個patch 。 得到 xttmgr-0.9.7.pre3.tar.gz之后怎么做?看不明白。。 |
給你看看指令
cd /usr/src/
wget ftp://mdk.linux.org.tw/pub/3rd-*****....shiva.src.rpm
rpm2cpio xttmgr-0.9.7.pre3-1mdk.shiva.src.rpm | cpio -id
tar zxf xttmgr-0.9.7.pre3.tar.gz
cd xttmgr-0.9.7.pre3/
patch -p1 < ~/xttmgr-0.9.7.pre3.patch
這樣而已
作者: garychang 发布时间: 2004-11-27
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28