发新话题
打印

Slackware gs/ghostscript + Chinese mini-HOWTO

Slackware gs/ghostscript + Chinese mini-HOWTO

Print Chinese with ghostscript and view Chinese with gv mini-Howto


(1) Software requirements:
   Install ghostscript (espgs-7.05.6), font (gnu-gs-fonts) and
ghostview (gv) packages


(2) Font requirements:
   Install SimSun, SimHei and other Chinese TTF fonts to XFree86
TTF font dir


(3) Hack the ghostscript:

   Backup file /usr/share/ghostscript/7.05/lib/CIDFnmap, then
modify it as follows:
    %(CIDFnmap.Win) .runlibfile
    % Add the following line
    (CIDFnmap.zhcn) .runlibfile

   Add file /usr/share/ghostscript/7.05/lib/CIDFnmap.zhcn as
follows:
------------------- cut here -------------------------------------------
/SimSun     (simsun.ttc)        ;
/STSong-Light           /SimSun         ;   
/Beijing                /SimSun         ;   
/NSimSun    (simsun.ttc)    2   ;
/Adobe-GB1              /SimSun         ;   
/song                   /SimSun         ;   
/zycjksun               /SimSun         ;   

/SimHei     (simhei.ttf)        ;
/STHeiti-Regular        /SimHei         ;
/hei                    /SimHei         ;
/zycjkhei               /SimHei         ;   

/SimFang    (simfang.ttf)       ;
/FangSong               /SimFang        ;   
/STFangsong-Light       /SimFang        ;   
/fang                   /SimFang        ;   
/zycjkfang              /SimFang        ;   

/SimKai     (simkai.ttf)        ;
/KaiTi                  /SimKai         ;   
/STKaiti-Regular        /SimKai         ;   
/kai                    /SimKai         ;   
/zycjkkai               /SimKai         ;   

/FZFangSong (fzfsjw.ttf)        ;
/FZWeiBei   (fzwbjw.ttf)        ;
/FZKai      (fzktjw.ttf)        ;
/FZShuTi    (fzstjw.ttf)        ;

/SIL-FangSong-          /STFangsong-Light   ;
/SIL-FangSong-Reg-Jian  /STFangsong-Light   ;
/SIL-Hei-Med-Jian       /STHeiti-Regular    ;
/SIL-Kai-               /STKaiti-Regular    ;
/SIL-Kai-Reg-Jian       /STKaiti-Regular    ;
/SIL-Song-Reg-Jian      /STSong-Light       ;
------------------- cut here -------------------------------------------

   Backup /usr/share/ghostscript/7.05/lib/gs_res.ps, then modify
it as follows:

    Find the following line
       /GenericResourceDir (/usr/share/ghostscript/) readonly .forcedef
    Replace it with the following line
       /GenericResourceDir (/usr/share/ghostscript/Resource/) readonly .forcedef


(4) Add Adobe CMAP for CID fonts to ghostscript

    Download ac14.tar.Z and ag14.tar.Z from the following link:
    ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/adobe/

    Execute the following commands:
    # cd /usr/share/ghostscript/
    # mkdir Resource
    # cd Resource
    # mkdir CMap
    # tar -zxvf /tmp/ac14.tar.Z
    # tar -zxvf /tmp/ag14.tar.Z
    # cp ac14/CMap/* ag14/CMap/* CMap
    # rm -rf ac14 ag14

    Alternatively, if you want the latest Adobe CMAP files, download
"Complete set of Adobe CMAP files for CID Fonts" in the "Adobe Font
Development Kit for OpenType" from adobe.com:
    http://partners.adobe.com/asn/tech/type/otfdk/index.jsp

    Execute the following commands:
    # cd /usr/share/ghostscript/
    # mkdir Resource
    # cd Resource
    # mkdir CMap
    # unzip /tmp/Adobe\ Cmaps.zip
    # cp Adobe\ Cmaps/Adobe-CNS1-2/* Adobe\ Cmaps/Adobe-CNS1-3/* \
      Adobe\ Cmaps/Adobe-CNS1-4/* Adobe\ Cmaps/Adobe-GB1-3/* \
      Adobe\ Cmaps/Adobe-GB1-4/* Adobe\ Cmaps/Adobe-Identity-0/* \
      CMap
    # rm -rf Adobe\ Cmaps

    Then create symbol links of the TrueType fonts in the ghostscript
fonts directory. I have tried to specify the full path of TrueType fonts
in CIDFnmap.zhcn instead of creating symbol links. However, it can only
make gv display Chinese. It's impossible to print Chinese!!!

    # cd /usr/share/ghostscript/fonts
    # ln -s /usr/X11R6/lib/X11/fonts/TTF/sim* .
    # ln -s /usr/X11R6/lib/X11/fonts/TTF/fz* .


(5) Hack Mozilla/Firebird preference file:
    Modify mozilla/default/pref/unix.js as follows:

    Look for the following line:
        pref("print.postscript.nativefont.zh-CN", "");

    Replace it with the following line:
        pref("print.postscript.nativecode.zh-CN", "gb2312");
        pref("print.postscript.nativefont.zh-CN", "SimSun-GB-EUC-H");

(6) Testing
    To view the mozilla.ps, use the following
    % gv mozilla.ps

    To test the mozilla.ps before send it to printer, use the following
command:
     % cat mozilla.ps | gs -q -dBATCH -dPARANOIDSAFER -dQUIET -dNOPAUSE -sDEVICE=x11 -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792 -dDuplex=true -dTumble=false -r300  -sOutputFile=- -      

TOP

发新话题