• linux中安装中文字体


    转载地址:http://hintcnuie.javaeye.com/blog/661447

    可能是因为在安装linux的过程中忘记了选择支持中文,所以机器在安装完之后从Mozzila访问中文网站全是乱码,在“查看”菜单中即使选择GBK的编码字符集也无效,另外在shell中的中文也为乱码,openOffice打开之后也全为乱码。重装机器是个苦差事,不想那样做。于是我选择了对其进行汉化。

    第一步:

    修改文件/etc/sysconfig/i18n。将里面的en:US.UTF8修改成zh_CN.GB18030,修改后的内容如下:

    LANG="zh_CN.GB18030"

    LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"

    SUPPORTED="zh_CN.GB18030:zh_CN:zh"

    SYSFONT="lat0-sun16"

    SYSFONTACM="8859-15"

    第二步:

    安装中文字库。字库文件一般是独立于系统的,所以我选择了将windows下的字库文件安装到linux中去,windows中的字库文件位于C:\WINDOWS\Fonts下,选择其中的三个文件(simsun.ttc,tahoma.ttf ,tahomabd.ttf)。

    首先将这三个字库文件直接复制到linux分区的/usr/share/fonts/default/TrueType。这里主要涉及windows系统如何与linux系统交换数据的问题。可以将三个字库文件复制到windows的一个FAT32格式的分区中去,然后在linux中用命令:

    mount –t vfat –o iocharset=gb2312 /dev/hda6 /mnt/e

    其次我们要配置显卡文件(/etc/X11/XF86Config)。X中可以支持TrueType字体(一种可缩放的矢量字体,这些字体需要字体渲染引擎来读取。字体渲染引擎有很多种,xtt这种据说对中文支持很好,我们现在就是要配置指定用xtt这个字体渲染引擎去/usr/share/fonts /default/TrueType目录读取上面的三个字体文件的信息(如大小,分辩率,编码等)。修改其中的Section "Module"处,加入Load   “xtt”让其用使用xtt这个引擎,并注释掉与其冲突的#Load "freetype"与 #Load "type1"。另外,在Section "Files"处加入FontPath “/usr/share/fonts/default/TrueType”一句让xtt引擎去这个目录去找字库文件。修改后的部分文件如下:

        Section "Files"

    # RgbPath is the location of the RGB database. Note, this is the name of the

    # file minus the extension (like ".txt" or ".db"). There is normally

    # no need to change the default.

    # Multiple FontPath entries are allowed (they are concatenated together)

    # By default, Red Hat 6.0 and later now use a font server independent of

    # the X server to render fonts.

        RgbPath      "/usr/X11R6/lib/X11/rgb"

        FontPath     "unix/:7100"

        FontPath     “/usr/share/fonts/default/TrueType”

    EndSection

    Section "Module"

        Load "dbe"

        Load "extmod"

        Load "fbdevhw"

        Load "glx"

        Load "record"

    #Load "freetype"

    #Load "type1"

        Load "dri"

        Load   “xtt”

    EndSection

    最后,建立配置文件 fonts.dir与fonts.scale。方法很简单,在/usr/share/fonts/default/TrueType运行命令 ttmkfdir > fonts.dir即可生成一个有内容的fonts.scale的文件与一个空的fonts.dir。然后在fonts.scale中加入一行(别忘了修改第一行的那个数字):

    ds=y:ai=0.3:SimSun.ttf –misc-SimSun-bold-i-normal –-0-0-0-0-p-0-gbk-0

    接着,将fonts.scale复制一份到fonts.dir即可。(运行命令cp fonts.scale fonts.dir)

    最后,将/usr/x11R6/lib/X11/fonts/encodings/encoding.dir复制到/usr/share/fonts/default/TrueType中。

    重启机器,OK。

    ps:

    省略掉配置显卡的那一部分,中文也可以显示出来。

    RedHat Enterprise Linux 5 中文字体安装

    RedHat Enterprise Linux 5是RedHat新出的版本,现在需要在RHEL5下面用到一些中文的东西,NND,发现中文全是方框框,怎么办?重装?NO,经过仔细分析,发现是没有支持中文的字体,所以我想了想,就把我Vista下面的“宋体&新宋体”更新上去。过程如下:
    1,cd /usr/share/fonts
    2,mkdir truetype
    3,cd truetype
    4,mkdir simsun
    5,使用FTP或SFTP将Vista下的simsun.tcc文件传到/usr/share/fonts/truetype/simsun/目录中
    6,执行 mkfontscale
       生成了fonts.scale文件
    7,执行 mkfontdir
       生成了fonts.dir文件
    8,chkfontpath --add /usr/share/fonts/truetype/simsun/
    9,service xfs reload
    此时,使用Window方式登录,语言选择中文,即可正确显示中文了。

  • 相关阅读:
    word-wrap和word-break的区别
    transform 二维转变
    过渡
    新闻下滑导航案例
    background-origin,clip
    边框图片
    背景样式
    线性渐变与径向渐变与重复渐变
    边框阴影
    盒模型和圆角
  • 原文地址:https://www.cnblogs.com/qi09/p/1820939.html
Copyright © 2020-2023  润新知