Ubuntu-安装字体

作者:聂勇 欢迎转载,请保留作者信息并说明文章来源!

Ubuntu10.10下的中文字体有点少,将Windows的字库中一些常用的字体安装到Ubuntu中来,方便文档处理。安装和设置过程如下:

运行环境 | Enviroment

  • Ubuntu 10.10 (经测试,Redhat 5.x 和 CentOS 5.x也可以用同样的方法安装字体

安装和设置字体 | How to install and setup fonts

1、打开openoffice,可以看到如下的字体列表:
字体列表

2、打开字体配置文件(需要root权限):/etc/fonts/fonts.conf,找到如下的配置内容:

1
2
3
4
5
<!-- Font directory list -->
<dir>/usr/share/fonts</dir>
<dir>/usr/X11R6/lib/X11/fonts</dir>
<dir>/usr/local/share/fonts</dir>
<dir>~/.fonts</dir>

增加自己的字体目录,修改后的结果如下:

1
2
3
4
5
6
<!-- Font directory list -->
<dir>/usr/share/fonts</dir>
<dir>/usr/X11R6/lib/X11/fonts</dir>
<dir>/usr/local/share/fonts</dir>
<dir>~/.fonts</dir>
<dir>/devdata/fonts</dir>

3、依次执行如下命令:

1
2
3
sudo mkfontscale
sudo mkfontdir
sudo fc-cache -fv

/usr/share/fonts: caching, new cache contents: 0 fonts, 3 dirs
/usr/share/fonts/X11: caching, new cache contents: 0 fonts, 6 dirs
/usr/share/fonts/X11/100dpi: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/X11/75dpi: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/X11/Type1: caching, new cache contents: 9 fonts, 0 dirs
/usr/share/fonts/X11/encodings: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/X11/encodings/large: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/X11/misc: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/X11/util: caching, new cache contents: 0 fonts, 0 dirs
/usr/share/fonts/truetype: caching, new cache contents: 1 fonts, 14 dirs
/usr/share/fonts/truetype/freefont: caching, new cache contents: 12 fonts, 0 dirs
/usr/share/fonts/truetype/openoffice: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/takao: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/thai: caching, new cache contents: 54 fonts, 0 dirs
/usr/share/fonts/truetype/ttf-dejavu: caching, new cache contents: 6 fonts, 0 dirs
/usr/share/fonts/truetype/ttf-indic-fonts-core: caching, new cache contents: 17 fonts, 0 dirs
/usr/share/fonts/truetype/ttf-kacst-one: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/ttf-khmeros-core: caching, new cache contents: 2 fonts, 0 dirs
/usr/share/fonts/truetype/ttf-lao: caching, new cache contents: 1 fonts, 0 dirs
/usr/share/fonts/truetype/ttf-liberation: caching, new cache contents: 12 fonts, 0 dirs
/usr/share/fonts/truetype/ttf-punjabi-fonts: caching, new cache contents: 2 fonts, 0 dirs
/usr/share/fonts/truetype/ubuntu-font-family: caching, new cache contents: 4 fonts, 0 dirs
/usr/share/fonts/truetype/unfonts: caching, new cache contents: 4 fonts, 0 dirs
/usr/share/fonts/truetype/wqy: caching, new cache contents: 2 fonts, 0 dirs
/usr/share/fonts/type1: caching, new cache contents: 0 fonts, 2 dirs
/usr/share/fonts/type1/gsfonts: caching, new cache contents: 35 fonts, 0 dirs
/usr/share/fonts/type1/mathml: caching, new cache contents: 1 fonts, 0 dirs
/usr/X11R6/lib/X11/fonts: skipping, no such directory
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/home/aofeng/.fonts: skipping, no such directory
/devdata/fonts: caching, new cache contents: 19 fonts, 0 dirs
/var/cache/fontconfig: cleaning cache directory
/home/aofeng/.fontconfig: cleaning cache directory
fc-cache: succeeded

如上加粗字体所示:当前的自定义字体目录共发现了19个字体文件。末尾出现 fc-cache: succeeded 表示加载字体成功。

4、重新打开openoffice,可以看到新的字体列表如下:
字体列表