chiark / gitweb /
numbered-alias-sheet: new -P option
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 3 Nov 2013 23:48:39 +0000 (23:48 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 3 Nov 2013 23:48:39 +0000 (23:48 +0000)
numbered-alias-sheet

index ac581c83da3016560f24bc53800dc3a7d95d1947..be3297e4f46e15d77631e055ac100be3e851f45f 100755 (executable)
@@ -6,6 +6,7 @@ use POSIX;
 use Data::Dumper;
 
 our @paperpts = ('creditcard');
+our @bigpaperpts = ();
 our $fontname_num = 'Helvetica';
 our $fontscale_num = 0.8;
 our $fontname = 'Courier';
@@ -24,6 +25,7 @@ our $usage = <<END;
 usage: $us [<options>] <foo-mail-pregen> <foo-mail-pregen-opts>...
 options:
   -p<papersize>           for libpaper, or "creditcard", default is $paperpts[0]
+  -P<actual-papersize>    center in this; default is not to center
   -f<bothfont>            set both to same font name
   -f[<numfont>[*<scale>]],[<addrfont>]  default is $fontname_num*$fontscale_num,$fontname
   -b<border>|-b<bx>x<by>  all in mm
@@ -72,8 +74,12 @@ for (;;) {
     while (m/^-./) {
        if (s/^-p(\w+)$//) {
            @paperpts = ($1);
+       } elsif (s/^-P(\w+)$//) {
+           @bigpaperpts = ($1);
        } elsif (s/^-p($dbl_re)x($dbl_re)$//o) {
            @paperpts = mm2pt($1,$2);
+       } elsif (s/^-P($dbl_re)x($dbl_re)$//o) {
+           @bigpaperpts = mm2pt($1,$2);
        } elsif (s/^-f($fontname_re)$//o) {
            $fontname = $fontname_num = $1;
        } elsif (s/^-f(?:($fontname_re)(?:\*($dbl_re))?)?,($fontname_re)?$//o) {
@@ -133,6 +139,7 @@ sub canonpaper ($) {
 }
 
 canonpaper(\@paperpts);
+canonpaper(\@bigpaperpts);
 
 @borders = mm2pt @borders;
 
@@ -457,6 +464,14 @@ sub write_output () {
        for ($tile[1]=0; $tile[1]<$tiles[1]; $tile[1]++) {
            prf "%% tile @tile\n";
            prf "gsave\n";
+           if (@bigpaperpts) {
+               foreach (qw(0 1)) {
+                   my $spare = $bigpaperpts[$_] - $tiles[$_] * $paperpts[$_];
+                   $spare >= 0 or die "too many tiles: will not fit!\n";
+                   prf "%s ", $spare*0.5;
+               }
+               prf "translate\n";
+           }
            prf "%s ", $tile[$_] * $paperpts[$_] foreach qw(0 1);
            prf "translate\n";
            write_output_tile($tile[0] * $pertile +