Ubuntu Linux 6.06 下 Firefox 2.0b1 字体配置参考方案
大家可以看到,无论是中文网页还是英文网页,浏览效果都和Windows下的IE相差不大。
也许你注意到了,英文字体不如Windows下的锐利。这是因为启用了Anti-aliasing 的结果。
在 Windows XP 下,如果你安装了微软的 ClearType 字体美化软件,那么英文字体的美化效果和AA是相似的。
ClearType 和 Anti-aliasing 都是很先进的显示技术,有利于缓解视觉疲劳,保护眼睛。微软的下一代操作系统 Windows Vista 将应用 ClearType 显示技术。锋利的字体将成为 Windows 的历史。
这样的显示效果是怎么样配置出来的呢?
首先,你手头上要有支持 XFT 的 Firefox。Firefox 默认是不带 XFT 的。你最好自己编译一份。我现在下载的版本是2.0Beta1。
源码下载地址:
http://releases.mozilla.org/pub/mozilla.org/firefox/releases/2.0b1/source/firefox-2.0b1-source.tar.bz2
注意解压的源码不能直接编译,必须先在解压出来的mozilla目录下创建一个名为mozconfig的文件,指定编译参数。
具体方法参见源码包中的README.
下面把我的mozconfig文件内容贴出来给大家参考.
# Build Firefox
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/release/firefox-static
. $topsrcdir/browser/config/mozconfig
ac_add_options --enable-optimize=-O2
ac_add_options --disable-debug
ac_add_options --enable-default-toolkit=gtk2
ac_add_options --enable-xft #这是必须的
ac_add_options --enable-static
ac_add_options --disable-shared
ac_add_options --disable-tests
mozconfig创建完毕就可以编译安装了。
# ./configure
# make
# make install
下面安装常用中文字体。文泉驿、文鼎等都是不错的选择。如果你没有这些字体,那么考虑用Windows下已经安装的,包括中易公司的sim* 系列字体看看效果。比较简单的做法是,把Windows目录下的Fonts文件夹中几个重要字体,比如宋体、楷体、仿宋、细黑、Tohama、Arial等复制到 /usr/share/fonts/other 文件夹中。然后执行
# fc-cache /usr/share/fonts/other
更新字体缓存。
以下步骤是假定你拷贝了Windows\Fonts下的所有主要字体。如果你使用了其他字体,参照下面的步骤修改具体参数即可。
检查一下 /etc/fonts/fonts.conf 文件有没有被修改过。如果被修改了,最好恢复到最原始的版本。
下面在 /etc/fonts/ 目录下创建文件 local.conf ,文件内容如下:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/local.conf file for local customizations -->
<fontconfig>
<match target="font">
<edit name="autohint">
<bool>true</bool>
</edit>
<edit name="hintstyle">
<const>hintfull</const>
</edit>
<edit name="antialias">
<bool>true</bool>
</edit>
</match>
<match target="font">
<edit name="embeddedbitmap" mode="assign">
<bool>true</bool>
</edit>
</match>
<match target="font">
<!-- check to see if the font is just regular -->
<test name="weight" compare="less_eq">
<const>medium</const>
</test>
<!-- check to see if the pattern requests bold -->
<test target="pattern" name="weight" compare="more">
<const>medium</const>
</test>
<!--
set the embolden flag
needed for applications using cairo, e.g. gucharmap, gedit, ...
-->
<edit name="embolden" mode="assign">
<bool>true</bool>
</edit>
<!--
set weight to bold
needed for applications using Xft directly, e.g. Firefox, ...
-->
<edit name="weight" mode="assign">
<const>bold</const>
</edit>
<!--
Hinting will be done before Embolden in freetype2,
but in such case, Embolden will get wrong result
on some glyph contours after applying hinting.
Actually, hinting should be done after embolden, but we can't
fix it in current freetype2. So as a workaround, just turn off
hinting if we want to do embolden.
-->
<!--<edit name="hintstyle" mode="assign">
<const>hintnone</const>
</edit>-->
</match>
<match target="font">
<test target="pattern" name="lang" compare="contains">
<string>zh</string>
<string>ja</string>
<string>ko</string>
</test>
<edit name="spacing">
<const>proportional</const>
</edit>
<edit name="globaladvance">
<bool>false</bool>
</edit>
</match>
<match target="pattern">
<test name="family">
<string>SimSun</string>
<string>SimHei</string>
<string>KaiTi_GB2312</string>
<string>FangSong_GB2312</string>
<string>Batang</string>
<string>Gulim</string>
<string>MS Gothic</string>
<string>MingLiU</string>
<string>SimSun-18030</string>
<string>AR PL SungtiL GB</string>
<string>AR PL ShanHeiSun Uni</string>
<string>AR PL New Sung</string>
<string>PMingLiU</string>
</test>
<edit binding="strong" mode="prepend" name="family">
<string>Tahoma</string>
<string>Arial</string>
<string>Verdana</string>
<string>DejaVu Sans</string>
<string>Bitstream Vera Sans</string>
</edit>
</match>
<alias>
<family>serif</family>
<prefer>
<family>Nimbus Roman No9 L</family>
<family>Thorndale AMT</family>
<family>DejaVu Serif</family>
<family>Bitstream Vera Serif</family>
<family>Times New Roman</family>
<family>Luxi Serif</family>
<family>Likhan</family>
<family>FreeSerif</family>
<family>Times</family>
<family>SimSun</family>
<family>SimHei</family>
<family>KaiTi_GB2312</family>
<family>FangSong_GB2312</family>
<family>Batang</family>
<family>Gulim</family>
<family>MS Gothic</family>
<family>MingLiU</family>
<family>SimSun-18030</family>
<family>WenQuanYi Bitmap Song</family>
<family>AR PL ShanHeiSun Uni</family>
<family>AR PL New Sung</family>
<family>FZSongTi</family>
<family>FZMingTiB</family>
<family>AR PL SungtiL GB</family>
<family>AR PL Mingti2L Big5</family>
<family>Kochi Mincho</family>
<family>UnBatang</family>
<family>Baekmuk Batang</family>
<family>HanyiSong</family>
<family>ZYSong18030</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>DejaVu Sans</family>
<family>Bitstream Vera Sans</family>
<family>Luxi Sans</family>
<family>Arial</family>
<family>Verdana</family>
<family>Albany AMT</family>
<family>Nimbus Sans L</family>
<family>FreeSans</family>
<family>Helvetica</family>
<family>SimSun</family>
<family>SimHei</family>
<family>KaiTi_GB2312</family>
<family>FangSong_GB2312</family>
<family>Batang</family>
<family>Gulim</family>
<family>MS Gothic</family>
<family>MingLiU</family>
<family>SimSun-18030</family>
<family>WenQuanYi Bitmap Song</family>
<family>AR PL ShanHeiSun Uni</family>
<family>AR PL New Sung</family>
<family>FZSongTi</family>
<family>FZMingTiB</family>
<family>AR PL SungtiL GB</family>
<family>AR PL Mingti2L Big5</family>
<family>Kochi Gothic</family>
<family>UnDotum</family>
<family>Baekmuk Gulim</family>
<family>Baekmuk Dotum</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>DejaVu Sans Mono</family>
<family>Bitstream Vera Sans Mono</family>
<family>Luxi Mono</family>
<family>Courier New</family>
<family>Cumberland AMT</family>
<family>Nimbus Mono L</family>
<family>Andale Mono</family>
<family>FreeMono</family>
<family>SimSun</family>
<family>SimHei</family>
<family>KaiTi_GB2312</family>
<family>FangSong_GB2312</family>
<family>Batang</family>
<family>Gulim</family>
<family>MS Gothic</family>
<family>MingLiU</family>
<family>NSimSun</family>
<family>NSimSun-18030</family>
<family>PMingLiU</family>
<family>WenQuanYi Bitmap Song</family>
<family>AR PL ShanHeiSun Uni</family>
<family>AR PL New Sung</family>
<family>FZSongTi</family>
<family>FZMingTiB</family>
<family>AR PL SungtiL GB</family>
<family>AR PL Mingti2L Big5</family>
<family>Kochi Gothic</family>
<family>UnDotum</family>
<family>Baekmuk Gulim</family>
<family>Baekmuk Dotum</family>
<family>HanyiSong</family>
<family>ZYSong18030</family>
</prefer>
</alias>
</fontconfig>
这份配置文件能适应大多数情况。
注意中间有一段是分别指定中文字体和其他字体的渲染顺序的,大家可以根据自己的需要修改。
最后打开 Firefox 浏览器,在地址栏中输入
about:config修改一些键值。
以下左边为 Preference Name, 右边为修改后的值Value。
font.FreeType2.unhinted falsebrowser.display.use_document_fonts 0font.default.zh-CN SimSunfont.language.group x-westernfont.name.monospace.zh.CN SimSunfont.name.sans-serif.zh-CN SimSunfont.name.serif.zh-CN SimSuninti.charset.default GB2312以上只是针对简体中文的设置。如果你浏览繁体中文网页,可将
font.default.zh-HK 等设置为
-arphic-Ming for ISO10646-big5hkscs-0 等。
把
browser.display.use_document_fonts 置0是最关键的,否则下面的字体设置都不起作用。
SimSun就是你要使用的宋体的字体名称。使用字体查看器打开字体文件时可以看到字体名称。
好了,打开几个网页看看效果。
附带说一句,按照上面的方法创建文件
local.conf 后,在支持XFT的
Opera中不能再选SimSun作为首选字体了,否则网页文字会变得模糊不清。
依次打开 工具->首选项->高级->字体, 把网页普通文字改为
NSimSun,再在"国际字体"的"书写系统"选"简体中文", ",把"普通字体"也改为
NSimSun。(Veiz)