use Data::Dumper;
our @paperpts = ('creditcard');
+our @bigpaperpts = ();
our $fontname_num = 'Helvetica';
our $fontscale_num = 0.8;
our $fontname = 'Courier';
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
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) {
}
}
-if (@paperpts==1) {
- if ($paperpts[0] eq 'creditcard') {
+sub canonpaper ($) {
+ my ($pts) = @_;
+
+ return unless @$pts==1;
+ my ($name) = @$pts;
+
+ if ($name eq 'creditcard') {
# ISO/IEC 7810 ID-1, from en.wikipedia.org/wiki/Payment_card
- @paperpts = mm2pt qw(85.60 53.98);
+ @$pts = mm2pt qw(85.60 53.98);
} else {
- $!=0; $?=0; my $r = `paperconf -sp $paperpts[0]`;
+ $!=0; $?=0; my $r = `paperconf -sp $name`;
defined $r or die "paperconf failed: $? $!\n";
$r =~ m/^([0-9.]+) ([0-9.]+)$/ or die "$_ ?";
- @paperpts = ($1,$2);
+ @$pts = ($1,$2);
}
}
+canonpaper(\@paperpts);
+canonpaper(\@bigpaperpts);
+
@borders = mm2pt @borders;
@ARGV >= 2 or badusage;
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 +
prf "grestore\n";
}
}
+ prf "showpage\n";
}
readstrings();