penn

链接

Backup and recover your boot sector

Gentoo中文UTF-8设置及美化

penn posted @ 2008年11月05日 19:34 in Linux with tags gentoo linux fvwm 中文 , 9388 阅读

原帖在这里,为简化期间,只贴出简略的步骤和配置文件。

一、安装基本系统
依照Gentoo的安装手册进行安装,安装手册的地址点击这里。我选择的是AMD64。这里要非常感谢gentoo中文文档组的成员。由于我的硬盘没有光驱,所以在安装的时候需要从老的linux系统启动,然后使用chroot命令切换到新的系统下。下面使我的硬盘使用情况:
/dev/hda --- 原来老的linux系统(因为硬盘摔了一下,经常丢东西,所以要重装系统)。
/dev/hdc --- 目前要安装的linux所在硬盘。
/dev/sda --- 我的SATA硬盘,安装的是MS XP系统。

这是我的/etc/make.conf和/etc/locale.gen文件

代码:

# These settings were set by the catalyst build script that automatically built this stage
# Please consult /etc/make.conf.example for a more detailed example
CFLAGS="-march=athlon64 -O3 -pipe -ftracer -funit-at-a-time -fforce-addr -fpeel-loops -funswitch-loops"
CHOST="x86_64-pc-linux-gnu"
LDFLAGS="-Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common -Wl,--strip-all"
CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden"
CBUILD="x86_64-pc-linux-gnu"
MAKEOPTS="-j2"
ACCEPT_KEYWORDS="amd64"
GENTOO_MIRRORS="http://61.135.158.199 ftp://ftp.sjtu.edu.cn/sites/gentoo ftp://gg3.net/pub/linux/gentoo"
SYNC="rsync://61.135.158.199/gentoo-portage"

#
# USE
USE="-midi -ipv6 -doc svga linguas_zh_CN fbcon 3dnow aac font-server bash-completion amd64 X lcms mmx sse gtk gtk2 -gnome nls -qt -kde alsa -cups cjk -dvd -dvdr -debug aalib jpeg wmf mng svg png mpeg truetype opengl stroke -xinerama -joysticks readline lm_sensors quicktime xv xvid bzip2 acc ftp python xml libcaca xvmc nvidia unicode -no-old-linux tiff symlink encode gif sdl imlib chardet mp3 wma real srt msn qq preview-latex fontconfig xpm a52 -emacs -xemacs -latex ggi gd pdf plotutils -berkdb"

#
# Other
AUTOCLEAN=yes
LINGUAS="zh_CN"
LANG="zh_CN"
#DISDIR=
#FEATURES="ccache confcache"
CCACHE_SIZE="2G"
CCACHE_DIR="/var/tmp/cache"
VIDEO_CARDS="nvidia"
ALSA_CARDS="intel8x0"   
#PORTDIR_OVERLAY=/usr/local/portage
source /usr/portage/local/layman/make.conf
INPUT_DEVICES="mouse keyboard"
#/etc/locale.gen
en_US ISO-8859-1
en_US.UTF-8 UTF-8
zh_CN GB2312
zh_CN.GBK GBK
zh_CN.GB18030 GB18030
zh_CN.UTF-8 UTF-8
zh_HK BIG5-HKSCS
zh_HK.UTF-8 UTF-8
zh_TW BIG5
zh_TW.UTF-8 UTF-8

调整/boot/grub/grub.conf文件

代码:
default 0
timeout 30
#splashimage=(hd0,0)/boot/grub/self1.xpm.gz
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
# /dev/hda的老linux系统
title Gentoo Linux (HDA)
root    (hd0,0)
kernel  /kernel-2.6.16-gentoo-r7 root=/dev/hda6 video=vesafb:1024x768@75,mtrr,ywrap vga=0x318 splash=silent,fadein,theme:sexy CONSOLE=/dev/tty1
initrd /fbsplash-penn

# 新安装的Gentoo系统。
title Gentoo Linux (HDC)
root    (hd1,0)
kernel  /kernel-2.6.23-gentoo-r3 root=/dev/hdc6 video=vesafb:1024x768@75,mtrr,ywrap vga=0x318

#这里为XP的启动提供通道
title Window XP
map (hd0) (hd2)
map (hd2) (hd0)
rootnoverify (hd2,0)
makeactive
chainloader +1
安装完基本系统,安装X和fvwm. 这里就简单的emerge就行了。此处不在多说。
二、安装字体和字体设置。
1. 增加字体
使用emerge安装的字体:
代码:
emerge  media-fonts/corefonts wqy-bitmapfont media-fonts/wqy-zenhei media-fonts/ttf-bitstream-vera
现在开始盗版了,我是把window的字体拷贝到
/usr/share/font/local目录下.
我拷贝的字体有:SimSun-Bold.ttf,SimSun-BoldItalic.ttf,SimSun-Italic.ttf,mingliu.ttc,msyh.ttf,msyhbd.ttf,tahoma.ttf,tahomabd.ttf等。
2. 设置x核心字体
代码:
# cd /usr/share/fonts/local
# ttmkfdir
# cp fonts.scale fonts.dir
如果没有ttmkfdir工具的朋友需要
代码:
# emerge x11-apps/ttmkfdir
在/etc/X11/xorg.conf里面添加字体路径:
代码:
    FontPath    "/usr/share/fonts/corefonts/"
    FontPath    "/usr/share/fonts/local/"
    FontPath    "/usr/share/fonts/ttf-bitstream-vera/"
    FontPath    "/usr/share/fonts/wqy-bitmapfont"
    FontPath    "/usr/share/fonts/wqy-zenhei/"
3. 设置XFT字体
应为/usr/share/fonts是xft自动搜索目录,所以不需要另外设置,只需要修改好fontconfig文件即可。下面是草兄的配置,放到/etc/fonts/local.conf,不建议直接编辑/etc/font.conf文件
代码:
<?xml version="1.0"?>
<fontconfig>
        <alias>
                <family>serif</family>
                <prefer>
                        <family>Bitstream Vera Serif</family>
                        <family>Microsoft Yahei</family>
                        <family>DejaVu Serif</family>
                        <family>AR PL ShanHeiSun Uni</family>
                        <family>WenQuanYi Bitmap Song</family>
                        <family>AR PL ZenKai Uni</family>
                </prefer>
        </alias>
        <alias>
                <family>sans-serif</family>
                <prefer>
                        <family>Bitstream Vera Sans</family>
                        <family>Microsoft Yahei</family>
                        <family>DejaVu Sans</family>
                        <family>AR PL ShanHeiSun Uni</family>
                        <family>WenQuanYi Bitmap Song</family>
                        <family>AR PL ZenKai Uni</family>
                </prefer>
        </alias>
        <alias>
                <family>monospace</family>
                <prefer>
                        <family>Bitstream Vera Sans Mono</family>
                        <family>Microsoft Yahei</family>
                        <family>DejaVu Sans Mono</family>
                        <family>AR PL ShanHeiSun Uni</family>
                        <family>WenQuanYi Bitmap Song</family>
                        <family>AR PL ZenKai Uni</family>
                </prefer>
        </alias>
        <match target="font" >
                <edit name="rgba" mode="assign">
                        <const>none</const>
                </edit>
                <edit mode="assign" name="antialias" >
                        <bool>true</bool>
                </edit>
                <edit mode="assign" name="autohint" >
                        <bool>false</bool>
                </edit>
                <edit name="hinting">
                        <bool>true</bool>
                </edit>
                <edit name="hintstyle" mode="assign" >
                        <const>hintmedium</const>
                </edit>
        </match>
        <match target="font" >
                <test name="family" compare="contains" >
                        <string>Song</string>
                        <string>Sun</string>
                        <string>Kai</string>
                        <string>Ming</string>
                </test>
                <test name="weight" compare="less_eq">
                        <int>100</int>
                </test>
                <test compare="more_eq" target="pattern" name="weight" >
                        <int>180</int>
                </test>
                <edit mode="assign" name="embolden" >
                        <bool>true</bool>
                </edit>
        </match>
        <match target="font" >
                <test name="family" compare="contains" >
                        <string>Song</string>
                        <string>Sun</string>
                        <string>Kai</string>
                        <string>Ming</string>
                </test>
                <edit name="globaladvance">
                        <bool>false</bool>
                </edit>
                <edit name="spacing">
                        <int>0</int>
                </edit>
                <edit name="hinting">
                        <bool>true</bool>
                </edit>
                <edit name="autohint">
                        <bool>false</bool>
                </edit>
                <edit name="antialias" mode="assign">
                        <bool>true</bool>
                </edit>
                <test name="pixelsize" compare="less_eq">
                        <int>18</int>
                </test>
                <edit name="antialias" mode="assign" >
                        <bool>false</bool>
                </edit>
        </match>
        <match target="font" >
                <test name="family" compare="contains" >
                        <string>Microsoft Yahei</string>
                </test>
                <edit name="globaladvance">
                        <bool>false</bool>
                </edit>
                <edit name="spacing">
                        <int>0</int>
                </edit>
        </match>
</fontconfig>
如此,xft服务器就能找到合适的字体匹配。
4. 用户字体设置及编码
设置字体,我使用gtk,所以只设置了gtkrc文件,.gtkrc-2.0文件
代码:
style "user-font"
{
font_name = "Verdana, Microsoft YaHei 12"
}
widget_class "*" style "user-font"
gtk-theme-name="MacOS-X"
gtk-icon-theme-name="MacOS-X"
我使用startx系统进入X。所以要编辑.xinitrc文件,这是字体编码、还有输入法等。我的配置文件如下:
代码:
#!/bin/bash
#
# Setup locale
export GDK_USE_XFT=1
export C=zh_CN.utf8
export LC_CTYPE=zh_CN.utf8
#export LC_ALL=zh_CN.utf8

# Setup scim IM
LANG=zh_CN.utf8 scim -d
export XMODIFIERS="@im"="SCIM"
export GTK_IM_MODULE="scim"
export QT_IM_MODULE="scim"
exec fvwm 2>.fvwm.log

如果使用xdm登录,需要修改.Xclients

代码:

#!/bin/bash
#
# Setup locale
export GDK_USE_XFT=1

#
export LC_CTYPE=zh_CN.utf8

# if you want to zh_CN, open the 2 optionals
#export LC_ALL=zh_CN
#LC_ALL includes all of following 6 options
#export LC_TIME=zh_CN
#export LC_NUMERIC=zh_CN
export LC_NOMETAEY=zh_CN.utf8
export LC_MESSAGES=zh_CN.utf8
export LC_COLLATE=zh_CN.utf8
export C=zh_CN.utf8
#
# Setup fcitx IM
#export XMODIFIERS="@im=fcitx"
#export XIM=fcitx
#export XIM_PROGRAM=fcitx
#exec fcitx &
#
# Setup scim IM
LANG=zh_CN.utf8 scim -d
export XMODIFIERS="@im"="SCIM"
export GTK_IM_MODULE="scim"
export QT_IM_MODULE="scim"
#exec conky &
exec fvwm 2>.fvwm.log
#exec starte16

进入fvwm后,发现原来gb2312文件中中文都是乱码,所以需要进行编码转换,编码转换使用iconv程序,没有这个程序的需要emerge

代码:
emerge dev-haskell/iconv
对于需要文件名进行转换的文件需要使用:
代码:
emerge app-text/convmv
这是一个perl程序,可以转换从任意字符名字转换为utf-8。
由于iconv默认输入到终端,所以要需要文件重定向。-f (from) -t (to)
代码:
iconv -f gb2312 -t utf-8 gb2312-file > utf8file
格式转换后,需要修改fvwm字体,如果要 雅黑 字体则需要这样设置:
代码:
"xft:Microsoft YaHei:encoding=iso10646-1"

设置好后就可以显示中文了。
完毕。

效果图:



Avatar_small
mic 说:
2015年4月25日 10:48

hi, 请问这是什么桌面?


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter