Path: galaxy.trc.rwcp.or.jp!news.trc!imnet3!nspixp2!newsfeed1.dti.ad.jp!newsfeed2.dti.ad.jp!dnews0.dti2.ne.jp!dnews1.dti.ne.jp.POSTED!not-for-mail
Sender: endo-h@KYTOMA
Newsgroups: fj.comp.lang.perl,fj.comp.lang.postscript,fj.sources.d
Subject: unofficial patch for a2ps.pl-1.43-pre1 (was: a2ps.pl-1.43-pre1)
References: <19990110234830V.utashiro@iij.ad.jp>
X-Emacs: Emacs 20.2, MULE 3.0 (MOMIJINOGA), Meadow-1.00 (MIDORI)
MIME-Version: 1.0 (generated by SEMI 1.5.2 - "Kurobe")
Content-Type: text/plain; charset=ISO-2022-JP
From: Hideyuki Endo <endo-h@remus.dti.ne.jp>
Message-ID: <wk678jwv3g.fsf@remus.dti.ne.jp>
Lines: 407
X-Newsreader: Semi-gnus 6.4.0 (based on Gnus 5.6.11; for SEMI 1.5)
Date: 03 Mar 1999 04:27:15 +0900
NNTP-Posting-Host: 210.159.167.114
X-Complaints-To: abuse@dti.ad.jp
X-Trace: dnews1.dti.ne.jp 920402916 210.159.167.114 (Wed, 03 Mar 1999 04:28:36 JST)
NNTP-Posting-Date: Wed, 03 Mar 1999 04:28:36 JST
Organization: Dream Train Internet
Xref: galaxy.trc.rwcp.or.jp fj.comp.lang.perl:1072 fj.comp.lang.postscript:208 fj.sources.d:3329
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.sources.d&nb=3329&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.

$B$($s$I$&$G$9(B

$B2NBe$5$s$N(Bperl$BHG(Ba2ps$B$r$A$g$C$H$$$8$C$F$_$^$7$?!#(B
$B2NBe$5$s$K%a!<%k$7$h$&$+$H$b;W$C$?$N$G$9$,!"(BComment Please$B$H1>$&$3$H$G%](B
$B%9%H$7$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;
 ;#
+;# Select the fonts for filename, date, sign and footer.
+;# (Helvetica, Helvetica-Bold, Times-Roman, Times-Bold etc..)
+;#
+;;$filenamefont= 'Times-Bold';
+;;$datefont= 'Times-Roman';
+;;$signfont= 'Times-Roman';
+;;$footerfont= 'Times-Roman';
+;#
+;# Change the default style parameters.
+;#
+;;$baselineskip = 1.0;# (original: 1.1)
+;;$borderwidth = 0.1;# width of surrounding border 
+;;$headergray = 0.95;# gray value of header area
+;;$numformat = '%-5d '; # format of line numbering
+;#
 ;# WISH LIST
 ;#- better algorithm to determine frame size (buggy on big font)
 ;#- print toc matched pattern at the bottom of pages
@@ -75,7 +90,7 @@
 $show_punchmark = 0;
 $tab_w = 8;
 $skip_column = 1;
-$numformat = '%-5d ';
+#$numformat = '%4d  ';
 $oblique = 1;
 $bold = 1;
 $kanji_ascii_ratio = 1.0;
@@ -90,76 +105,13 @@
 @font{'n', 'b', 'u'} = ('C', 'B', 'O');# normal, bold, underline
 @font_number{'C', 'B', 'O'} = (0, 1, 2);# Courier, Bold, Oblique
 
-while ($_ = $ARGV[0], s/^-(.+)$/$1/ && shift) {
-    next if $_ eq '';
-    if (s/^help$//){&usage;next;}
-    if (s/^basename$//){$basename++;next;}
-    if (s/^(us|a4|b4)$//i){&paper($paper="\L$1");next;}
-    if (s/^l(.*)$//){defined($label=$1||shift)||&usage;next;}
-    if (s/^L(.*)$//){defined($sublabel=$1||shift)||&usage;next;}
-    if (s/^toc$//){defined($toc=shift)||&usage;next;}
-
-    if (s/^k([\d\.]+)//){$kanji_ascii_ratio=$1;redo;}
-    if (s/^f([\d\.]+)//){$font_size=$1;redo;}
-    if (s/^fx([\d\.]+)//){$font_mag=$1;redo;}
-    if (s/^f([nbu])(.*)//){defined($font_number{$font{$1}=$2||shift}) ||
- &usage;redo;}
-    if (s/^j([\d\.]*)//){$ascii_mag=$1||1.2;redo;}
-    if (s/^d(\d*)//){$debug=$1||1;redo;}
-
-    if (s/^(n?)m//){$show_punchmark= !$1;redo;}
-    if (s/^(n?)h//){$show_header= !$1;redo;}
-    if (s/^(n?)s//){$show_border= !$1;redo;}
-    if (s/^(n?)t//){$show_footer= !$1;redo;}
-    if (s/^(n?)C//){$selfconvert= !$1;redo;}
-    if (s/^(n?)w//){$wide_pages= !$1;redo;}
-    if (s/^(n?)c//){$jisconvert= !$1;redo;}
-    if (s/^(n?)v//){$visualize= !$1;redo;}
-    if (s/^(n?)p//){$portrait= !$1;redo;}
-    if (s/^(n?)f//){$folding= !$1;redo;}
-    if (s/^(n?)r//){$restart= !$1;redo;}
-    if (s/^(n?)o//){$oblique= !$1;redo;}
-    if (s/^(n?)b//){$bold= !$1;redo;}
-
-    if (s/^(n?)n//){$numbering= !$1;redo;}
-    &usage;
+if ($ENV{A2PSOPTS}) {
+    @init_opts = split(' ', $ENV{A2PSOPTS});
+    &set_switch(@init_opts);
 }
+@ARGV = &set_switch(@ARGV);
 
-sub usage {
-    ($command = $0) =~ s#.*/##;
-    select(STDERR); $|=0;
-    print "syntax: $command [switches] [files]\n";
-    print <<"    >>";
-switches are:
--l \@label string
--L \@sub-label string (\%default="$default_sublabel")
--[n]ttail label (t)
--[n]nnumbering (nn)
--[n]hheader (h)
--[n]sscale (s)
--[n]mpunch mark (nm)
--[n]wwide page (nw)
--[n]pportrait (np)
--[n]ffolding (f)
--[n]cconvert to jis code (c)
--[n]rreset sheet number on each file (r)
--[n]buse bold/gothic font for overstruck characters (b)
--[n]ouse oblique font for underlined characters (o)
--f[x]#font size or maginificent (6.6 or 9.8)
--fn#normal font (C: Courier)
--fb#bold font (B: Courier-Bold)
--fu#underline font (O: Courier-BoldOblique)
--k#kanji:ascii font size ratio (1.0)
--j[#]adjust ascii font height to Japanese (1.0)
--us/a4/b4
-US letter / A4 / B4
--toc pattern
-specify table of contents pattern
--helpprint this message
-    >>
-    print "($rcsid)\n";
-    exit 1;
-}
+$sign = &getsign();
 
 $twinpage = !($portrait || $wide_pages);
 $font_size = $portrait ? $fontsize_p  : $fontsize_l unless $font_size;
@@ -174,7 +126,7 @@
     $portrait ? ($portrait_header, $sheet_width, $sheet_height)
       : ($landscape_header, $sheet_height, $sheet_width);
 $header_size = $show_header ? $header * $pixels_inch : 0;
-$linesperpage = (int(($page_height-$header_size)/($font_size * 1.1))) - 1;
+$linesperpage = (int(($page_height-$header_size)/($font_size * $baselineskip))) - 1;
 if ($portrait || $wide_pages) {
     $columnsperline = (int($page_width / $char_width)) - 1;
 } else {
@@ -233,6 +185,107 @@
 
 ############################################################
 
+sub set_switch {
+    local (@opts) = @_;
+
+    while ($_ = $opts[0], s/^-(.+)$/$1/ && shift(@opts)) {
+next if $_ eq '';
+if (s/^help$//){&usage;next;}
+if (s/^basename$//){$basename++;next;}
+if (s/^(us|a4|b4)$//i){&paper($paper="\L$1");next;}
+if (s/^l(.*)$//){defined($label=$1||shift)||&usage;next;}
+if (s/^L(.*)$//){defined($sublabel=$1||shift)||&usage;next;}
+if (s/^toc$//){defined($toc=shift)||&usage;next;}
+
+if (s/^a([\d\.]+)//){$baselineskip=$1;redo;}
+if (s/^k([\d\.]+)//){$kanji_ascii_ratio=$1;redo;}
+if (s/^f([\d\.]+)//){$font_size=$1;redo;}
+if (s/^fx([\d\.]+)//){$font_mag=$1;redo;}
+if (s/^f([nbu])(.*)//){defined($font_number{$font{$1}=$2||shift}) ||
+ &usage;redo;}
+if (s/^j([\d\.]*)//){$ascii_mag=$1||1.2;redo;}
+if (s/^d(\d*)//){$debug=$1||1;redo;}
+if (s/^(n?)g([\d\.]*)//){
+    if ('' ne $1) {
+&usage() if ('' ne $2);
+$headergray=1;
+    }
+    $headergray=$2 if ('' ne $2);redo;}
+if (s/^(n?)m//){$show_punchmark= !$1;redo;}
+if (s/^(n?)h//){$show_header= !$1;redo;}
+
+if (s/^(n?)s([\d\.]*)//){
+    if ('' ne $1) {
+&usage() if ('' ne $2);
+$show_border = !$1;
+    }
+    $borderwidth = $2 if ('' ne $2);redo;}
+if (s/^(n?)t//){$show_footer= !$1;redo;}
+if (s/^(n?)C//){$selfconvert= !$1;redo;}
+if (s/^(n?)w//){$wide_pages= !$1;redo;}
+if (s/^(n?)c//){$jisconvert= !$1;redo;}
+if (s/^(n?)v//){$visualize= !$1;redo;}
+if (s/^(n?)p//){$portrait= !$1;redo;}
+if (s/^(n?)f//){$folding= !$1;redo;}
+if (s/^(n?)r//){$restart= !$1;redo;}
+if (s/^(n?)o//){$oblique= !$1;redo;}
+if (s/^(n?)b//){$bold= !$1;redo;}
+
+if (s/^(n?)n//){$numbering= !$1;redo;}
+&usage;
+    }
+    return @opts;
+}
+
+sub usage {
+    ($command = $0) =~ s#.*/##;
+    select(STDERR); $|=0;
+    print "syntax: $command [switches] [files]\n";
+    print <<"    >>";
+switches are:
+-l \@label string
+-L \@sub-label string (\%default="$default_sublabel")
+-[n]ttail label (t)
+-[n]nnumbering (nn)
+-[n]hheader (h)
+-[n]g[#]
+fill header with gray (g0.95) (0.0[black]-1.0[white])
+-[n]s[#]
+print frame (s0.1)
+-[n]mpunch mark (nm)
+-[n]wwide page (nw)
+-[n]pportrait (np)
+-[n]ffolding (f)
+-[n]cconvert to jis code (c)
+-[n]rreset sheet number on each file (r)
+-[n]buse bold/gothic font for overstruck characters (b)
+-[n]ouse oblique font for underlined characters (o)
+-a#change baselineskip (1.0)
+-f[x]#font size or maginificent (6.6 or 9.8)
+-fn#normal font (C: Courier)
+-fb#bold font (B: Courier-Bold)
+-fu#underline font (O: Courier-BoldOblique)
+-k#kanji:ascii font size ratio (1.0)
+-j[#]adjust ascii font height to Japanese (1.0)
+-us/a4/b4
+US letter / A4 / B4
+-toc pattern
+specify table of contents pattern
+-helpprint this message
+    >>
+    print "($rcsid)\n";
+    exit 1;
+}
+
+sub getsign {
+    local ($sign);
+    return undef unless ($sign = $ENV{USER}); 
+    if ($host = $ENV{HOST}) {# tcsh only?
+$sign = "$sign\@$host";
+    }
+    return $sign;
+}
+
 sub print_file {
     local($name, $label) = @_;
     defined($label) || ($label = $name || 'stdin');
@@ -514,6 +567,10 @@
 print "/noheader true def\n";
 print "/headersize 0.0 def\n";
     }
+    printf("/baselineskip %g def\n", $baselineskip);
+    printf("/borderwidth %g def\n", $borderwidth);
+    printf("/headergray %g def\n", $headergray);
+    print("/sign ($sign) def\n");
     print "/nofooter ", $show_footer ? "false" : "true", " def\n";
     print "/nopunchmark ", $show_punchmark ? "false" : "true", " def\n";
     printf("/bodyfontsize %g def\n", $font_size);
@@ -527,6 +584,10 @@
     } else {
 printf("/doasciimag false def\n");
     }
+    print("/filenamefontname /$filenamefont def\n");
+    print("/datefontname /$datefont def\n");
+    print("/signfontname /$signfont def\n");
+    print("/footerfontname /$footerfont def\n");
     &print_template;
 
     if ($copies_number > 1) {
@@ -654,10 +715,14 @@
 /bodymargin bodyfontsize 0.7 mul def
 
 % Font assignment to differents kinds of "objects"
-/filenamefontname /Helvetica-Bold def
+%/filenamefontname /Helvetica-Bold def
 /stdfilenamefont filenamefontname filenamefontsize getfont def
-/datefont /Helvetica datefontsize getfont def
-/footerfont /Helvetica-Bold datefontsize getfont def
+%/datefont /Helvetica datefontsize getfont def
+/datefont datefontname datefontsize getfont def
+%/signfont /Times-Roman datefontsize getfont def
+/signfont signfontname datefontsize getfont def
+%/footerfont /Helvetica-Bold datefontsize getfont def
+/footerfont footerfontname 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
@@ -691,7 +756,7 @@
    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
+   bodyfontsize baselineskip mul lines mul bodymargin dup add add headersize add
    def
 
 % Coordinates for upper corner of a logical page and for sheet number.
@@ -809,10 +874,13 @@
       paper_adjust neg 0 translate
     } if
 } if
+      sheetside 0 eq {
+          printsign
+          nofooter not { printfooter } if
+          nopunchmark not { punchmark } 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
@@ -820,6 +888,15 @@
       moveto
     } bind def
 
+/printsign {
+    gsave
+upperx sheetside get uppery moveto
+        signfont setfont
+0 6 rmoveto
+        sign show
+    grestore
+} bind def
+
 % Function printheader: prints page header.
 /printheader
     { upperx sheetside get  uppery headersize sub 1 add  moveto
@@ -857,6 +934,8 @@
 % Function printborder: prints border page.
 /printborder 
     { upperx sheetside get uppery moveto
+      borderwidth setlinewidth
+      noborder not { grayheader } if
       gsave% print the four sides
         pagewidth 0 rlineto% of the square
         0 pageheight neg rlineto
@@ -868,6 +947,16 @@
       if
     } bind def
 
+/grayheader { 
+    gsave
+headergray setgray
+pagewidth 0 rlineto
+   0 headersize neg rlineto
+pagewidth neg 0 rlineto
+closepath fill
+grestore
+} bind def
+
 % Punch Marker
 /punchmark {
   gsave
@@ -921,7 +1010,7 @@
 % Function nl: newline
 /nl {
       grestore
-      0 bodyfontsize 1.1 mul neg rmoveto
+      0 bodyfontsize baselineskip mul neg rmoveto
     } bind def
 
 % Function cr: carriage return
