为什么中文字体在不同locale下显示效果不一样?请高手指点
我的理解是这样的,不知道对不对,目前没有utf-8的字体库,所以各种gb或big5的编码的字库要通过encodings.dir这个文件实现gb到 utf-8的映射来转换使用gb编码的中文字库,如果是这样的话字体的显示和locale应该没有关系阿,但是我安装了firefly new sung, 在中文locale下显示很好,但是换到其他的比如en_US.UTF-8 或者其他ISO-9XXX的时候字体的AA自动加上了,但是fonts.conf并没有改变设置,是安装firefly的自动修改了的,默认关掉中文字体的Anti-Alias,我真的不明白为什么到了英文的locale下fonts.conf似乎就失效了。如果选用其他字体如simsun...出现一样的问题。特别是firefox,,,别的软件可以用LANG=zh_CN,,,LC_MESSAGE=en_US来解决
但是只要firefox的界面是英文的,他就无视其他环境设定,是不是这类软件能够自己支配字体设置而绕过xft的fontconfig。还是fontconfig的局限性导致的,只能使用相应语言的locale才能正常执行对应字体的设置。
网上有各种各样的此类问题,无非是改变环境变量或者是给各个软件单独设置。我就是不明白为什么,gtk1用的是核心字体,gtk2和qt用的是xft的fontconfig, 为什么一改变 locale,似乎核心字体和xft的fontconfig就改变了似的。
另外一种方法就是在sans serif 和serif的prefer list里把中文字体提到最前边,那样的话英文也变了,这可以理解,自动使用中文字库的英文字体,因为在最上边,我猜想有这种可能,就是无法在同一个软件里对通一种风格比如serif自动使用两种不同的字体,根据locale选择对应的合适字体,而无视非本locale的语言字体。
请高手指点这个技术问题,为什么在非中文的locale下边fonts.conf就失效了,不论我的英文或其他西方语言是否UTF-8的或者ISO的。 Confused
我也在其他论坛上发表了相同的问题,希望能得到一个答案。谢谢大家。 截几张图上来看看,理论上说没有差别 只要不是太老的字体,应该都是iso10646编码。utf8是一种编码转换格式,不是一种编码。用于把ucs就是iso10646编码转换成老式设备能处理的8位编码
我看晕了,把你的fonts.conf贴上来看看吧 下边是我得fonts.conf,因为工作和学习的原因 ,以前从来没有用过中文,只使用和切换各种英文字体包括Latin ISO-XXX和ISO10645(unicode)的时候没有任何问题。现在在自己的笔记本上装了ubuntu, 发现了这样的问题,然后在其他发行版上尝试,问题是一样的,只要用中文的locale就没有任何问题,英文的时候关闭中文字体的AA的tag就无效了,这个问题很多人在不同中文论坛上都有问,但是没有什么答案,大家好像都不太了解xft fontconfig的具体运作方式,官方documentation并没有说什么有用的,只说了encodings.dir的用途,就是转换非iso10646的字库,但是我的工作原因必须使用全英文,现在似乎是没有办法。
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>
<!--
DO NOT EDIT THIS FILE.
IT WILL BE REPLACED WHEN FONTCONFIG IS UPDATED.
LOCAL CHANGES BELONG IN 'local.conf'.
The intent of this standard configuration file is to be adequate for
most environments.If you have a reasonably normal environment and
have found problems with this configuration, they are probably
things that others will also want fixed.Please submit any
problems to the fontconfig bugzilla system located at fontconfig.org
Note that the normal 'make install' procedure for fontconfig is to
replace any existing fonts.conf file with the new version.Place
any local customizations in local.conf which this file references.
Keith Packard
-->
<dir>/usr/share/fonts</dir>
<dir>/usr/X11R6/lib/X11/fonts/Type1</dir> <dir>/usr/local/share/fonts</dir>
<dir>~/.fonts</dir>
<!--
Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
<match target="pattern">
<test qual="any" name="family">
<string>mono</string>
</test>
<edit name="family" mode="assign">
<string>monospace</string>
</edit>
</match>
<!--
Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans serif</string>
</test>
<edit name="family" mode="assign">
<string>sans-serif</string>
</edit>
</match>
<!--
Accept deprecated 'sans' alias, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans</string>
</test>
<edit name="family" mode="assign">
<string>sans-serif</string>
</edit>
</match>
<!--
Mark common families with their generics so we'll get
something reasonable
-->
<!--
Serif faces
-->
<alias>
<family>Bitstream Vera Serif</family>
<family>AR PL New Sung</family>
<family>Times</family>
<family>Times New Roman</family>
<family>Nimbus Roman No9 L</family>
<family>Luxi Serif</family>
<family>Kochi Mincho</family>
<family>AR PL SungtiL GB</family>
<family>AR PL Mingti2L Big5</family>
<family>Baekmuk Batang</family>
<family>FreeSerif</family>
<default><family>serif</family></default>
</alias>
<!--
Sans-serif faces
-->
<alias>
<family>Bitstream Vera Sans</family>
<family>AR PL New Sung</family>
<family>Helvetica</family>
<family>Arial</family>
<family>Verdana</family>
<family>Nimbus Sans L</family>
<family>Luxi Sans</family>
<family>Kochi Gothic</family>
<family>AR PL KaitiM GB</family>
<family>AR PL KaitiM Big5</family>
<family>Baekmuk Dotum</family>
<family>SimSun</family>
<family>FreeSans</family>
<default><family>sans-serif</family></default>
</alias>
<!--
Monospace faces
-->
<alias>
<family>Bitstream Vera Sans Mono</family>
<family>AR PL New Sung</family>
<family>Courier</family>
<family>Courier New</family>
<family>Andale Mono</family>
<family>Luxi Mono</family>
<family>Nimbus Mono L</family>
<family>NSimSun</family>
<family>FreeMono</family>
<default><family>monospace</family></default>
</alias>
<!--
If the font still has no generic name, add sans-serif
-->
<match target="pattern">
<test qual="all" name="family" compare="not_eq">
<string>sans-serif</string>
</test>
<test qual="all" name="family" compare="not_eq">
<string>serif</string>
</test>
<test qual="all" name="family" compare="not_eq">
<string>monospace</string>
</test>
<edit name="family" mode="append_last">
<string>sans-serif</string>
</edit>
</match>
<!--
Some Asian fonts misadvertise themselves as monospaced when
in fact they are dual-spaced (half and full).This makes
FreeType very confused as it forces all widths to match.
Undo this magic by disabling the width forcing code -->
<match target="font">
<test name="family"><string>GulimChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<match target="font">
<test name="family"><string>DotumChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<match target="font">
<test name="family"><string>BatangChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<match target="font">
<test name="family"><string>GungsuhChe</string></test>
<edit name="globaladvance"><bool>false</bool></edit>
</match>
<!--
The Bitstream Vera fonts have GASP entries suggesting that hinting be
disabled below 8 ppem, but FreeType ignores those, preferring to use
the data found in the instructed hints.The initial Vera release
didn't include the right instructions in the 'prep' table. Fix this
by disabling hinting manually at smaller sizes (< 8ppem)
-->
<match target="font">
<test name="family">
<string>Bitstream Vera Sans</string>
</test>
<test name="pixelsize" compare="less">
<double>7.5</double>
</test>
<edit name="hinting">
<bool>false</bool>
</edit>
</match>
<match target="font">
<test name="family">
<string>Bitstream Vera Serif</string>
</test>
<test name="pixelsize" compare="less">
<double>7.5</double>
</test>
<edit name="hinting">
<bool>false</bool>
</edit>
</match>
<match target="font">
<test name="family">
<string>Bitstream Vera Sans Mono</string>
</test>
<test name="pixelsize" compare="less">
<double>7.5</double>
</test>
<edit name="hinting">
<bool>false</bool>
</edit>
</match>
<!--
Load local system customization file
-->
<include ignore_missing="yes">local.conf</include>
<!--
Load per-user customization file
-->
<include ignore_missing="yes">~/.fonts.conf</include>
<!--
Alias well known font names to available TrueType fonts
-->
<alias>
<family>Times</family>
<accept><family>Times New Roman</family></accept>
</alias>
<alias>
<family>Helvetica</family>
<accept><family>Verdana</family></accept>
</alias>
<alias>
<family>Arial</family>
<accept><family>Verdana</family></accept>
</alias>
<alias>
<family>Courier</family>
<accept><family>Courier New</family></accept>
</alias>
<!--
Check user preference to avoid bitmap fonts and replace
bitmap face names with equivalent scalable fonts
-->
<match target="pattern">
<test name="prefer_outline">
<bool>true</bool>
</test>
<test name="family">
<string>Helvetica</string>
</test>
<edit name="family" mode="prepend" binding="same">
<string>Arial</string>
</edit>
</match>
<match target="pattern">
<test name="prefer_outline">
<bool>true</bool>
</test>
<test name="family">
<string>Times</string>
</test>
<edit name="family" mode="prepend" binding="same">
<string>Times New Roman</string>
</edit>
</match>
<!--
Provide required aliases for standard names
-->
<alias>
<family>serif</family>
<prefer>
<family>Bitstream Vera Serif</family>
<family>AR PL New Sung</family>
<family>Times New Roman</family>
<family>Nimbus Roman No9 L</family>
<family>Luxi Serif</family>
<family>Times</family>
<family>Frank Ruehl</family>
<family>Kochi Mincho</family>
<family>AR PL SungtiL GB</family>
<family>AR PL Mingti2L Big5</family>
<family>Baekmuk Batang</family>
<family>FreeSerif</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Bitstream Vera Sans</family>
<family>AR PL New Sung</family>
<family>Verdana</family>
<family>Nimbus Sans L</family>
<family>Luxi Sans</family>
<family>Arial</family>
<family>Helvetica</family>
<family>Nachlieli</family>
<family>Kochi Gothic</family>
<family>AR PL KaitiM GB</family>
<family>AR PL KaitiM Big5</family>
<family>Baekmuk Dotum</family>
<family>SimSun</family>
<family>FreeSans</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Bitstream Vera Sans Mono</family>
<family>AR PL New Sung</family>
<family>Andale Mono</family>
<family>Courier New</family>
<family>Luxi Mono</family>
<family>Nimbus Mono L</family>
<family>Miriam Mono</family>
<family>Kochi Gothic</family>
<family>AR PL KaitiM GB</family>
<family>Baekmuk Dotum</family>
<family>FreeMono</family>
</prefer>
</alias>
<!--
Artificial oblique for fonts without an italic or oblique version
-->
<match target="font">
<!-- check to see if the font is roman -->
<test name="slant">
<const>roman</const>
</test>
<!-- check to see if the pattern requested non-roman -->
<test target="pattern" name="slant" compare="not_eq">
<const>roman</const>
</test>
<!-- multiply the matrix to slant the font -->
<edit name="matrix" mode="assign">
<times>
<name>matrix</name>
<matrix><double>1</double><double>0.2</double>
<double>0</double><double>1</double>
</matrix>
</times>
</edit>
<!-- pretend the font is oblique now -->
<edit name="slant" mode="assign">
<const>oblique</const>
</edit>
</match>
<match target="font">
<test qual="any" name="family" compare="eq">
<string>SimSun</string>
<string>NSimSun</string>
<string>AR PL Mingti2L Big5</string>
<string>AR PL SungtiL Big5</string>
<string>AR PL New Sung</string>
<string>Ming(ISO10646)</string>
<string>MingLiu</string>
<string>PMingLiu</string>
<string>Kochi Mincho</string>
<string>Baekmuk Dotum</string>
</test>
<test name="pixelsize" compare="less_eq">
<double>18</double>
</test>
<edit name="antialias">
<bool>false</bool>
</edit>
<edit name="hinting">
<bool>true</bool>
</edit>
</match>
<config>
<!--
These are the default Unicode chars that are expected to be blank
in fonts.All other blank chars are assumed to be broken and
won't appear in the resulting charsets
-->
<blank>
<int>0x0020</int> <!-- SPACE -->
<int>0x00a0</int> <!-- NO-BREAK SPACE -->
<int>0x00ad</int> <!-- SOFT HYPHEN -->
<int>0x115f</int> <!-- HANGUL CHOSEONG FILLER -->
<int>0x1160</int> <!-- HANGUL JUNGSEONG FILLER -->
<int>0x1680</int> <!-- OGHAM SPACE MARK -->
<int>0x2000</int> <!-- EN QUAD -->
<int>0x2001</int> <!-- EM QUAD -->
<int>0x2002</int> <!-- EN SPACE -->
<int>0x2003</int> <!-- EM SPACE -->
<int>0x2004</int> <!-- THREE-PER-EM SPACE -->
<int>0x2005</int> <!-- FOUR-PER-EM SPACE -->
<int>0x2006</int> <!-- SIX-PER-EM SPACE -->
<int>0x2007</int> <!-- FIGURE SPACE -->
<int>0x2008</int> <!-- PUNCTUATION SPACE -->
<int>0x2009</int> <!-- THIN SPACE -->
<int>0x200a</int> <!-- HAIR SPACE -->
<int>0x200b</int> <!-- ZERO WIDTH SPACE -->
<int>0x200c</int> <!-- ZERO WIDTH NON-JOINER -->
<int>0x200d</int> <!-- ZERO WIDTH JOINER -->
<int>0x200e</int> <!-- LEFT-TO-RIGHT MARK -->
<int>0x200f</int> <!-- RIGHT-TO-LEFT MARK -->
<int>0x2028</int> <!-- LINE SEPARATOR -->
<int>0x2029</int> <!-- PARAGRAPH SEPARATOR -->
<int>0x202a</int> <!-- LEFT-TO-RIGHT EMBEDDING -->
<int>0x202b</int> <!-- RIGHT-TO-LEFT EMBEDDING -->
<int>0x202c</int> <!-- POP DIRECTIONAL FORMATTING -->
<int>0x202d</int> <!-- LEFT-TO-RIGHT OVERRIDE -->
<int>0x202e</int> <!-- RIGHT-TO-LEFT OVERRIDE -->
<int>0x202f</int> <!-- NARROW NO-BREAK SPACE -->
<int>0x205f</int> <!-- MEDIUM MATHEMATICAL SPACE -->
<int>0x2060</int> <!-- WORD JOINER -->
<int>0x2061</int> <!-- FUNCTION APPLICATION -->
<int>0x2062</int> <!-- INVISIBLE TIMES -->
<int>0x2063</int> <!-- INVISIBLE SEPARATOR -->
<int>0x206A</int> <!-- INHIBIT SYMMETRIC SWAPPING -->
<int>0x206B</int> <!-- ACTIVATE SYMMETRIC SWAPPING -->
<int>0x206C</int> <!-- INHIBIT ARABIC FORM SHAPING -->
<int>0x206D</int> <!-- ACTIVATE ARABIC FORM SHAPING -->
<int>0x206E</int> <!-- NATIONAL DIGIT SHAPES -->
<int>0x206F</int> <!-- NOMINAL DIGIT SHAPES -->
<int>0x3000</int> <!-- IDEOGRAPHIC SPACE -->
<int>0x3164</int> <!-- HANGUL FILLER -->
<int>0xfeff</int> <!-- ZERO WIDTH NO-BREAK SPACE -->
<int>0xffa0</int> <!-- HALFWIDTH HANGUL FILLER -->
<int>0xfff9</int> <!-- INTERLINEAR ANNOTATION ANCHOR -->
<int>0xfffa</int> <!-- INTERLINEAR ANNOTATION SEPARATOR -->
<int>0xfffb</int> <!-- INTERLINEAR ANNOTATION TERMINATOR -->
</blank>
<!--
Rescan configuration every 30 seconds when FcFontSetList is called
-->
<rescan>
<int>30</int>
</rescan>
</config>
</fontconfig> 这是local.conf 没有什么有用的,只是引用firefly的字体conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<include ignore_missing="yes">/var/lib/defoma/fontconfig.d/fonts.conf</include>
<!-- Uncomment below to enable bitmapped fonts -->
<!--
<dir>/usr/X11R6/lib/X11/fonts</dir>
-->
<match target="font">
<test qual="all" name="rgba">
<const>unknown</const>
</test>
<edit name="rgba" mode="assign"><const>rgb</const></edit>
</match>
<!-- Uncomment below to enable the freetype autohinter module -->
<!--
<match target="font">
<edit name="autohint" mode="assign">
<bool>true</bool>
</edit>
</match>
-->
<include ignore_missing="yes">newsung-precedence.conf</include>
<include ignore_missing="yes">newsung-antialias.conf</include>
</fontconfig> 这是firefly的两个conf文件,大家可能都有,如果用的是deb的话。其实这里定义的东西和我的fonts.conf其实都是一样的,重复定义了,但是不管那个是开启的或者都开启的时候都不行。没设置什么东西,无非是调整各种pattern的prefer顺序,和关闭中文字体的AA。
newsung-precedence.conf 如下:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test name="family" compare="eq">
<string>serif</string>
</test>
<edit name="family" mode="assign">
<string>Bitstream Vera Serif</string>
<string>Times New Roman</string>
<string>Thorndale AMT</string>
<string>Times</string>
<string>Nimbus Roman No9 L</string>
<string>Luxi Serif</string>
<string>Kochi Mincho</string>
<string>AR PL New Sung</string>
<string>AR PL SungtiL GB</string>
<string>AR PL Mingti2L Big5</string>
<string>MS 明朝</string>
<string>Baekmuk Batang</string>
<string>FreeSerif</string>
</edit>
</match>
<match target="pattern">
<test name="family" compare="eq">
<string>sans-serif</string>
</test>
<edit name="family" mode="assign">
<string>Bitstream Vera Sans</string>
<string>Helvetica</string>
<string>Arial</string>
<string>Verdana</string>
<string>Albany AMT</string>
<string>Nimbus Sans L</string>
<string>Luxi Sans</string>
<string>Kochi Gothic</string>
<string>AR PL New Sung</string>
<string>AR PL KaitiM GB</string>
<string>AR PL KaitiM Big5</string>
<string>MS ゴシック</string>
<string>Baekmuk Dotum</string>
<string>SimSun</string>
<string>FreeSans</string>
</edit>
</match>
<match target="pattern">
<test name="family" compare="eq">
<string>mono</string>
</test>
<edit name="family" mode="assign">
<string>Bitstream Vera Sans Mono</string>
<string>Courier</string>
<string>Courier New</string>
<string>Andale Mono</string>
<string>Luxi Mono</string>
<string>Cumberland AMT</string>
<string>Nimbus Mono L</string>
<string>NSimSun</string>
<string>FreeMono</string>
<string>AR PL New Sung</string>
</edit>
</match>
</fontconfig>
antialias.conf如下:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- Disable antialias feature of AR PL New Sung when pixelsize less than 17 -->
<match target="font">
<test name="family"><string>AR PL New Sung</string></test>
<edit name="antialias"><bool>false</bool></edit>
<edit name="hinting"><bool>true</bool></edit>
<edit name="autohint"><bool>false</bool></edit>
</match>
<match target="font">
<test name="family"><string>AR PL New Sung</string></test>
<test name="pixelsize" compare="more_eq"><int>17</int></test>
<edit name="antialias" mode="assign"><bool>true</bool></edit>
<edit name="hinting" mode="assign"><bool>true</bool></edit>
</match>
</fontconfig> 二楼的老大,这论坛怎么发图片?我不太会用BBS。其实不用看,明显的AA效果,就是那样子,边缘模糊不清,有的地方深有的地方浅而已。谢谢各位。 抱歉阿,不知道拉 :oops: 知道是怎么回事了,
把simsun往前放,放到第二个位置上 知道是怎么回事了,
把simsun往前放,放到第二个位置上
放到第几个位置都没用,可以看见前边有new sung,一开始用的simsun,比这个更难看,所以把new sung提前。谢谢。 把simsun放在new sung的后面试试看,new sung字体似乎没有起作用,它使用的是Xorg里fixed字体中的中文
在ubuntu里弄中文很简单啊,只要把中文字体复制到/usr/share/fonts里,然后mkfontscale,mkfontdir,fc-cache就行了,不知道你怎么弄的 把simsun放在new sung的后面试试看,new sung字体似乎没有起作用,它使用的是Xorg里fixed字体中的中文
在ubuntu里弄中文很简单啊,只要把中文字体复制到/usr/share/fonts里,然后mkfontscale,mkfontdir,fc-cache就行了,不知道你怎么弄的
您好,您说的是核心字体的使用方法,xft并不使用 dir 和 scale 那两个文件来找字体,使用核心字体的程序很少了,好像只有用gtk1的才自动使用,现在很少程序是使用gtk1开发了。那个字体是new sung,但是问题是在英文locale下的自动打开了AA,,,我问了一个xft开发组人员,他说他也不清楚,因为现在xft的设计并没有太多考虑到东亚字体的处理,有可能是所使用的程序如firefox强行指定的开启AA,所以我修改了firefox设置外观的那两个样式表文件,让他强行关闭AA,,,结果就生效了,但是同时英文字体自然也就关闭了AA,,,所以英文又变得很难看。所以我感觉这一切都是因为应用程序自身的问题,导致了fontconfig的失效。
Linux现在东亚语言支持的问题还很多,特别是内核的不支持双字节编码,希望大家能一起努力推动Linux的真正中文支持。 我以前用ubuntu的时候就是这么做的,没有任何问题,gtk1和gtk2都可以正常的使用中文字体
现在中文支持方面,用户已经不需要做什么工作了
<match target="font">
<edit name="antialias" mode="assign"><bool>true</bool></edit>
<edit name="hinting" mode="assign"><bool>false</bool></edit>
<edit name="autohint" mode="assign"><bool>false</bool></edit>
<edit name="hintstyle" mode="assign"><const>hintnone</const></edit>
<edit name="rh_prefer_bitmaps" mode="assign"><bool>false</bool></edit>
</match>
<match target="font">
<test compare="more_eq" name="pixelsize" qual="any" ><double>12</double></test>
<test compare="less_eq" name="pixelsize" qual="any" ><double>16</double></test>
<edit name="antialias" mode="assign"><bool>false</bool></edit>
<edit name="hinting" mode="assign"><bool>true</bool></edit>
<edit name="autohint" mode="assign"><bool>false</bool></edit>
<edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
<edit name="rh_prefer_bitmaps" mode="assign"><bool>true</bool></edit>
</match>
试试看
页:
[1]