LinuxSir.cn,穿越时空的Linuxsir!

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

中文字体与输入法设置

[复制链接]
发表于 2009-6-3 18:53:39 | 显示全部楼层 |阅读模式
根据自己的经验总结,抛砖引玉。不同的发行版其实指导思想也差不多。

字体——

一、为了实现字体修饰功能,确保带这几个关键字的包装上:fontconfig 、freetype 、Xft 、cairo
Mandirva2009.1(x86_64)里面好像是:lib64xft2、fontconfig、lib64cairo2、freetype
ps:有时候reinstall(--replacepkg)一遍这几个包flash的字体就能显示了,有时不行。

二、查出显示器LCD的真实DPI。
例如我的网上查到我显示器规格DPI点距是0.282mm。1英寸是25.4mm,那么DPI=25.4 / 0.282 = 90;
还有一种方法是那尺子量显示器的宽、高,除以分辨率:宽mm/1680,高mm/1050
写入/etc/X11/xorg.conf
  1. Section "Monitor"
  2.     Option         "DPI" "90 x 90"
  3. EndSection
复制代码
重启,检测方法:终端运行
  1. xdpyinfo | grep resolution
复制代码
,应该就是你设置的DPI

三、安装字体
LCD推荐用矢量字体,我觉得矢量已经很锐利了,请看附件截图。
当然,点阵也是要的,为了和别人交流。
把字体放到/usr/share/fonts目录下,自己建个目录把costom。弄好了就运行fc-cache -fv刷新字体。

四、开启字体效果
这就是我乱来的,我把openSUSE里的配置文件照搬,然后改了几个false为true。
生成文件/etc/fonts/local.conf或~/.fonts.conf
仅供参考:
  1. <?xml version="1.0"?>
  2. <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
  3. <fontconfig>
  4. <!-- Generated by SuSEconfig.fonts, don't edit, your changes will get lost. -->
  5. <!-- Edit /etc/sysconfig/fonts-config instead.                              -->
  6. <!-- Or put rules into your personal config file ~/.fonts.conf.             -->
  7. <!-- ************************************************************ -->
  8. <!-- Hinting and antialiasing                                     -->
  9. <!-- ************************************************************ -->
  10. <!--
  11.     Using hinting=true, hintstyle=hintfull and antialias=true
  12.     is a good default for most fonts.
  13.     Match on "pattern" for the default, not on "font" to make
  14.     it easier to override the default using FcPatternDel()
  15.     and FcPatternAdd...() (see bugzilla #104365).
  16. -->
  17.         <match target="pattern">
  18.                 <edit name="hinting">
  19.                         <bool>true</bool>
  20.                 </edit>
  21.                 <edit name="hintstyle">
  22.                         <const>hintfull</const>
  23.                 </edit>
  24.                 <edit name="antialias">
  25.                         <bool>true</bool>
  26.                 </edit>
  27.         </match>
  28. <!--
  29.     Set autohinter=true as the default, then add exceptions for certain fonts.
  30.     Match on "font" here, not on "pattern" because of bug #118131 comment #93.
  31.     (If an autohint value is set in pattern, OpenOffice 2.1 will use that even
  32.     if there are fontconfig rules matching on "font" which should override it
  33.     again). This doesn't cause any problems for Cairo/Gnome (see bug #104365)
  34.     because Cairo/Gnome don't try to change the autohint value anyway.
  35. -->
  36.        
  37.         <match target="font">
  38.                 <edit name="autohint">
  39.                         <bool>true</bool>
  40.                 </edit>
  41.         </match>
  42.         <!--
  43.             Switch off the autohinter for PostScript fonts (Type 1 and OpenType CFF)
  44.             because using the PostScript hinting usually looks better than using
  45.             the autohinter.
  46.         -->
  47.         <match target="font">
  48.                 <test name="fontformat">
  49.                         <string>Type 1</string>
  50.                         <string>CFF</string>
  51.                 </test>
  52.                 <edit name="autohint">
  53.                         <bool>true</bool>
  54.                 </edit>
  55.         </match>
  56. <!--
  57.     TrueType Fonts which have high quality byte code interpreter
  58.     instructions can look very good in even in small sizes when using
  59.     the byte code interpreter (autohint=false). This is true
  60.     both with and without anti-aliasing.
  61.     In black and white (antialias=false) the results when rendering
  62.     with the byte code interpreter may even look as good as high quality
  63.     bitmap fonts.
  64.     On the other hand, some low quality TrueType Fonts do not have
  65.     byte code interpreter instructions at all or only very bad byte
  66.     code and may look better when the autohinter is used.
  67.     (See "FreeSans" for example, it looks better with the
  68.     autohinter which is especially obvious if anti-aliasing is off).
  69. -->
  70.         <!--
  71.             Switch off the autohinter for TrueType fonts in order
  72.             to use the byte code interpreter.
  73.         -->
  74.                
  75.         <match target="font">
  76.                 <test name="fontformat">
  77.                         <string>TrueType</string>
  78.                 </test>
  79.                 <edit name="autohint">
  80.                         <bool>true</bool>
  81.                 </edit>
  82.         </match>
  83.         <!--
  84.             Switch on the autohinter for a few TrueType fonts which
  85.             have no byte code or very bad byte code and look better
  86.             with the autohinter:
  87.             But see also bug #215602 for many fonts the autohinter
  88.             seriously distorts the metrics so badly that
  89.             even the digits which should be monospaced are not
  90.             monospaced at all anymore.
  91.             Because of this problem, better don't switch on
  92.             the autohinter for
  93.                Sazanami
  94.                IPA
  95.                DejaVu Sans Light
  96.                DejaVu Sans Condensed
  97.                DejaVu Serif Condensed
  98.                FreeSans
  99.                FreeSerif
  100.                FreeMono
  101.             and other fonts with similar problems until this is solved
  102.             in the autohinter.
  103.         -->
  104.         <match target="font">
  105.                 <test name="fontformat">
  106.                         <string>TrueType</string>
  107.                 </test>
  108.                 <test name="family">
  109.                         <string>iLiHei</string>
  110.                         <string>Microsoft YaHei</string>
  111.                         <string>Vera Sans YuanTi</string>
  112.                         <string>Vera Sans YuanTi Mono</string>
  113.                         <string>MS PGothic</string>
  114.                         <string>MS UI Gothic</string>
  115.                         <string>MS Mincho</string>
  116.                         <string>MS PMincho</string>
  117.                         <string>HGPSoeiKakupoptai</string>
  118.                         <string>HGSGothicE</string>
  119.                         <string>HGSGothicM</string>
  120.                         <string>HGKyokashotai</string>
  121.                         <string>HGSSoeiKakugothicUB</string>
  122.                         <string>HGPGothicB</string>
  123.                         <string>HGPGothicE</string>
  124.                         <string>HGPGothicM</string>
  125.                         <string>HGSKyokashotai</string>
  126.                         <string>HGMaruGothicMPRO</string>
  127.                         <string>HGPSoeiKakugothicUB</string>
  128.                         <string>HGMinchoL</string>
  129.                         <string>HGPMinchoL</string>
  130.                         <string>HGMinchoB</string>
  131.                         <string>HGPMinchoB</string>
  132.                         <string>HGSMinchoB</string>
  133.                         <string>HGMinchoE</string>
  134.                         <string>HGPMinchoE</string>
  135.                         <string>HGSMinchoE</string>
  136.                         <string>HGSoeiKakugothicUB</string>
  137.                         <string>HGGyoshotai</string>
  138.                         <string>HGPGyoshotai</string>
  139.                         <string>HGSGyoshotai</string>
  140.                         <string>HGSoeiKakupoptai</string>
  141.                         <string>HGSSoeiPresenceEB</string>
  142.                         <string>HGPSoeiPresenceEB</string>
  143.                         <string>HGGothicB</string>
  144.                         <string>HGGothicE</string>
  145.                         <string>HGGothicM</string>
  146.                         <string>HGSoeiPresenceEB</string>
  147.                         <string>HGPKyokashotai</string>
  148.                         <string>HGSSoeiKakupoptai</string>
  149.                         <string>HGSeikaishotaiPRO</string>
  150.                         <string>TLKyokashotai</string>
  151.                         <string>TLMincho</string>
  152.                         <string>TLPMincho</string>
  153.                         <string>TLPGothic</string>
  154.                         <string>TLPKyokashotai</string>
  155.                         <string>TLMarugothicM</string>
  156.                         <string>TLGyoshotai</string>
  157.                         <string>TLPGyoshotai</string>
  158.                         <string>TLSGyoshotai</string>
  159.                         <string>TLPMarugothicM</string>
  160.                         <string>TLSMarugothicM</string>
  161.                         <string>TLSKyokashotai</string>
  162.                         <string>TLGothic</string>
  163.                 </test>
  164.                 <edit name="autohint">
  165.                         <bool>true</bool>
  166.                 </edit>
  167.         </match>
  168.         <!--
  169.             The following rule sets up black and white rendering with
  170.             the byte code interpreter for a small list of fonts which
  171.             are known to have good byte code and give bitmap quality
  172.             results at small sizes.
  173.             The pixelsize limit is set to '0' though, which effectively
  174.             disables this rule by default because most users don't like
  175.             that bitmap look and feel.
  176.             If you like a bitmap look and feel of your desktop,
  177.             copy this rule into your ~/.fonts.conf file and replace the '0'
  178.             with non-zero pixelsize limit. Using '18' as the pixelsize
  179.             limit is a good choice if you have the fonts in this list installed
  180.             and like a bitmap look and feel.
  181.         -->
  182.         <match target="font">
  183.                 <test name="family">
  184.                         <string>iLiHei</string>
  185.                         <string>Microsoft YaHei</string>
  186.                         <string>Vera Sans YuanTi</string>
  187.                         <string>Vera Sans YuanTi Mono</string>
  188.                         <string>Andale Mono</string>
  189.                         <string>Arial</string>
  190.                         <string>Comic Sans MS</string>
  191.                         <string>Georgia</string>
  192.                         <string>Impact</string>
  193.                         <string>Trebuchet MS</string>
  194.                         <string>Verdana</string>
  195.                         <string>Courier New</string>
  196.                         <string>Times New Roman</string>
  197.                         <string>Tahoma</string>
  198.                         <string>Webdings</string>
  199.                         <string>Albany AMT</string>
  200.                         <string>Thorndale AMT</string>
  201.                         <string>Cumberland AMT</string>
  202.                         <string>Andale Sans</string>
  203.                         <string>Andy MT</string>
  204.                         <string>Bell MT</string>
  205.                         <string>Monotype Sorts</string>
  206.                 </test>
  207.                 <test name="pixelsize" compare="less_eq">
  208.                                 <double>0</double>
  209.                 </test>
  210.                 <edit name="autohint">
  211.                         <bool>true</bool>
  212.                 </edit>
  213.                 <edit name="antialias">
  214.                         <bool>true</bool>
  215.                 </edit>
  216.         </match>
  217. <!--
  218.   Some CJK fonts require the byte code interpreter to be rendered correctly.
  219.   These are composite fonts which store components and composing information
  220.   and compose the glyphs on the fly using the hinting instructions.
  221.   For all such fonts we switch off the autohinter here.
  222.   When "autohint" is set to "false", the byte code interpreter will
  223.   be used if it has been enabled at all when compiling freetype2.
  224.   The Chinese fonts "MingLiu" and "PMingLiU" used to belong to the fonts
  225.   which absolutely require the byte code interpreter to be rendered
  226.   correctly.
  227.   But apparently the new versions of "MingLiU" and "PMingLiU" from Windows
  228.   Vista are rendered correctly without the byte code interpreter.
  229. -->
  230.         <match target="font">
  231.                 <test name="family">
  232.                         <string>iLiHei</string>
  233.                         <string>Microsoft YaHei</string>
  234.                         <string>MingLiU</string>
  235.                         <string>Vera Sans YuanTi</string>
  236.                         <string>Vera Sans YuanTi Mono</string>
  237.                         <string>PMingLiU</string>
  238.                 </test>
  239.                 <edit name="autohint">
  240.                         <bool>true</bool>
  241.                 </edit>
  242.         </match>
  243. <!--
  244. Hinting for CJK fonts in freetype doesn't yet work as well as for Latin fonts.
  245. Recently the autohinter in in freetype has been improved for CJK fonts
  246. a lot but it is still not perfect. Therefore one might want to switch
  247. off the autohinter for CJK fonts.
  248. This can be achieved by using the following rule:
  249.         <match target="font">
  250.                 <test name="lang" compare="contains">
  251.                         <string>ja</string>
  252.                         <string>zh</string>
  253.                         <string>ko</string>
  254.                 </test>
  255.                 <edit name="autohint">
  256.                         <bool>true</bool>
  257.                 </edit>
  258.         </match>
  259. -->
  260. <!--
  261. for some Bengali fonts (e.g. "Mukti Narrow"), the autohinter works well
  262. with the patch from http://www.kde.gr.jp/~akito/patch/freetype2/2.1.7
  263. applied. But for "Likhan" it still doesn't work that well
  264. (look how the "matra" lines at the top line up). Therefore, switch
  265. off the autohinter for the "Likhan" font:
  266. -->
  267.         <match target="font">
  268.                 <test name="family">
  269.                         <string>iLiHei</string>
  270.                         <string>Likhan</string>
  271.                         <string>Microsoft YaHei</string>
  272.                         <string>Vera Sans YuanTi</string>
  273.                         <string>Vera Sans YuanTi Mono</string>
  274.                 </test>
  275.                 <edit name="autohint">
  276.                         <bool>true</bool>
  277.                 </edit>
  278.         </match>
  279. </fontconfig>
复制代码

五、桌面环境的设置
KDE在systemsettings里:slight、medium、full。 不建议开RGB
GNOME在appearance里:Monochrome、Best shapes、Best contrast 、grayscale+slight等等。我开Subpixel smoothing会出现红蓝偏色。
注意不一定开得越高好,不同字体不同设置有最佳效果。
字体推荐:
文泉驿正黑(含等宽)
文泉驿微米黑(含等宽)
Vera Sans YuanTi (含等宽)
微软雅黑
微软正黑
iLiHei

重启。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
 楼主| 发表于 2009-6-3 18:54:19 | 显示全部楼层
输入法——

举个ibus的例子

一、无论中文或英文环境,确保LC_CTYPE是zh_CN.UTF-8
# cat /etc/sysconfig/i18n
  1. LC_TELEPHONE=en_US.UTF-8
  2. [color=red]LC_CTYPE=zh_CN.UTF-8[/color]
  3. LANGUAGE=en_US.UTF-8:en_US:en
  4. LC_MONETARY=en_US.UTF-8
  5. LC_ADDRESS=en_US.UTF-8
  6. [color=red]LC_COLLATE=zh_CN.UTF-8[/color]
  7. LC_PAPER=en_US.UTF-8
  8. LC_NAME=en_US.UTF-8
  9. LC_NUMERIC=en_US.UTF-8
  10. SYSFONT=lat0-16
  11. LC_MEASUREMENT=en_US.UTF-8
  12. LC_TIME=en_US.UTF-8
  13. LANG=en_US.UTF-8
  14. LC_IDENTIFICATION=en_US.UTF-8
  15. LC_MESSAGES=en_US.UTF-8
复制代码
ps:LC_COLLATE是按照中文拼音排序,我也设为zh_CN.UTF-8

二、设置一下变量
/etc/X11/xinit/xinitrc或~/.xinitrc,不放心的话两个都加入
  1. export XMODIFIERS="@im=ibus"
  2. export XIM="ibus"
  3. export XINPUT="ibus"
  4. export XIM_PROGRAM="ibus"
  5. export GTK_IM_MODULE="ibus"
  6. export QT_IM_MODULE="ibus"
复制代码
ps:fcitx的话把ibus替换

三、开启桌面输入法进程
gnome的starup applications加入一项
  1. ibus-daemon -x -d
复制代码
fcitx忘了,好像是fcitx -d
kde在autostart里设置。

四、如果上面两步如果解决了问题,跳过此步
很多发行版/etc/X11下都有关于输入法的配置文件,很容易找到。
fcitx的话就把ibus替换掉。
# cat /etc/X11/xinit/XIM
  1. #!/bin/bash
  2. # read the user (~/.i18n) or system-wide (/etc/sysconfig/i18n) i18n settings
  3. . /etc/profile.d/10lang.sh
  4. # The Gnome applets must not be launched each time if they are already
  5. # managed by Gnome; here is the file path to the Gnome Applets config file;
  6. # so we can do a grep to see if a given applet is already managed by Gnome
  7. GNOME_APPLET_CONFIG="$HOME/.gnome/panel.d/default/Applet_Config"
  8. if [ -z "$XIM_PROGRAM" -a -z "$XIM" ]; then
  9.    locale=C
  10.    if [ ! -z "$LC_ALL" ]; then
  11.         locale=$LC_ALL
  12.    elif [ ! -z "$LC_CTYPE" ]; then
  13.         locale=$LC_CTYPE
  14.    elif [ ! -z "$LANG" ]; then
  15.         locale=$LANG
  16.    fi
  17.    case $locale in
  18.     zh_TW*)
  19.         export LC_CTYPE=zh_TW.Big5
  20.         XIM=ibus
  21.         ;;
  22.     zh_CN*)
  23.         XIM=ibus
  24.         ;;
  25.     ja*)
  26.         XIM=ibus
  27.         ;;
  28.     ko*)
  29.         XIM=ibus
  30.         ;;
  31.     *)
  32.         XIM=ibus
  33.         ;;
  34.    esac
  35. fi
  36. if [ -z "$XIM_PROGRAM" ]; then
  37.    case "$XIM" in
  38.     Chinput) XIM_PROGRAM=ibus ;;
  39.     xcin*) XIM_PROGRAM=ibus ;;
  40.     uim-*) XIM_PROGRAM=ibus ;;
  41.     kinput2) XIM_PROGRAM=ibus ;;
  42.     Ami)
  43.             # now ami determine which mode it will take from $DESKTOP variable
  44.         # (not from this script's first argument given by Xsession script)
  45.         # i think this way seems better.
  46.         # -- Jaegeum --
  47.         case $DESKTOP in
  48.         # Gnome init program automatically restore previous session's
  49.         # ami_applet. If you put ami_applet here, you may experience a lot of
  50.         # repeated error windows that report "an applet died abruptly".
  51.         # so we first check if the ami_applet is referenced in Gnome config
  52.         # files
  53.         # I think removing ` and ` around grep command is more reasonable.
  54.         # -- Jaegeum --
  55.         Gnome|GNOME|gnome)
  56.             if [ -f "$GNOME_APPLET_CONFIG" ] && \
  57.                 grep -q '\<ami_applet\>' "$GNOME_APPLET_CONFIG";
  58.             then
  59.                 XIM_PROGRAM=/bin/true
  60.             elif [ -x /usr/bin/ami_applet ]; then
  61.                 XIM_PROGRAM=ibus
  62.             else
  63.                 XIM_PROGRAM=ibus
  64.             fi ;;
  65.         # Now new wmami supports KDE2 docking mode.
  66.         # XIM_PROG_ARGS variable is added to send xim's arguments if
  67.         # they are needed.
  68.         # -- Jaegeum --
  69.         KDE|Kde|kde)
  70.                         XIM_PROGRAM=ibus;;
  71.         WindowMaker|WINDOWMAKER|Windowmaker|windowmaker)
  72.                         XIM_PROGRAM=ibus;;
  73.         # Following three WM entries should be added
  74.         # because that wmami supports them is already well known fact.
  75.         # -- Jaegeum --
  76.         AfterStep|AFTERSTEP|Afterstep|afterstep)
  77.                         XIM_PROGRAM=ibus;;
  78.         Enlightenment|ENLIGHTENMENT|enlightenment)
  79.                         XIM_PROGRAM=ibus;;
  80.         BlackBox|BLACKBOX|Blackbox|blackbox)
  81.                         XIM_PROGRAM=ibus;;
  82.         *)
  83.                         XIM_PROGRAM=ibus ;;
  84.         esac ;;
  85.     *) XIM_PROGRAM=/bin/true ;;
  86.    esac
  87. fi
  88. [ -z "$XMODIFIERS" -a -n "$XIM" ] && export XMODIFIERS="@im=$ibus"
  89. if which $XIM_PROGRAM >/dev/null 2>/dev/null
  90. then
  91.     # minichinput has problems running on utf-8 locales
  92.     if [ "$XIM_PROGRAM" = "chinput" ] ; then
  93.         case "$LANG" in
  94.             zh_TW*|zh_HK*) LANG=zh_TW LC_ALL=zh_TW chinput $XIM_PROG_ARGS &
  95.                 ;;
  96.             *) LANG=zh_CN LC_ALL=zh_CN chinput $XIM_PROG_ARGS &
  97.                 ;;
  98.         esac
  99.     else
  100.         $XIM_PROGRAM $XIM_PROG_ARGS &
  101.     fi
  102. fi
复制代码
ps:由于我不知道这样改会不会损失其他一些特性,所以第一二步解决问题就跳过此步。

重启。
回复 支持 反对

使用道具 举报

发表于 2009-6-3 20:27:36 | 显示全部楼层
字体都没有调节好呢 一片模糊一片清楚的 MDV09用自带字体安装程序安装字体是不能的!英文会变成挤在一起 搞不好会成竖的。。。。很郁闷 就放弃MDV了。。。小问题很多
回复 支持 反对

使用道具 举报

发表于 2009-6-3 20:47:10 | 显示全部楼层
Post by zaiqi;1993795
字体都没有调节好呢 一片模糊一片清楚的 MDV09用自带字体安装程序安装字体是不能的!英文会变成挤在一起 搞不好会成竖的。。。。很郁闷 就放弃MDV了。。。小问题很多


请详细说一下你安装字体的过程,使用的用户及如何安装的,看到很多人说2009.1安装字体后有问题,我没遇到这种问题,我装了win下常用的中文字体,目前使用的字体是雅黑,一切正常

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

发表于 2009-6-5 12:05:43 | 显示全部楼层
感觉截图的字体边缘有点虚啊。不如不做修改。
回复 支持 反对

使用道具 举报

发表于 2009-6-28 17:24:14 | 显示全部楼层
果然这样设置就能用ibus了,谢谢楼主!:thank
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-6-30 20:01:37 | 显示全部楼层
我自己用自己方法弄了一遍,不行,昏!主要是改了全局locale但是用户locale还是不生效。

用户locale更改要不全en_US.UTF-8,要不zh_CN.UTF-8。
而我喜欢英文环境,只要中文输入法和中文排序。症结在于不能对用户locale的每项细节分开设置。
回复 支持 反对

使用道具 举报

发表于 2009-7-4 17:02:00 | 显示全部楼层
Post by Jeff-cao;2001850
果然这样设置就能用ibus了,谢谢楼主!:thank


楼上的好运气,可惜我这样做了仍然在Qt程序中用不了ibus(GTK的程序可以用),并且升级了最新的ibus也不行。
PS:我试着改了QT_PLUGIN_PATH,也没有成功:help
回复 支持 反对

使用道具 举报

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

本版积分规则

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