Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FreeBSD 5.2.1-RC2 の a2ps-j の生成する postscript について

78 views
Skip to first unread message

NAKAGAWA. Yoshifumi

unread,
Feb 22, 2004, 7:26:08 AM2/22/04
to
仲川@滋賀と申します。

自宅で、FreeBSD 5.2.1-RC2 を利用しています。

% uname -a
FreeBSD zeus.my.domain 5.2.1-RC2 FreeBSD 5.2.1-RC2 #4: Sun Feb 22 02:22:40 JST
2004 ro...@zeus.my.domain:/usr/obj/usr/src/sys/INSPIRON i386

日本語のテキストファイルを印刷したいのですが、ports でインストールした a2ps-j
の出力する postscript ファイルで、本文の部分が日本語になりません。

具体的には、下記の words-e.txt の内容を、

% a2ps-j words-e.txt > words-e.ps

としたとき、日本語の部分が、

bl ( ) s kanji_init (%9%L!<%W) ks nl
bl ( ) s
(%W%m%;%C%5B&$N%-%c%C%7%e!&%a%b%j$H%a%$%s!&%a%b%j$N4V$G@09g@-0];}!J%9%L!<%W!K)

のようになっています。これを印刷すると、上記の%の文字が入った本文が出力されま
す。

尚、コマンドで

% nkf -e words-e.txt | a2ps-j > words-e.ps

とやってみても、同様でした。

LANGは、ja_JP.eucJP を指定しております。分かる方いらっしゃいましたら、教えて頂
けませんでしょうか?

(1)ファイルの内容(word-e.txt)
スヌープ
プロセッサ側のキャッシュ・メモリとメイン・メモリの間で整合性維持(スヌープ)

(2)生成された postscript ファイル

%!PS-Adobe-1.0
%%Title: words-e.txt
%%Creator: Id: a2ps,v 1.45 2001/05/28 07:25:46 utashiro Exp
%%CreationDate: Sun Feb 22 21:16:55 2004
%%Pages: (atend)
%%PageOrder: Ascend
%%DocumentPaperSizes: A4
%%Orientation: Landscape
%%EndComments

/$a2psdict 100 dict def
$a2psdict begin
% Initialize page description variables.
/inch {72 mul} bind def
%% SelectTray
statusdict /a4tray known { statusdict begin a4tray end } if
/landscape true def
/twinpage true def
/sheetheight 11.64 inch def
/sheetwidth 8.27 inch def
/lmargin 1.2 inch def
/smargin 1.2 inch def
/paper_adjust 0.05 inch def
/noborder false def
/noheader false def
/headersize 0.22 inch def
/nofooter false def
/nopunchmark true def
/bodyfontsize 6.6 def
/kanjiAsciiRatio 1 def
/lines 66 def
/columns 86 def
/date (Feb 22 2004 21:16) def
/doasciimag false def
%! PostScript Source Code
%
% File: imag:/users/local/a2ps/header.ps
% Created: Tue Nov 29 12:14:02 1988 by miguel@imag (Miguel Santana)
% Version: 2.0
% Description: PostScript prolog for a2ps ascii to PostScript program.
%
% Edit History:
% - Original version by evan@csli (Evan Kirshenbaum).
% - Modified by miguel@imag to:
% 1) Correct an overflow bug when printing page number 10 (operator
% cvs).
% 2) Define two other variables (sheetwidth, sheetheight) describing
% the physical page (by default A4 format).
% 3) Minor changes (reorganization, comments, etc).
% - Modified by tull...@apolloway.prl.philips.nl
% 1) Correct stack overflows with regard to operators cvs and copy.
% The resulting substrings where in some cases not popped off
% the stack, what can result in a stack overflow.
% 2) Replaced copypage and erasepage by showpage. Page througput
% degrades severely (see red book page 140) on our ps-printer
% after printing sheet 16 (i.e. page 8) of a file which was
% actually bigger. For this purpose the definitions of startdoc
% and startpage are changed.
% - Modified by Tim Clark <T.C...@uk.ac.warwick> to:
% 1) Print one page per sheet (portrait) as an option.
% 2) Reduce size of file name heading, if it's too big.
% 3) Save and restore PostScript state at begining/end. It now uses
% conventional %%Page %%Trailer markers.
% 4) Print one wide page per sheet in landscape mode as an option.
% - Modified by mig...@imag.fr to
% 1) Add new option to print n copies of a file.
% 2) Add new option to suppress heading printing.
% 3) Add new option to suppress page surrounding border printing.
% 4) Add new option to change font size. Number of lines and columns
% are now automatically adjusted, depending on font size and
% printing mode used.
% 5) Minor changes (best layout, usage message, etc).
% - Modified by kana...@sra.co.jp to:
% 1) Handle Japanese code
% - Modified by utas...@sra.co.jp to:
% 1) Fix bug in printing long label
% 2) Handle carriage-return
% 3) Specify kanji-ascii character retio
% 4) Add footer label
% 5) Change filename->fname becuase ghostscript has operator filename
% 6) Support three different font style
% 7) Incorporate B4 paper support and punchmark contributed
% by Masami Ueno <cab...@kki.esi.yamanashi.ac.jp>
%

% Copyright (c) 1988, Miguel Santana, mig...@imag.imag.fr
%
% Permission is granted to copy and distribute this file in modified
% or unmodified form, for noncommercial use, provided (a) this copyright
% notice is preserved, (b) no attempt is made to restrict redistribution
% of this file, and (c) this file is not distributed as part of any
% collection whose redistribution is restricted by a compilation copyright.
%


% General macros.
/xdef {exch def} bind def
/getfont {exch findfont exch scalefont} bind def

% Page description variables and inch function are defined by a2ps program.

% Character size for differents fonts.
landscape
{ /filenamefontsize 12 def }
{ /filenamefontsize 16 def }
ifelse
/datefontsize filenamefontsize 0.8 mul def
/headermargin filenamefontsize 0.25 mul def
/bodymargin bodyfontsize 0.7 mul def

% Font assignment to differents kinds of "objects"
/filenamefontname /Helvetica-Bold def
/stdfilenamefont filenamefontname filenamefontsize getfont def
/datefont /Helvetica datefontsize getfont def
/footerfont /Helvetica-Bold datefontsize getfont def
/mag { doasciimag { [ 1 0 0 asciimagsize 0 0 ] makefont } if } def
/bodynfont /Courier bodyfontsize getfont mag def
/bodybfont /Courier-Bold bodyfontsize getfont mag def
/bodyofont /Courier-BoldOblique bodyfontsize getfont mag def
/fontarray [ bodynfont bodybfont bodyofont ] def
/bodyfont bodynfont def

% Initializing kanji fonts
/kanji_initialized false def
/kanji_init {
kanji_initialized not
{
/bodykfontsize bodyfontsize kanjiAsciiRatio mul def
/bodyknfont /Ryumin-Light-H bodykfontsize getfont def
/bodykbfont /GothicBBB-Medium-H bodykfontsize getfont def
/bodykofont bodykbfont [ 1 0 .2 1 0 0 ] makefont def
/KanjiRomanDiff 1.2 bodyfontsize mul 1.0 bodykfontsize mul sub def
/KanjiRomanDiffHalf KanjiRomanDiff 2 div def
/kfontarray [ bodyknfont bodykbfont bodykofont ] def
/kanji_initialized true def
} if
} def

% Backspace width
/backspacewidth
bodyfont setfont (0) stringwidth pop
def

% Logical page attributs (a half of a real page or sheet).
/pagewidth
bodyfont setfont (0) stringwidth pop columns mul bodymargin dup add add
def
/pageheight
bodyfontsize 1.1 mul lines mul bodymargin dup add add headersize add
def

% Coordinates for upper corner of a logical page and for sheet number.
% Coordinates depend on format mode used.
% In twinpage mode, coordinate x of upper corner is not the same for left
% and right pages: upperx is an array of two elements, indexed by sheetside.
/rightmargin smargin 3 div def
/leftmargin smargin 2 mul 3 div def
/topmargin lmargin twinpage {3} {2} ifelse div def
landscape
{ % Landscape format
/punchx .4 inch def % for PunchMark
/punchy sheetwidth 2 div def % for PunchMark
/uppery rightmargin pageheight add bodymargin add def
/sheetnumbery sheetwidth leftmargin pageheight add datefontsize add sub def
twinpage
{ % Two logical pages
/upperx [ topmargin 2 mul % upperx for left page
dup topmargin add pagewidth add % upperx for right page
] def
/sheetnumberx sheetheight topmargin 2 mul sub def
}
{ /upperx [ topmargin dup ] def
/sheetnumberx sheetheight topmargin sub datefontsize sub def
}
ifelse
}
{ % Portrait format
/punchx .3 inch def
/punchy sheetheight 2 div def
/uppery topmargin pageheight add def
/upperx [ leftmargin dup ] def
/sheetnumberx sheetwidth rightmargin sub datefontsize sub def
/sheetnumbery
sheetheight
topmargin pageheight add datefontsize add headermargin add
sub
def
}
ifelse

% Strings used to make easy printing numbers
/pnum 12 string def
/empty 12 string def

% Other initializations.
datefont setfont
/datewidth date stringwidth pop def
/pagenumwidth (Page 999) stringwidth pop def
/filenameroom
pagewidth
filenamefontsize 4 mul datewidth add pagenumwidth add
sub
def


% Function startdoc: initializes printer and global variables.
/startdoc
{ /sheetside 0 def % sheet side that contains current page
} bind def

% Function setlabel: initialize label in header
/setlabel
{ stdfilenamefont setfont
/fname xdef
/filenamewidth fname stringwidth pop def
/filenamefont
filenamewidth filenameroom gt
{
filenamefontname
filenamefontsize filenameroom mul filenamewidth div
getfont
}
{ stdfilenamefont }
ifelse
def
} bind def

% Function printpage: Print a physical page.
/printpage
{ /sheetside 0 def
twinpage
{ sheetnumber }
{ noheader noborder not and
{ sheetnumber }
if
}
ifelse
showpage
% pagesave restore
% /sheet sheet 1 add def
} bind def

% Function cleanup: terminates printing, flushing last page if necessary.
/cleanup
{ twinpage sheetside 1 eq and
{ printpage }
if
} bind def

%
% Function startpage: prints page header and page border and initializes
% printing of the file lines. Page number is stored on the top of stack,
% and file name is next.
/startpage
{ /pagenum exch def
sheetside 0 eq
{ % /pagesave save def
landscape
{ sheetwidth 0 inch translate % new coordinates system origin
90 rotate % landscape format
paper_adjust neg 0 translate
} if
} if
noborder not { printborder } if
noheader not { printheader } if
nofooter not { printfooter } if
nopunchmark not { punchmark } if
upperx sheetside get bodymargin add
uppery
bodymargin bodyfontsize add noheader {0} {headersize} ifelse add
sub
moveto
} bind def

% Function printheader: prints page header.
/printheader
{ upperx sheetside get uppery headersize sub 1 add moveto
datefont setfont
gsave
datefontsize headermargin rmoveto
date show % date/hour
grestore
gsave
pagenum pnum cvs pop
pagewidth pagenumwidth sub
headermargin
rmoveto
(Page ) show pnum show % page number
grestore
empty pnum copy pop
gsave
filenamefont setfont
filenameroom fname stringwidth pop sub 2 div datewidth add
filenamefontsize 2 mul
add
headermargin
rmoveto
fname show % file name
grestore
} bind def

% Function printfooter: prints page footer.
/printfooter
{ upperx 0 get sheetnumbery moveto
footerfont setfont
fname show
} bind def

% Function printborder: prints border page.
/printborder
{ upperx sheetside get uppery moveto
gsave % print the four sides
pagewidth 0 rlineto % of the square
0 pageheight neg rlineto
pagewidth neg 0 rlineto
closepath stroke
grestore
noheader not
{ 0 headersize neg rmoveto pagewidth 0 rlineto stroke }
if
} bind def

% Punch Marker
/punchmark {
gsave
newpath punchx punchy moveto
punchx 2 add punchy -0.5 add lineto
punchx 2 add punchy 0.5 add lineto
punchx punchy lineto
closepath
0 setgray .8 setlinewidth stroke
grestore
} bind def

%
% Function endpage: adds a sheet number to the page (footnote) and prints
% the formatted page (physical impression). Activated at the end of each
% source page (lines reached or FF character).
/endpage
{ twinpage sheetside 0 eq and
{ /sheetside 1 def }
{ printpage }
ifelse
} bind def

% Function sheetnumber: prints the sheet number.
/sheetnumber
{ sheetnumberx sheetnumbery moveto
datefont setfont
sheet pnum cvs
dup stringwidth pop (0) stringwidth pop sub neg 0 rmoveto show
empty pnum copy pop
} bind def

% Function bs: go back one character width to emulate BS
/bs { backspacewidth neg 0 rmoveto } bind def

% Function s: print a source string
/s { fontarray fonttype get setfont
show
} bind def

% Function ks: print a kanji source string
/ks { kfontarray fonttype get setfont
KanjiRomanDiffHalf 0 rmoveto
KanjiRomanDiff 0 3 -1 roll ashow
KanjiRomanDiffHalf neg 0 rmoveto
} def

% Function bl: beginning of line
/bl { gsave } bind def

% Function nl: newline
/nl {
grestore
0 bodyfontsize 1.1 mul neg rmoveto
} bind def

% Function cr: carriage return
/cr { grestore } bind def

% Function hlr: half-line up
/hlr { 0 bodyfontsize 0.55 mul rmoveto } bind def

% Function hlr: half-line down
/hlf { 0 bodyfontsize 0.55 mul neg rmoveto } bind def

% Function hlr: half-character backward
/hcr { backspacewidth 2 div neg 0 rmoveto } bind def

% Function hlr: half-character forward
/hcf { backspacewidth 2 div 0 rmoveto } bind def

/R { /fonttype 0 def } bind def
/B { /fonttype 1 def } bind def
/I { /fonttype 2 def } bind def
R
/docsave save def
startdoc
%%EndProlog

%%Page: 1 1
/sheet 1 def
(words-e.txt) setlabel
1 startpage
bl ( ) s kanji_init (%9%L!<%W) ks nl
bl ( ) s
(%W%m%;%C%5B&$N%-%c%C%7%e!&%a%b%j$H%a%$%s!&%a%b%j$N4V$G@09g@-0];}!J%9%L!<%W!K)
ks endpage

cleanup
%%Trailer
docsave restore end


---
NAKAGAWA. Yoshifumi
mail-to: yosi...@fides.dti.ne.jp

NIDE Naoyuki

unread,
Feb 22, 2004, 9:48:32 AM2/22/04
to
In article <20040222212608.6...@fides.dti.ne.jp>,

yosi...@fides.dti.ne.jp writes:
> 日本語のテキストファイルを印刷したいのですが、ports でインストールした a2ps-j
> の出力する postscript ファイルで、本文の部分が日本語になりません。

手元のRedHat Linux 7.1, kernel 2.4.20-28.7, a2ps 1.45, perl 5.6.0でも
そんな出力になります。で、PostScriptプリンタにはちゃんと日本語として出ま
すし、ghostviewでも日本語として見えます。
従って、a2psがおかしいのではないと思います。ghostscript経由でプリンタ
に出しているなら、ghostscriptが日本語化されていないか設定がまずい、
PostScriptプリンタであるならそのプリンタがa2psの出力と愛称が悪い、という
ことになろうかと思います。後者である場合は、ps2psを通すと印刷できるかも
知れません。
なお、ps2psを使う場合、状況に応じて -dLanguageLevel=1 といったオプショ
ンを試してみるといいそうです。そういった話については、最近、fj.comp.
texhaxとfj.comp.lang.postscriptで2回立て続けに話題になりました。

ni...@ics.nara-wu.ac.jp

ca...@xxx.kgc.co.jp

unread,
Feb 22, 2004, 7:02:54 PM2/22/04
to
"NAKAGAWA. Yoshifumi" <yosi...@fides.dti.ne.jp> writes:

> 自宅で、FreeBSD 5.2.1-RC2 を利用しています。
>
> % uname -a
> FreeBSD zeus.my.domain 5.2.1-RC2 FreeBSD 5.2.1-RC2 #4: Sun Feb 22 02:22:40 JST
> 2004 ro...@zeus.my.domain:/usr/obj/usr/src/sys/INSPIRON i386
>
> 日本語のテキストファイルを印刷したいのですが、ports でインストールした a2ps-j
> の出力する postscript ファイルで、本文の部分が日本語になりません。

添付の ps をうちの gs で見ましたが、日本語出てます。

ports/japanese/ghostscript-gnu-jpnfont は入れましたか?

神田敏広 <ca...@kgc.co.jp>

Kawaguti Ginga

unread,
Feb 22, 2004, 9:02:16 PM2/22/04
to
川口です

他の方からも指摘がありますが

<20040222212608.6...@fides.dti.ne.jp>の記事において
yosi...@fides.dti.ne.jpさんは書きました。


> % uname -a
> FreeBSD zeus.my.domain 5.2.1-RC2 FreeBSD 5.2.1-RC2 #4: Sun Feb 22 02:22:40 JST
> 2004 ro...@zeus.my.domain:/usr/obj/usr/src/sys/INSPIRON i386
>
> 日本語のテキストファイルを印刷したいのですが、ports でインストールした a2ps-j
> の出力する postscript ファイルで、本文の部分が日本語になりません。

"postscript ファイルの本文が日本語にならない" のではなく,
日本語な postscript を処理する環境(?)に問題があるのでは
ないでしょうか?

なにを試してなにで駄目なのか,をもうすこし整理しましょう.
(どこそこの ps printer は駄目だった,
gs のversion xx では X11 表示がどうだった,etc.)
--
∧∧
Zzz.. (- - )⌒⌒⊇~ 川口 銀河
############## ginga-fj-s...@ginganet.org

NAKAGAWA. Yoshifumi

unread,
Feb 23, 2004, 10:50:21 AM2/23/04
to
仲川@滋賀です。

NIDEさん、神田さん、川口さん、フォローありがとうございます。

On 23 Feb 2004 09:02:54 +0900
ca...@xxx.kgc.co.jp wrote:

> 添付の ps をうちの gs で見ましたが、日本語出てます。
>
> ports/japanese/ghostscript-gnu-jpnfont は入れましたか?

上記 ports ガうまく入っていなかったようで、上記フォントを Reinstall したら gs
でも、印刷でも日本語が表示されました。単純な話でお騒がせしました。

成程、a2ps ではなくて、ps を処理する環境の方だったのですね。

普段、portupgrade を利用しているのですが、そういえば、ghostscript 関係は何回か
依存関係が崩れたことがあります。たぶん、pkgdb -F で無理矢理依存関係の整合を
とったりしていたので、その過程で壊してしまったのかもしれません。

おかげ様で、印刷環境が整いました。

本当にありがとうございました。

0 new messages