FreeBSD安装各种字体


X11 使用的默认字体不是很理想。 大型的字体显得参差不齐,打开浏览器一看中文就能吐血而亡。

因此,需要我们手工加入字体,可采用如下两种方式:

1、添加Times Roman,Helvetica,Palatino等Type1字体

URW字体集合 (x11-fonts/urwfonts) 就包括了高质量的 标准 type1 字体。因此安装URW即可:

1.1安装URW

# cd /usr/ports/x11-fonts/urwfonts
# make install clean

1.2 配置URW

需要在 X 服务器的配置文件 (/etc/X11/xorg.conf) 中增加下面的配置:

FontPath "/usr/local/lib/X11/fonts/URW/"

也可采用命令方式在当前会话中执行,以下内容需要在X桌面的Terminal执行才可以。

% xset fp+ /usr/local/lib/X11/fonts/URW
% xset fp rehash

2、安装微软雅黑、宋体等等中文字体即 TrueType® 字体

Xorg 已经内建了对 TrueType® 字体的支持

2.1 配置文件

将下面这行添加到 /etc/X11/xorg.conf 文件的 "Module" 部分

Load "freetype"

2.2为 TrueType® 字体创建一个目录

比如, /usr/local/lib/X11/fonts/TrueType, 然后把所有的 TrueType® 字体复制到这个目录。记住您不能直接从 Macintosh® 计算机中提取TrueType® 字体; 能被 X11 使用的必须是UNIX®/MS-DOS®/Windows® 格式的。

2.3 用 ttmkfdir 来创建 fonts.dir 文件, 以便让X字体引擎知道您已经安装了这些新文件。

2.3.1 ttmkfdir 需要安装,直接用pkg_add -r ttmkfdir就能装上。

2.3.2

# cd /usr/local/lib/X11/fonts/TrueType
# ttmkfdir -o fonts.dir

3.4 把 TrueType® 字体目录添加到字体路径中

需要在 X 服务器的配置文件 (/etc/X11/xorg.conf) 中增加下面的配置:

FontPath "/usr/local/lib/X11/fonts/TrueType"

如果要立即启用请输入:(以下命令需要在X桌面的Terminal中执行才可以)

% xset fp+ /usr/local/lib/X11/fonts/TrueType
% xset fp rehash

就是这样。现在 Netscape®,Gimp,StarOffice™ 和其他所有的 X 应用程序 应该可以认出安装的TrueType® 字体。一些很小的字体(如在 Web 页面上高分辨率显示的文本) 和一些很大的字体(在StarOffice™ 下) 现在看起来已经很好了。

3、安装文泉驿中文字体:
# whereis wqy
wqy: /usr/ports/x11-fonts/wqy
# cd /usr/ports/x11-fonts/wqy
# make install clean
15分钟左右ok

让X系统启动时载入字体。
编辑/etc/X11/xorg.conf
在Section "Files"里面加一行,FontPath "/usr/local/lib/X11/fonts/wqy"像下面这样
Section "Files"
ModulePath  "/usr/local/lib/xorg/modules"
FontPath    "/usr/local/lib/X11/fonts/misc/"
FontPath    "/usr/local/lib/X11/fonts/TTF/"
FontPath    "/usr/local/lib/X11/fonts/OTF"
FontPath    "/usr/local/lib/X11/fonts/Type1/"
FontPath    "/usr/local/lib/X11/fonts/100dpi/"
FontPath    "/usr/local/lib/X11/fonts/75dpi/"
FontPath    "/usr/local/lib/X11/fonts/wqy"
EndSection

相关内容