【已解决 更新DEB】解决Gnome全局字体渲染设置与fontconfig之冲突。比较满意的雅黑显示效果。

系统字体配置、中文显示和输入法问题
头像
david_pi
帖子: 91
注册时间: 2010-03-28 1:52

【已解决 更新DEB】解决Gnome全局字体渲染设置与fontconfig之冲突。比较满意的雅黑显示效果。

#1

帖子 david_pi » 2010-04-29 8:14

小弟通过编辑local.conf单独设置某些字体的hint与AA,我只希望对几个微软字体打开hintfull,其他字体hintslight。
但发现fontconfig对gnome界面的字体设置根本没作用,会被gnome“外观首选项”的全局字体渲染设置吃掉。似乎是说,gnome“外观首选项”的全局字体渲染设置优先级高于fontconfig。如果把gnome的全局渲染设为hintfull,英文又变得很难看。
在gnome环境下,local.conf的设置只对某些程序(如firefox)起作用,系统菜单还是只遵循gnome“外观首选项”的字体渲染设置。而KDE中就可以把字体渲染选为“系统默认”,让所有程序都服从我的local.conf。
请问有无办法禁用gnome“外观首选项”的全局字体渲染设置?或者是在gnome下单独设置某些字体的渲染?
下面的截图可以说明我的问题:上面的firefox是hintfull,下面的nautilus是hintslight。望高人赐教。
gnome中,上面的firefox是hintfull,下面的nautilus是hintslight
gnome中,上面的firefox是hintfull,下面的nautilus是hintslight
Screenshot.png (25.29 KiB) 查看 11646 次
KDE中,只要将字体渲染设为“系统默认”,一切都很完美。
附KDE中截图三张:[/size]
KDE
KDE
KDE
KDE

再附上小弟的local.conf,在我的电脑上,这样设置,微软雅黑与Simsun都可以得到与win中近似相同的效果。
PS:微软雅黑一定要用5.0版本,win7中的6.02在ubuntu下怎样设置都惨不忍睹。

代码: 全选

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!--  顺序 --> 
<match target="pattern">
		<test qual="any" name="family">
			<string>serif</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>DejaVu Serif</string>
			<string>Bitstream Vera Serif</string>
			<string>Georgia</string>
			<string>Times New Roman</string>
			<string>SimSun</string>
			<string>WenQuanYi Bitmap Song</string>
			<string>WenQuanYi Zen Hei</string>
		</edit>
	</match> 
	<match target="pattern">
		<test qual="any" name="family">
			<string>sans-serif</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>DejaVu Sans</string>
			<string>Bitstream Vera Sans</string>
			<string>Arial</string>
			<string>Tahoma</string>
			<string>Verdana</string>
			<string>Segoe UI</string>
			<string>Microsoft YaHei</string>
			<string>WenQuanYi Micro Hei</string>
			<string>Microsoft JhengHei</string>
			<string>SimSun</string>
			<string>WenQuanYi Zen Hei</string>
		</edit>
	</match> 
	<match target="pattern">
		<test qual="any" name="family">
			<string>monospace</string>
		</test>
		<edit name="family" mode="prepend" binding="strong">
			<string>DejaVu Sans Mono</string>
			<string>Bitstream Vera Sans Mono</string>
			<string>Courier 10 Pitch</string>
			<string>Consolas</string>
			<string>Courier New</string>
			<string>Microsoft YaHei</string>
			<string>WenQuanYi Micro Hei Mono</string>
			<string>WenQuanYi Zen Hei Mono</string>
		</edit>
	</match> 
<!--  全局 --> 
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintslight</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
 </match>

<!--Hinting for Microsoft Yahei-->

    <match target="font">
        <test qual="any" name="family">
      <string>Microsoft Yahei</string>
      <string>微软雅黑</string>
      <string>msyh</string>
  </test>
  <edit name="autohint" mode="assign" >
          <bool>false</bool>
          </edit>
        <edit name="hinting" mode="assign" >
              <bool>true</bool>
        </edit>
        <edit name="hintstyle" mode="assign" >
              <const>hintfull</const>
        </edit>
  <edit name="rgba" mode="assign">
      <const>rgb</const>
  </edit>
<edit name="antialias" mode="assign"><bool>true</bool></edit>
    </match>

   <!--Hinting for SimSun-->
   <match target="font">
        <test qual="any" name="family">
                <string>SimSun</string>
                <string>宋体</string>
                <string>NSimSun</string>
                <string>新宋体</string>
        </test>
      <test name="weight" compare="less_eq" target="pattern">
         <const>medium</const>
      </test>
        <test compare="less_eq" name="pixelsize"><double>17</double></test>
        <edit name="antialias" mode="assign"><bool>false</bool></edit>
        <edit name="embeddedbitmap" mode="assign"><bool>true</bool></edit>
        <edit name="hinting" mode="assign"><bool>true</bool></edit>
        <edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
  <edit name="autohint" mode="assign" >
          <bool>false</bool>
          </edit>
</match>

<match target="pattern">
<test name="family">
<string>SimSun</string>
<string>宋体</string>
<string>NSimSun</string>
<string>新宋体</string>
</test>
<edit binding="strong" mode="prepend" name="family">
<string>Palatino Linotype</string>
</edit>
</match>

     <!--Hinting for Simhei-->
   <match target="font">
        <test qual="any" name="family">
                <string>SimHei</string>
                <string>黑体</string>
        </test>
        <edit name="antialias" mode="assign"><bool>true</bool></edit>
        <edit name="embeddedbitmap" mode="assign"><bool>true</bool></edit>
        <edit name="hinting" mode="assign"><bool>true</bool></edit>
        <edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
  <edit name="autohint" mode="assign" >
          <bool>false</bool>
          </edit>
  </match>

</fontconfig>
望高人赐教。



经过高人pheyx的指导,成功解决了此问题。

原来早就有人不爽这个bug,详见http://bugs.freedesktop.org/show_bug.cgi?id=11838。可以视作cairo的一个bug,无视fontconfig的hint设置。
补丁编译安装步骤如下:

代码: 全选

su
apt-get install build-essential devscripts fakeroot
apt-get build-dep libcairo2 libxft2 freetype
mkdir cairo
cd cairo
wget -O cairo-respect-fontconfig.patch http://bugs.freedesktop.org/attachment.cgi?id=34511
apt-get source cairo
cd cairo-1.8.10/
patch -p1 <../cairo-respect-fontconfig.patch
dpkg-buildpackage -rfakeroot -us -uc
cd ..
dpkg -i *.deb
现在gnome界面可以接受fontconfig的控制,即可以通过编辑local.conf或.fonts.conf来单独控制每个字体。
将雅黑字体设为hintfull,清晰明亮,而英文字体设为hintslight,饱满柔和。
可以进新力得把这个包hold住。
patch后的gnome菜单
patch后的gnome菜单
Screenshot.png (26.83 KiB) 查看 11206 次
再次感谢八楼pheyx,一位伟大的潜水者。
附上编译好的deb,懒得自己编译的筒子可以试试。
libcairo2_1.8.10-2ubuntu1_i386.deb
(506.19 KiB) 已下载 300 次
上次由 david_pi 在 2010-05-08 17:14,总共编辑 7 次。
头像
ptpt52
帖子: 717
注册时间: 2008-07-27 8:51
系统: Ubuntu/Windows
来自: 广西玉林|广东深圳
联系:

Re: 求助!Gnome的全局字体渲染吃掉了我的fontconfig。差一点就完美的字体解决方案(对我而言)。

#2

帖子 ptpt52 » 2010-04-29 8:23

好像把这些写到 ~/.fonts.conf 里面,注销再进就起作用了啊
走过去了也便有了路
http://www.ptpt52.com/
头像
david_pi
帖子: 91
注册时间: 2010-03-28 1:52

Re: 求助!Gnome的全局字体渲染吃掉了我的fontconfig。差一点就完美的字体解决方案(对我而言)。

#3

帖子 david_pi » 2010-04-29 8:29

ptpt52 写了:好像把这些写到 ~/.fonts.conf 里面,注销再进就起作用了啊
写到.fonts.conf也不起作用呀。我想.fonts.conf是在/etc/fonts/conf.d/50-user.conf被引用的,为了避免干扰,就在/etc/fonts/conf.d/建了个01-local.conf,99-local.conf,内容如上,把其他东西都夹在中间~~还是不起作用,被gnome吃掉。
ibook1
帖子: 53
注册时间: 2006-10-05 8:48

Re: 求助!Gnome的全局字体渲染设置吃掉了我的fontconfig。差一点就完美的字体解决方案(对我而言)。

#4

帖子 ibook1 » 2010-04-30 7:22

你这个配置能正常显示雅黑粗体吗?
头像
david_pi
帖子: 91
注册时间: 2010-03-28 1:52

Re: 求助!Gnome的全局字体渲染设置吃掉了我的fontconfig。差一点就完美的字体解决方案(对我而言)。

#5

帖子 david_pi » 2010-04-30 16:37

ibook1 写了:你这个配置能正常显示雅黑粗体吗?

这样算正确显示嘛?
Screenshot.png
Screenshot.png (9.34 KiB) 查看 11546 次
pheyx
帖子: 6
注册时间: 2006-01-19 20:47

Re: 求助!Gnome的全局字体渲染设置吃掉了我的fontconfig。差一点就完美的字体解决方案(对我而言)。

#7

帖子 pheyx » 2010-04-30 22:04

david_pi:这是cairo 的问题,你可以google一下cairo respect fontconfig patch,下载这个patch和 cairo的源码,应用patch 并手工编译安装,或者更好的办法是编译后先不安装,生成一个deb包,再安装这个deb包,这样卸载就会方便一些。
头像
david_pi
帖子: 91
注册时间: 2010-03-28 1:52

Re: 求助!Gnome的全局字体渲染设置吃掉了我的fontconfig。差一点就完美的字体解决方案(对我而言)。

#8

帖子 david_pi » 2010-05-01 0:40

pheyx 写了:david_pi:这是cairo 的问题,你可以google一下cairo respect fontconfig patch,下载这个patch和 cairo的源码,应用patch 并手工编译安装,或者更好的办法是编译后先不安装,生成一个deb包,再安装这个deb包,这样卸载就会方便一些。

多谢指点!我已成功解决问题!等会重新编辑帖子把方法写上。应该能帮助很多像我一样的人吧 :em01
lingallen
帖子: 74
注册时间: 2006-11-15 16:46

Re: [已解决】求助!Gnome的全局字体渲染设置吃掉了我的fontconfig。差一点就完美的字体解决方案(对我而言

#10

帖子 lingallen » 2010-05-03 13:19

写的很好,顺便解决了我的eva好多口口的问题,感谢作者
ibook1
帖子: 53
注册时间: 2006-10-05 8:48

Re: [已解决】求助!Gnome的全局字体渲染设置吃掉了我的fontconfig。差一点就完美的字体解决方案(对我而言

#11

帖子 ibook1 » 2010-05-03 15:57

表扬LZ的行为,自己解决了问题问题不忘其他的兄弟们 :em09
回头我试试你的配置文件
头像
Rerven
帖子: 75
注册时间: 2005-04-22 16:46

Re: [已解决】求助!Gnome的全局字体渲染设置吃掉了我的fontconfig。差一点就完美的字体解决方案(对我而言

#12

帖子 Rerven » 2010-05-03 23:09

其實使用文泉藝米黑的效果挺不錯的, 你可以試試看
头像
foolegg
帖子: 249
注册时间: 2007-12-01 14:56

Re: 【已解决 更新DEB】解决Gnome全局字体渲染设置与fontconfig之冲突。比较满意的雅黑显示效果。

#14

帖子 foolegg » 2010-05-08 20:13

goooood!
附上amd64的包
libcairo2_1.8.10-3ubuntu1_amd64.deb
(518.23 KiB) 已下载 160 次
libcairo2-dev_1.8.10-3ubuntu1_amd64.deb
(618.37 KiB) 已下载 158 次
我打包时候把发行版本号增加了一,可以暂时抵抗升级
york824
帖子: 965
注册时间: 2007-11-07 22:01

Re: 【已解决 更新DEB】解决Gnome全局字体渲染设置与fontconfig之冲突。比较满意的雅黑显示效果。

#15

帖子 york824 » 2010-06-10 22:40

楼主,我安装了你的deb包,但是很奇怪的是,firefox和chrome的显示不一样。
如图:
Screenshot.png
如今chrome的雅黑足够锐利了,但是firefox里面还是slight的hint,比较虚。
好像chrome现在跟系统设置里面的hint设置,而firefox则完全忽略系统设置,一概slight。
回复