Chinaunix首页 | 论坛 | 博客
  • 博客访问: 246911
  • 博文数量: 33
  • 博客积分: 3030
  • 博客等级: 中校
  • 技术积分: 500
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-09 17:49
文章分类

全部博文(33)

文章存档

2011年(1)

2010年(1)

2009年(10)

2008年(21)

我的朋友

分类: LINUX

2008-06-08 19:14:30

linux下的中文字体确实是一个比较令人头大的地方,尤其是在gentoo下,每次编译过fontconfig后总是会出一点状况,那么为了长期稳定使用自己设置好的中文字体,那么除了把配置文件放在用户本地目录下外,另一个办法就是把文件备份。中文字体用simsun.ttf等。

在用户本地目录下~/.fonts.conf


<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <alias>
  <family>serif</family>
  <prefer>
   <family>Tahoma</family>
   <family>SimSun</family>
   <family>Bitstream Vera Serif</family>
  </prefer>
 </alias>
 <alias>
  <family>sans-serif</family>
  <prefer>
   <family>Tahoma</family>
   <family>SimSun</family>
   <family>Bitstream Vera Sans</family>
  </prefer>
 </alias>
 <alias>
  <family>monospace</family>
  <prefer>
   <family>Tahoma</family>
   <family>SimSun</family>
   <family>Bitstream Vera Sans Mono</family>
  </prefer>
 </alias>
 <match target="font" >
  <edit mode="assign" name="rgba" >
   <const>none</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>hintmedium</const>
  </edit>
 </match>
 <match target="font" >
  <edit mode="assign" name="antialias" >
   <bool>false</bool>
  </edit>
 </match>
</fontconfig>


在/etc/fonts/目录下:
/etc/fonts/fonts.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">

<fontconfig>





    <dir>/usr/share/fonts</dir>
    <dir>/usr/local/share/fonts</dir>
    <dir>~/.fonts</dir>


    <match target="pattern">
        <test qual="any" name="family">
            <string>mono</string>
        </test>
        <edit name="family" mode="assign">
            <string>monospace</string>
        </edit>
    </match>


    <match target="pattern">
        <test qual="any" name="family">
            <string>sans serif</string>
        </test>
        <edit name="family" mode="assign">
            <string>sans-serif</string>
        </edit>
    </match>


    <match target="pattern">
        <test qual="any" name="family">
            <string>sans</string>
        </test>
        <edit name="family" mode="assign">
            <string>sans-serif</string>
        </edit>
    </match>


    <include ignore_missing="yes">conf.d</include>



    <cachedir>/var/cache/fontconfig</cachedir>
    <cachedir>~/.fontconfig</cachedir>

    <config>

        <blank>
            <int>0x0020</int>    
            <int>0x00A0</int>    
            <int>0x00AD</int>    
            <int>0x034F</int>    
            <int>0x0600</int>    
            <int>0x0601</int>    
            <int>0x0602</int>    
            <int>0x0603</int>    
            <int>0x06DD</int>    
            <int>0x070F</int>    
            <int>0x115F</int>    
            <int>0x1160</int>    
            <int>0x1680</int>    
            <int>0x17B4</int>    
            <int>0x17B5</int>    
            <int>0x180E</int>    
            <int>0x2000</int>    
            <int>0x2001</int>    
            <int>0x2002</int>    
            <int>0x2003</int>    
            <int>0x2004</int>    
            <int>0x2005</int>    
            <int>0x2006</int>    
            <int>0x2007</int>    
            <int>0x2008</int>    
            <int>0x2009</int>    
            <int>0x200A</int>    
            <int>0x200B</int>    
            <int>0x200C</int>    
            <int>0x200D</int>    
            <int>0x200E</int>    
            <int>0x200F</int>    
            <int>0x2028</int>    
            <int>0x2029</int>    
            <int>0x202A</int>    
            <int>0x202B</int>    
            <int>0x202C</int>    
            <int>0x202D</int>    
            <int>0x202E</int>    
            <int>0x202F</int>    
            <int>0x205F</int>    
            <int>0x2060</int>    
            <int>0x2061</int>    
            <int>0x2062</int>    
            <int>0x2063</int>    
            <int>0x206A</int>    
            <int>0x206B</int>    
            <int>0x206C</int>    
            <int>0x206D</int>    
            <int>0x206E</int>    
            <int>0x206F</int>    
            <int>0x2800</int>    
            <int>0x3000</int>    
            <int>0x3164</int>    
            <int>0xFEFF</int>    
            <int>0xFFA0</int>    
            <int>0xFFF9</int>    
            <int>0xFFFA</int>    
            <int>0xFFFB</int>    
        </blank>

        <rescan>
            <int>30</int>
        </rescan>
    </config>

</fontconfig>



/etc/fonts/fonts.dtd


<!ELEMENT fontconfig (dir |
         cache |
         cachedir |
         include |
         config |
         selectfont |
         match |
         alias)* >


<!ELEMENT dir (#PCDATA)>
<!ATTLIST dir xml:space (default|preserve) 'preserve'>


<!ELEMENT cache (#PCDATA)>
<!ATTLIST cache xml:space (default|preserve) 'preserve'>


<!ELEMENT cachedir (#PCDATA)>
<!ATTLIST cachedir xml:space (default|preserve) 'preserve'>


<!ELEMENT include (#PCDATA)>
<!ATTLIST include
     ignore_missing (no|yes)        "no"
     xml:space     (default|preserve)    "preserve">


<!ELEMENT config (blank|rescan)*>


<!ELEMENT blank (int)*>



<!ELEMENT rescan (int)>


<!ELEMENT selectfont (rejectfont | acceptfont)* >

<!ELEMENT rejectfont (glob | pattern)*>

<!ELEMENT acceptfont (glob | pattern)*>

<!ELEMENT glob (#PCDATA)>

<!ELEMENT pattern (patelt)*>

<!ENTITY % constant 'int|double|string|matrix|bool|charset|const'>

<!ELEMENT patelt (%constant;)*>
<!ATTLIST patelt
     name CDATA    #REQUIRED>

<!ELEMENT alias (family*, prefer?, accept?, default?)>
<!ATTLIST alias
     binding (weak|strong|same) "weak">
<!ELEMENT prefer (family)*>
<!ELEMENT accept (family)*>
<!ELEMENT default (family)*>
<!ELEMENT family (#PCDATA)>
<!ATTLIST family xml:space (default|preserve) 'preserve'>

<!ENTITY % expr 'int|double|string|matrix|bool|charset
        |name|const
        |or|and|eq|not_eq|less|less_eq|more|more_eq|contains|not_contains
        |plus|minus|times|divide|not|if|floor|ceil|round|trunc'
>


<!ELEMENT match (test*, edit*)>
<!ATTLIST match
     target (pattern|font|scan) "pattern">


<!ELEMENT test (%expr;)*>
<!ATTLIST test
     qual (any|all|first|not_first) "any"
     name CDATA     #REQUIRED
     target (pattern|font|default)        "default"
     compare (eq|not_eq|less|less_eq|more|more_eq|contains|not_contains)    "eq">


<!ELEMENT edit (%expr;)*>
<!ATTLIST edit
     name CDATA     #REQUIRED
     mode (assign|assign_replace|prepend|append|prepend_first|append_last) "assign"
     binding (weak|strong|same) "weak">


<!ELEMENT int (#PCDATA)>
<!ATTLIST int xml:space (default|preserve) 'preserve'>
<!ELEMENT double (#PCDATA)>
<!ATTLIST double xml:space (default|preserve) 'preserve'>
<!ELEMENT string (#PCDATA)>
<!ATTLIST string xml:space (default|preserve) 'preserve'>
<!ELEMENT matrix (double,double,double,double)>
<!ELEMENT bool (#PCDATA)>
<!ELEMENT charset (#PCDATA)>
<!ATTLIST charset xml:space (default|preserve) 'preserve'>
<!ELEMENT name (#PCDATA)>
<!ATTLIST name xml:space (default|preserve) 'preserve'>
<!ELEMENT const (#PCDATA)>
<!ATTLIST const xml:space (default|preserve) 'preserve'>
<!ELEMENT or (%expr;)*>
<!ELEMENT and (%expr;)*>
<!ELEMENT eq ((%expr;), (%expr;))>
<!ELEMENT not_eq ((%expr;), (%expr;))>
<!ELEMENT less ((%expr;), (%expr;))>
<!ELEMENT less_eq ((%expr;), (%expr;))>
<!ELEMENT more ((%expr;), (%expr;))>
<!ELEMENT more_eq ((%expr;), (%expr;))>
<!ELEMENT contains ((%expr;), (%expr;))>
<!ELEMENT not_contains ((%expr;), (%expr;))>
<!ELEMENT plus (%expr;)*>
<!ELEMENT minus (%expr;)*>
<!ELEMENT times (%expr;)*>
<!ELEMENT divide (%expr;)*>
<!ELEMENT not (%expr;)>
<!ELEMENT if ((%expr;), (%expr;), (%expr;))>
<!ELEMENT floor (%expr;)>
<!ELEMENT ceil (%expr;)>
<!ELEMENT round (%expr;)>
<!ELEMENT trunc (%expr;)>


/etc/fonts/local.conf

<match target="pattern">
    <edit name="dpi" mode="assign">
        <double>96</double>
    </edit>
</match>


在/etc/fonts/conf.d/下有很多链接,整理出需要的如下:
10-no-sub-pixel.conf   20-unhint-small-vera.conf  50-user.conf
10-sub-pixel-bgr.conf  40-generic.conf            51-local.conf
10-unhinted.conf       49-sansserif.conf     

经过这样的设置后不但系统的中文显示没有任何问题,而且firefox的中文显示也和系统的完全统一了。

阅读(2154) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~