LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1470|回复: 6

fonts.conf及中文粗体的探索

[复制链接]
发表于 2006-9-29 00:31:30 | 显示全部楼层 |阅读模式
今天闲来无事研究了一下fontconfig的配置。以前也看过fonts.conf这个文件,但是一直没有很留意其中的“人工粗体”一小节。其原文是这样的:
<!--
Synthetic emboldening for fonts that do not have bold face available
-->

        <match target="font">
                <!-- check to see if the font is just regular -->
                <test name="weight" compare="less_eq">
                        <int>100</int>
                </test>
                <!-- check to see if the pattern requests bold -->
                <test target="pattern" name="weight" compare="more_eq">
                        <int>200</int>
                </test>
                <!-- set the embolden flag -->
                <edit name="embolden" mode="assign">
                        <bool>true</bool>
                </edit>
        </match>

意图很明显,就是对于那些认为需要作为“粗体”展现的pattern,而对应的字体本身不支持粗体时,通过调整"embolden"属性,模拟出粗体(比如可能是在偏移1个像素的地方重绘一次,造成“粗体”的假象)。结构上,前面两个<test>节是用于筛选出条件的,对于满足条件的pattern信息,通过<edit>节设置加粗的属性。如果把前面两个<test>都注释掉,那么结果就是所有的字体都绘被加粗显示。试验的结果也证实了这一点,包括中文在内的所有子体都是粗体了。显然如果能找到粗体与非粗体的临界条件,并在<test>中表现出来,那样就能很好的显示粗体了。我把第二个<test>打开,并把<int>值由200调整为100,结果发现仍然是全部粗体,也就是说没有得到很好的区分,于是试着把100改为150,再打开firefox,去了几个常用的网站,都能交好的显示粗体和正常字体了8-D

最终我的/etc/fonts/local.conf文件(不要改fonts.conf)中加入了如下的一节:

<!--
Synthetic emboldening for fonts that do not have bold face available
-->

        <match target="font">
                <!-- check to see if the font is just regular -->
                <!--test name="weight" compare="less_eq">
                        <int>100</int>
                </test-->
                <!-- check to see if the pattern requests bold -->
                <test target="pattern" name="weight" compare="more_eq">
                        <int>150</int>
                </test>
                <!-- set the embolden flag -->
                <edit name="embolden" mode="assign">
                        <bool>true</bool>
                </edit>
        </match>
发表于 2006-9-29 00:41:21 | 显示全部楼层
呵呵,改180。
回复 支持 反对

使用道具 举报

发表于 2006-9-29 08:17:56 | 显示全部楼层
搜一下就有了,探什么探...
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-9-29 09:13:06 | 显示全部楼层
我晕!果然搜到了,180......
还以为发现了新大陆-_-|||
回复 支持 反对

使用道具 举报

发表于 2006-9-29 12:03:32 | 显示全部楼层
直接转2.41都好了,但是原来9磅字现在要设置成11磅字才等大,也不知是要在那里设置一下?
回复 支持 反对

使用道具 举报

发表于 2006-9-29 12:19:02 | 显示全部楼层
其实字体主要的原因就在这个文件上,只要这个文件配只好,Linux下的开源字体的显示效果完全可以娉美simsun
回复 支持 反对

使用道具 举报

发表于 2006-9-29 15:37:46 | 显示全部楼层
一直没觉得simsun很好看……
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表