[轉貼]現在的中文列印

常言道:『飲水思源』,在 Open Source 的世界裡,我們常常需要別人的幫助,但是在您有所心得的時候請記得分享給大家,『幫助人是快樂的喔』。歡迎您在使用 debian 的過程中的任何心得分享給大家。

[轉貼]現在的中文列印

文章moto » 週四 2月 13, 2003 2:16 pm

作者: statue (statue) 看板: ft.chinese
標題: 現在的中文列印
時間: Mon Jun 3 14:18:58 2002

http://freebsd.sinica.edu.tw/~statue/in ... e=20020527

現在的中文列印
目前的中文顯示已經算是完備,我們平常需求的粗體與斜體都能正常顯示,
利用 -medium-r 對應普通字型,-bold-r 對應粗體,-medium-i 對應斜體,
-bold-i 對應粗斜體。

由於 print/ghostscript-gnu 從 6.53 升級到 7.05,相對應的
chinese/ghostscript6 與 print/ghostscript-gnu-cjk(gs-cjk) 也都 BROKEN,
中文列印就成了一個問題,不過,原來 gs-cjk 已經融入 7.05,
而且增加的方式更是簡單,以下用 mozilla 的中文列印來說明
只要修改 /usr/local/share/ghostscript/7.05/lib/CIDFnmap 最後增加

=== start file ===
(CIDFnmap.zh) .runlibfile
=== end file ===

接著新增 /usr/local/share/ghostscript/7.05/lib/CIDFnmap.zh

=== start file ===
% Chinese Truetype Fonts (Arphic)
/ZenKai-Medium (/usr/local/share/fonts/TrueType/bkai00mp.ttf) 1 ;
/ShanHeiSun-Light (/usr/local/share/fonts/TrueType/bsmi00lp.ttf) 1 ;
%
% Convenient aliases for PS files on Chinese PostScript printer
%
/B5-H /ZenKai-Medium ;
/ETen-B5-H /ZenKai-Medium ;
/B5-H /ShanHeiSun-Light ;
/ETen-B5-H /ShanHeiSun-Light ;
%
% CID fontmap for chinese-big5 encoding CIDFontName
%
/MSung-Light /ShanHeiSun-Light ;
/MHei-Medium /ZenKai-Medium ;
/MOESung-Regular /ShanHeiSun-Light ;
/MOEKai-Regular /ZenKai-Medium ;
=== end file ===

mozilla 僅有普通字體

接著修改 /usr/X11R6/lib/mozilla/defaults/pref/unix.js 最後增加

pref("print.postscript.nativecode.zh-TW", "big5");
pref("print.postscript.nativefont.zh-TW", "MSung-Light-B5-H");
用 mozilla 開網頁,選取列印,然後用 /usr/ports/print/gv 來觀看,
這樣子就會看到中文的 ps 囉

不過可以看到,並沒有粗體與斜體的相關設定,筆者在 CIDFnmap 並沒有找到
粗體與斜體的相關設定,不過這對 mozilla 而言是足夠的

why MSung-Light

MSung-Light 與 MHei-Medium 則是許多軟體預設的 CID fontmap,
都把他連到 ShanHeiSun-Light 與 ZenKai-Medium

ShanHeiSun-Light 的來源是 ttfinfo /usr/local/share/fonts/TrueType/bsmi00lp.ttf

的 TTFINFO_FONT_PSNAME="ShanHeiSun-Light"

TTFINFO_FONT_FILE="/usr/local/share/fonts/TrueType/bsmi00lp.ttf"
TTFINFO_FONT_NAME="AR PL Mingti2L Big5"
TTFINFO_FONT_PSNAME="ShanHeiSun-Light"
TTFINFO_FOUNDRY_NAME="Arphic"
TTFINFO_WEIGHT_NAME="medium"
TTFINFO_WIDTH="normal"
TTFINFO_NUMCMAP="2"
TTFINFO_CMAP0="1,0"
TTFINFO_CMAPNAME0="Apple,Roman"
TTFINFO_CMAP1="3,1"
TTFINFO_CMAPNAME1="Windows,Unicode"
TTFINFO_MAPNUM="1"
TTFINFO_FONTMAP1="-Arphic-AR PL Mingti2L Big5-medium-r-normal--0-0-0-0-c-0-big5-
0"

目前已經有類似的 ports,/usr/ports/japanese/ghostscript-gnu-jpnfont/
剛我也 send-pr 去修改 /usr/ports/print/ghostscript-gnu-commfont 了

測試
% cat cid.ps
/MSung-Light-B5-H findfont 60 scalefont setfont
50 600 moveto (2002年 5月29日) show
/MHei-Medium-B5-H findfont 60 scalefont setfont
50 520 moveto (2002年 5月29日) show
/MOESung-Regular-B5-H findfont 60 scalefont setfont
50 440 moveto (2002年 5月29日) show
/MOEKai-Regular-B5-H findfont 60 scalefont setfont
50 360 moveto (2002年 5月29日) show
showpage
quit
% gv -antialias cid.ps
% ps2pdf cid.ps
% xpdf cid.pdf (目前有問題!)

snapshot: http://freebsd.sinica.edu.tw/~statue/news/20020527.png

以下是 mozilla.ps 的 zh_TW 區段,mozilla 的列印正常

=== start file ===
/Unicode2NativeDictzh-TW 0 dict def
/zh-TW_ls {
/NativeFont /MSung-Light-B5-H def
/UCS2Font /Courier def
/Unicode2NativeDict Unicode2NativeDictzh-TW def
/unicodeshow1 { real_unicodeshow } bind def
/unicodeshow2 { real_unicodeshow_native } bind def
} bind def
=== end file ===

kword 仍然有問題

以下是 kword.ps 的 zh_TW 區段,kde3 的 kword 列印仍然有問題

=== start file ===
%%BeginSetup
% Fonts and encodings used
/MSung-Light-B5-HList [
[ /MSung-Light-B5-H 1 0 ]
[ /MOESung-Regular-B5-H 1 0 ]
[ /Helvetica 1.18991 0 ]
] d
% Asian postscript font requested. Using MSung-Light-B5-H
/MSung-Light-B5-HList [
[ /MSung-Light-B5-H 1 0.2 ]
[ /MOESung-Regular-B5-H 1 0.2 ]
[ /Helvetica-Oblique 1.18991 0 ]
] d
% Asian postscript font requested. Using MSung-Light-B5-H
/MSung-Light-B5-HList [
[ /MSung-Light-B5-H 1 0 ]
[ /MOESung-Regular-B5-H 1 0 ]
[ /Helvetica-Bold 1.12803 0 ]
] d
% Asian postscript font requested. Using MSung-Light-B5-H
/F1 30.375/MSung-Light-B5-H-Uni DF
/F2 30.375/MSung-Light-B5-H-Uni DF
/F3 30.375/MSung-Light-B5-H-Uni DF
%%EndSetup
=== end file ===

但是用 gs 來看就會有如下的錯誤訊息

=== start msg ===
GNU Ghostscript 7.05 (2002-04-22)
Copyright (C) 2002 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Can't find (or can't open) font file /usr/local/share/ghostscript/Resource/Font/
MSung-Light-B5-H-Uni.
Can't find (or can't open) font file MSung-Light-B5-H-Uni.
Substituting font Courier for MSung-Light-B5-H-Uni.
Loading NimbusMonL-Regu font from /usr/local/share/ghostscript/fonts/n022003l.pfb... 18883696 17394664 1743000 367192 0 done.
Can't find (or can't open) font file /usr/local/share/ghostscript/Resource/Font/
MSung-Light-B5-H-Uni.
Can't find (or can't open) font file MSung-Light-B5-H-Uni.
Substituting font Courier for MSung-Light-B5-H-Uni.
Can't find (or can't open) font file /usr/local/share/ghostscript/Resource/Font/
MSung-Light-B5-H-Uni.
Can't find (or can't open) font file MSung-Light-B5-H-Uni.
Substituting font Courier for MSung-Light-B5-H-Uni.
>>showpage, press to continue<<
=== end msg ===

fonts.dir 的粗體與斜體
回過頭來看 fonts.dir 的設定方式

bsmi00lp.ttf -Arphic-AR PL Mingti2L Big5-以下略
ai=0.3:bsmi00lp.ttf -Arphic-AR PL Mingti2L Big5-以下略
ds=y:bsmi00lp.ttf -Arphic-AR PL Mingti2L Big5-以下略
ds=y:ai=0.3:bsmi00lp.ttf -Arphic-AR PL Mingti2L Big5-以下略

第一個是正常的字體。
ai 代表 Automatic Italic 會造成斜體。後面的數字是傾斜比例。
ds 代表 Double Strike 會造成偽粗體。y 代表 yes,表示要粗體。
兩個一起用就變成粗斜體了。

當然,以上在 ttfm 的模組應該都會自動產生,但也可以自己去手動
調整。也可以利用 fs=p 來調整成調合字(proportional font)。另外,
要使用 MS 的新細明,可以加上 eb=y 來強迫 FreeType 去使用內嵌
於字型內的點陣字(會比 AA 好看,不過這個功能不是很穩定)。

gscjk 的粗體與斜體
以文鼎宋體為例,PSNAME 是 ShanHeiSun-Light,而我們常用的 CMap 是
ETen-B5-H,所以 gscjk 的字型就會有 'ShanHeiSun-Light-ETen-B5-H'、
'ShanHeiSun-Light-Bold-ETen-B5-H'、'ShanHeiSun-Light-Italic-ETen-B5-H'、
'ShanHeiSun-Light-BoldItalic-ETen-B5-H',Bold 是粗體,Italic 是斜體,
BoldItalic 是粗斜體,這樣就有了我們常用的字體了。

接著,gscjk 就會在 /usr/local/share/ghostscript/Resource/CIDFont/
底下產生 ShanHeiSun-Light ShanHeiSun-Light-Bold ShanHeiSun-Light-BoldItalic
ShanHeiSun-Light-Italic,並在 /usr/local/share/ghostscript/Resource/Font/
底下產生與繁體中文 CMap 相結合的字型。

在此的產生方式是透過 ttfm.sh 的 gscjk module,可以直接使用 ports 中的版本,
檢察 /usr/local/share/ttfm 底下是否有 gscjk.ttfm 即可,ttfm 的使用方式
則自己參考 manual 或是網頁

=== start file ===
/ShanHeiSun-Light-B5-H findfont 60 scalefont setfont
50 600 moveto (2002年 5月29日) show
/ShanHeiSun-Light-Bold-B5-H findfont 60 scalefont setfont
50 520 moveto (2002年 5月29日) show
/ShanHeiSun-Light-Italic-B5-H findfont 60 scalefont setfont
50 440 moveto (2002年 5月29日) show
/ShanHeiSun-Light-BoldItalic-B5-H findfont 60 scalefont setfont
50 360 moveto (2002年 5月29日) show
showpage
quit
=== end file ===

snapshot: http://freebsd.sinica.edu.tw/~statue/ne ... 0527-2.png


abiword 的粗體與斜體
abiword 也同樣的可以列印粗體與斜體。abiword 的字型目錄在
/usr/X11R6/share/AbiSuite/fonts,在其內先建立 zh-TW 目錄
接著只要利用 ttf 來建立 fonts.dir 就可以了。

格式如下:

PSFONT, TTFFONT, 880, 120, 1000

所以就建立如下的 fonts.dir

=== start file ===
4
ShanHeiSun-Light-ETen-B5-H, -Arphic-AR PL Mingti2L Big5-medium-r-normal--0-0-0-0
-c-0-big5-0, 880, 120, 1000
ShanHeiSun-Light-Bold-ETen-B5-H, -Arphic-AR PL Mingti2L Big5-bold-r-normal--0-0-
0-0-c-0-big5-0, 880, 120, 1000
ShanHeiSun-Light-Italic-ETen-B5-H, -Arphic-AR PL Mingti2L Big5-medium-i-normal--
0-0-0-0-c-0-big5-0, 880, 120, 1000
ShanHeiSun-Light-BoldItalic-ETen-B5-H, -Arphic-AR PL Mingti2L Big5-bold-i-normal
--0-0-0-0-c-0-big5-0, 880, 120, 1000
=== end file ===

利用 -medium-r 對應普通字型,-bold-r 對應 -Bold,-medium-i 對應 -Italic,
-bold-i 對應 -BoldItalic。
不過我都還必須在 zh-TW 底下 touch .already-in-fp,abiword 才不會說
Abiword could not load the following font or fontset from the X Window System di
splay server:
[-*-Times New Roman-regular-r-*-*-*-0-*-*-*-*-*-*]

FYI
http://www.cs.wisc.edu/~ghost/doc/gnu/7.05/CJK.htm
Usage of features to support CJK CID-keyed fonts in Ghostscript.
http://www.cs.wisc.edu/~ghost/doc/gnu/7.05/CJKTTCID.htm
Note providing information on utilization of CJK (Chinese, Japanese and
Korean) TrueType fonts as CIDFontType2 fonts from the viewpoint of its
validity and limitations.
--
※ Origin: 碩誠 Linux 資訊站 <bbs.sayya.org>
◆ From: u8-177.u203-204.giga.net.tw
※ X-Info: SJH -> SJH.bbs@bbs.ice.cycu.edu.tw
※ X-Sign: 0UGEN34/mV4uqEibya.w (02/06/12 22:36:20 )
頭像
moto
摩托學園站長
摩托學園站長
 
文章: 2808
註冊時間: 週二 9月 03, 2002 3:37 am
來自: 台北

回到 share

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客