Slackware 9.0的中文打印
时间:2003-08-06
来源:互联网
- 操作系统:Slackware 9.0
- 打印机:HP LaserJet 6L
- 打印服务程序:CUPS 1.1.18
- ghostscript 7.05
- Mozilla 1.4 中文版
说明:下面的操作几乎都需要root权限。
一、安装打印服务程序
Slackware 9.0 默认的打印服务程序是lpd,而现在更流行的是CUPS,设置也非常简单。可以到slackware下载的镜像站,在发行版本的 extra目录中下载,目前的版本是cups-1.1.18。用installpkg安装。
安装完毕后,会在/etc/rc.d/目录生成rc.cups文件,用root身份,运行 /etc/rc.d/rc.cups start ,即可启动cups打印服务。用浏览器访问 http://localhost:631/ 即可对cups和打印机进行设置,详情请看cups的文档。
添加打印机并成功打印出测试页之后,gedit和starsuite就直接能在我的HP LJ6L打印出中文。
二、设置ghostscript的中文支持
许多程序能够通过ghostscript生成postscript文件(.ps),如果能使ghostscript支持中文,就能够间接支持这些程序的中文打印。Slackware9.0自带的ghostscript是7.05版。
1. 下载CMap字体文件
ftp://ftp.gyve.org/pub/gs-cjk/adobe-cmaps-200211.tar.gz
ftp://ftp.gyve.org/pub/gs-cjk/acro5-cmaps-2001.tar.gz
把上面两个文件解压缩到/usr/share/ghostscript/Resource目录(如果没有这个目录,请自己mkdir)
cp adobe-cmaps-200211.tar.gz /usr/share/ghostscript/Resource
cp acro5-cmaps-2001.tar.gz /usr/share/ghostscript/Resource
tar zxvf adobe-cmaps-200211.tar.gz
tar zxvf acro5-cmaps-2001.tar.gz
rm *.gz
再建两个字体目录:
mkdir /usr/share/ghostscript/Resource/CIDFont /usr/share/ghostscript/Resource/Font
2.下载freetype-1.3.1(后面的ttfm需要)
http://sourceforge.net/project/showf...?group_id=3157
下载源码,自行编译安装,完成后运行 ldconfig 更新库文件索引
3. 下载ttfm
http://www.linuxeden.com/download/so...php?softid=650
下载 ttfm-1.0-6.i386.rpm 和 gscjk.ttfm
安装:
rpm -ivh ttfm-1.0-6.i386.rpm --nodeps
cp gscjk.ttfm /usr/share/fonts/install/
4.安装中文字体
我用的是ms windows提供的simsun.ttf, simhei.ttf, simkai.ttf 和simfang.ttf
把这四个字体放到 /usr/share/fonts/ttf目录中,也可以仅在这个目录里建立指向字体所在路径的符号链接。
然后:
cd /usr/share/fonts/install
ttfm.sh --initm gscjk.ttfm
这样就会在 /usr/share/ghostscript/Resource/CIDFont 和 /usr/share/ghostscript/Resource/Font 目录中生成对上面四种中文字体的描述文件。
5.让ghostscript启动时自动加载我们安装的中文字体
首先,修改 /usr/share/ghostscript/7.05/lib/gs_res.ps 文件,在其中找到这样两行:
/FontResourceDir (/usr/share/ghostscript/fonts/) readonly .forcedef
/GenericResourceDir (/usr/share/ghostcript/) readonly .forcedef
改为:
/FontResourceDir (/usr/share/ghostscript/Resource/Font/) readonly .forcedef
/GenericResourceDir (/usr/share/ghostscript/Resource/) readonly .forcedef
然后,建立CIDFnmap文件:
touch /usr/share/ghostscript/7.05/lib/CIDFnmap.zh
编辑这个文件,输入下面的内容:
/SimSun (/usr/share/fonts/ttf/simsun.ttf) 1 ; /SimHei (/usr/share/fonts/ttf/simhei.ttf) 1 ; /FangSong_GB2312 (/usr/share/fonts/ttf/simfang.ttf) 1 ; /KaiTi_GB2312 (/usr/share/fonts/ttf/simkai.ttf) 1 ; /Adobe-GB1 /SimSun ; /STSong-Light /SimSun ; /STFangsong-Light /FangSong_GB2312 ; /STHeiti-Regular /SimHei ; /STKaiti-Regular /KaiTi_GB2312 ;
最后,编辑/usr/share/ghostscript/7.05/lib/CIDFnmap,在文件末尾加入一行:
(CIDFnmap.zh) .runlibfile
6.测试
cd /usr/share/ghostscript/7.05/examples/cjk
gv gscjk_ag.ps
如果能看到四种字体的汉字,说明ghostscript简体中文字体设置成功。
三、设置mozilla支持中文打印
编辑 mozilla安装目录里面的/defauts/pref 目录下的 unix.js 文件,找到相应的行改成如下内容,如果没有这些行,自己增加。
pref("print.postscript.nativecode.zh-TW", "gbk");
pref("print.postscript.nativefont.zh-TW", "SimSun-GBK-EUC-H");
pref("print.postscript.nativecode.zh-CN", "gbk");
pref("print.postscript.nativefont.zh-CN", "SimSun-GBK-EUC-H");
完成后,存盘,重新启动mozilla。
如果直接让mozilla输出到打印机,中文不能正常打印而是以方框显示。因此需要采用间接的方法,打印时,选择打印到文件 mozilla.ps,然后:
ps2ps mozilla.ps out.ps
lpr out.ps
也可以先打印成mozilla.ps,然后选择菜单的“文件/打印/打印机属性”,在打印命令栏设定如下:
ps2ps mozilla.ps out.ps && lpr out.ps && rm mozilla.ps out.ps -f
以上命令输入一次后就不用再输入第二次了。再选直接打印到打印机,每次打印完后会把/home/USER目录下的mozilla.ps和out.ps文件删掉,以便下次打印其他文档。
这样就实现了mozilla的中文打印(谢谢kite兄指教)。
四、其他程序的中文打印
试验过gedit和starsuite6.0,均在安装cups并设置好打印机后,直接支持中文打印。
abiword的中文打印支持需另行设置,我没有测试,请参考最后附的参考文档。
其他的程序,如果直接打印不支持中文,可看看其是否有生成.ps文件的打印选项,然后尝试类似mozilla的方式进行打印。
基于qt的程序按上面的方法设置后似乎还不能支持中文打印,我测试过kedit,中文打印出来是乱码。
参考文档:《Slackware 8.1上的中文列印》
http://zope.slat.org/Members/Keanu/s...print.stx/view
作者: windrose 发布时间: 2003-08-06
作者: kite 发布时间: 2003-08-06
ps2ps mozilla.ps out.ps && lpr out.ps && rm mozilla.ps out.ps -f
以上命令输入一次后就不用再输入第二次了。然后选直接打印到打印机,每次打印完后会把/home/USER目录下的mozilla.ps和out.ps文件删掉,以便下次打印其他文档。
我记得以前在mozilla下不用这么麻烦的,设好打印命令,不用另现打印成ps,就点打印即可,我现在用mozillafirebird,不知是否不同。
作者: kite 发布时间: 2003-08-07
作者: windrose 发布时间: 2003-08-07
关于wprint,我是试用过,打印效果是惨不忍睹,很多漏字现象。
作者: kite 发布时间: 2003-08-07
繁体中文打印用文鼎字体才正常。
作者: windrose 发布时间: 2003-08-07
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=- -
作者: terminator 发布时间: 2003-12-18
ttfm-1.0-6.i386.rpm 和 ttfm-1.0.tar.gz可在ftp://cle.linux.org.tw/pub/CLE/devel/ttfm/处下载,将ttfm-1.0.tar.gz解压,在modules文件夹可取得gscjk.ttfm文件
该方法同样适用于fedora core 1,(ghostscript版本7.07 ,测试字体信息可用ggv)我已经测试成功,如果想得到pdf文件,用ps2pdf命令转换
Screenshot.png (92.7 KB, 265 次查看) |
作者: hupeng923 发布时间: 2004-02-27
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28