#! /bin/csh -f # # lpf-escp -- ESC/Pプリンタ用のフィルタ # # lpf-escp.text: テキストファイル出力用 (日本語コードの変換などを行う) # lpf-escp.bin: 入力をそのままプリンタに送る時に使う # lpf-escp.ps, lpf-escp.dvi: それぞれ ps, dviファイル用 # lpf-escp.small: 縮小印刷用 # # revision history: # 0.0: Jan. 5, 94 by Dai Ishijima # 1.0: Feb. 6, 96 # set path=(/usr/bin /bin /usr/local/bin) set prog=$0 set type=$prog:e set basename=$prog:r if (x$type == x) then foreach t (text bin ps dvi small) rm -f $basename.$t ln -s $prog $basename.$t end exit 0 endif # プリンタ初期化 # ESC @ リセット # ESC P ESC Q 80 用紙サイズを8インチに設定 # ESC P 10文字/インチ # ESC Q 80 用紙幅を80文字に # ESC l 5 左マージンを1/2インチ (5文字分) に設定 set init='\033@\033P\033Q\120\033l\005' # ESC x 0 高速 (ドラフト) 印字指定 # FS x 1 漢字高速印字指定 # ESC M エリートサイズ (12文字/インチ) 指定 # FS S 3 3 漢字の左右余白設定 set init="$init"'\033x0\034x1\033M\034S\003\003' # タブストップの設定 (ESC D): 8文字ごと set init="$init"'\033D\010\020\030\040\050\060\070\100\110\120\010' # 印刷後、改ページ (^L) してリセット (ESC @) set fin="\014\033@" set kin=`printf '\033$B'` set kout=`printf '\033(B'` set escp_kin=`printf '\034\\&'` set escp_kout=`printf '\034\\.'` printf "$init" if ($type == text) then nkf -j |\ sed -e 's/'"$kin"'/'"$escp_kin"'/g' -e 's/'"$kout"'/'"$escp_kout"'/g' else if ($type == ps) then gs -sDEVICE=epson -r180x180 -q -sOutputFile=- - else if ($type == dvi) then jdvi2kps | gs -sDEVICE=epson -r180x180 -q -sOutputFile=- - else if ($type == small) then nkf -s | slpr else if ($type == bin) then cat else cat endif printf "$fin"