Make the new PS/PDF backend somewhat configurable

This commit is contained in:
H. Peter Anvin 2002-05-15 19:02:52 +00:00
parent 692f6631a2
commit 1aef73430e
3 changed files with 58 additions and 17 deletions

View File

@ -43,7 +43,7 @@ nasmdoc.texi: nasmdoc.dip
new: nasmdocx.ps nasmdocx.pdf
nasmdocx.ps: nasmdoc.dip nasmlogo.eps genps.pl psfonts.ph pswidth.ph head.ps
$(PERL) $(srcdir)/genps.pl > nasmdocx.ps
$(PERL) $(srcdir)/genps.pl nasmdoc.dip > nasmdocx.ps
nasmdocx.pdf: nasmdocx.ps
$(PS2PDF) nasmdocx.ps nasmdocx.pdf

View File

@ -6,6 +6,8 @@
require 'psfonts.ph'; # The fonts we want to use
require 'pswidth.ph'; # PostScript string width
use Fcntl;
#
# PostScript configurables; these values are also available to the
# PostScript code itself
@ -30,11 +32,47 @@ require 'pswidth.ph'; # PostScript string width
idxcolumns => 2, # Number of index columns
);
# US-Letter paper
# $psconf{pagewidth} = 612; $psconf{pageheight} = 792;
# A4 paper
# $psconf{pagewidth} = 595; $psconf{pageheight} = 842;
%psbool = (
colorlinks => 0, # Set links in blue rather than black
);
# Known paper sizes
%papersizes = (
'a4' => [595, 842], # ISO standard paper size
'letter' => [612, 792], # US common paper size
'pa4' => [595, 792], # Compromise ("portable a4")
'b4' => [709,1002], # ISO intermediate paper size
'legal' => [612,1008], # US intermediate paper size
'a3' => [842,1190], # ISO double paper size
'11x17' => [792,1224], # US double paper size
);
#
# Parse the command line
#
undef $input;
while ( $arg = shift(@ARGV) ) {
if ( $arg =~ /^\-(|no\-)/ ) {
$parm = $';
$true = ($1 eq '') ? 1 : 0;
if ( $true && defined($papersizes{$parm}) ) {
$psconf{pagewidth} = $papersizes{$parm}->[0];
$psconf{pageheight} = $papersizes{$parm}->[1];
} elsif ( defined($psbool{$parm}) ) {
$psbool{$parm} = $true;
} elsif ( $true && defined($psconf{$parm}) ) {
$psconf{$parm} = shift(@ARGV);
} else {
die "$0: Unknown option: $arg\n";
}
} else {
$input = $arg;
}
}
#
# Document formatting parameters
#
$paraskip = 6; # Space between paragraphs
$chapstart = 30; # Space before a chapter heading
$chapskip = 24; # Space after a chapter heading
@ -51,7 +89,12 @@ $tocskip = 6; # Space between TOC entries
# First, format the stuff coming from the front end into
# a cleaner representation
#
open(PARAS, '< nasmdoc.dip');
if ( defined($input) ) {
sysopen(PARAS, $input, O_RDONLY) or
die "$0: cannot open $input: $!\n";
} else {
open(PARAS, "<&STDIN") or die "$0: $!\n";
}
while ( defined($line = <PARAS>) ) {
chomp $line;
$data = <PARAS>;
@ -736,9 +779,12 @@ print "%%EndComments\n";
print "%%BeginProlog\n";
# Emit the configurables as PostScript tokens
for $c ( keys(%psconf) ) {
foreach $c ( keys(%psconf) ) {
print "/$c ", $psconf{$c}, " def\n";
}
foreach $c ( keys(%psbool) ) {
print "/$c ", ($psbool{$c}?'true':'false'), " def\n";
}
# Emit fontset definitions
foreach $fset ( @AllFonts ) {

View File

@ -41,6 +41,7 @@
/lkbegun 1 def
/lktype exch def
/lktarget exch def
colorlinks { 0 0 0.4 setrgbcolor } if
end
} def
@ -85,17 +86,10 @@
% --
/linkend {
userdict begin
[ lktype /Dest eq {
/Dest lktarget
[ lktype /URI eq {
/Action 2 dict dup /Subtype /URI put dup /URI lktarget put
} {
lktype /URI eq {
/Action
% << .. >> would be languagelevel 2 :(
2 dict dup /Subtype /URI put dup /URI lktarget put
} {
/Dest lktarget
% /Page lktarget /View [ /XYZ 0 pageheight null ]
} ifelse
/Dest lktarget
} ifelse
/Border [0 0 0]
/Rect [ lkllx lkxmarg sub
@ -105,6 +99,7 @@
/Subtype /Link
/ANN pdfmark
/lkbegun 0 def
colorlinks { 0 setgray } if
end
} def