diff options
author | wl <wl> | 2011-08-10 18:22:58 +0000 |
---|---|---|
committer | wl <wl> | 2011-08-10 18:22:58 +0000 |
commit | a8a28d87bf78636f437d06712f80574f0c62dadb (patch) | |
tree | 4b32e3e506d127d6ac7142d62cdfbde84fc952e8 /src | |
parent | 0938acbb014e059439eabcd1688728e3bb00edaf (diff) | |
download | groff-a8a28d87bf78636f437d06712f80574f0c62dadb.tar.gz |
[gropdf] Minor updates and fixes.
* src/devices/gropdf/gropdf.pl: Change command line option `-fy' to
`-y' for consistency.
Better support for Windows platform.
(do_x): Handle keywords `pagename' and `switchtopage'.
* doc/groff.texinfo, src/devices/gropdf/gropdf.man: Updated.
* font/devpdf/Foundry: Renamed to...
* font/devpdf/Foundry.in: This.
Add default alias font names.
* font/devpdf/util/BuildFoundries.pl: This is now an installation
helper script and gets not longer installed.
Support alternative font file names (separated with `!').
* font/devpdf/Makefile.sub: Fixes to work with a separate build
directory.
Font files are now build at `make' time; this makes `test-groff'
work with -Tpdf.
* font/devpdf/util/Makefile.sub: Removed.
* Makefile.in (DEVDIRS, OTHERDIRS, EXTRADIRS): Handle devpdf
specially.
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/gropdf/gropdf.man | 11 | ||||
-rw-r--r-- | src/devices/gropdf/gropdf.pl | 101 |
2 files changed, 98 insertions, 14 deletions
diff --git a/src/devices/gropdf/gropdf.man b/src/devices/gropdf/gropdf.man index bdfe5727..a26a314b 100644 --- a/src/devices/gropdf/gropdf.man +++ b/src/devices/gropdf/gropdf.man @@ -25,11 +25,6 @@ the original English. . ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP . el .TP "\\$1" .. -.de TQ -. br -. ns -. TP \$1 -.. . .de FT . if '\\*(.T'ps' .ft \\$1 @@ -53,7 +48,7 @@ gropdf \- PDF driver for groff \#.OP \-I dir .OP \-p papersize \#.OP \-w n -.OP \-fy foundry +.OP \-y foundry .RI [ files .IR .\|.\|. ] .YS @@ -84,7 +79,7 @@ reads the standard input. A filename of .B \- also causes -.B grops +.B gropdf to read the standard input. . PDF output is written to the standard output. @@ -188,7 +183,7 @@ for details. Print the version number. . .TP -.BI \-fy foundry +.BI \-y foundry Set the foundry to use for selecting fonts of the same name. . .TP diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl index 7c070569..e56aa262 100644 --- a/src/devices/gropdf/gropdf.pl +++ b/src/devices/gropdf/gropdf.pl @@ -91,6 +91,8 @@ my $thislev=1; my $mark=undef; my $suspendmark=undef; my $n_flg=1; +my $pginsert=-1; # Growth point for kids array +my %pgnames; # 'names' of pages for switchtopage my %ppsz=( 'ledger'=>[1224,792], 'legal'=>[612,1008], @@ -131,9 +133,13 @@ my $version=0; #Load_Config(); -GetOptions("F=s" => \$fd, 'l' => \$frot, 'p=s' => \$fpsz, 'd!' => \$debug, 'v' => \$version, 'e' => \$embedall, 'fy=s' => \$Foundry); +GetOptions("F=s" => \$fd, 'l' => \$frot, 'p=s' => \$fpsz, 'd!' => \$debug, 'v' => \$version, 'e' => \$embedall, 'y=s' => \$Foundry); -print "GNU gropdf (groff) version $cfg{GROFF_VERSION}\n", exit if $version; +if ($version) +{ + print "GNU gropdf (groff) version $cfg{GROFF_VERSION}\n"; + exit; +} # Search for 'font directory': paths in -f opt, shell var GROFF_FONT_PATH, default paths @@ -191,6 +197,7 @@ my %info=('Creator' => "(groff version $cfg{GROFF_VERSION})", while (<>) { chomp; + s/\r$//; $lct++; do # The ahead buffer behaves like 'ungetc' @@ -470,7 +477,7 @@ sub OpenFile my $dirs=shift; my $fnm=shift; - if (substr($fnm,0,1) eq '/') + if (substr($fnm,0,1) eq '/' or substr($fnm,1,1) eq ':') # dos { return if -r "$fnm" and open($$f,"<$fnm"); } @@ -557,7 +564,7 @@ sub do_x $cat=$obj[$objct]->{DATA}; $objct++; $pages=$obj[2]->{DATA}; - Put("%PDF-1.4\n%âãÏÓ\n"); + Put("%PDF-1.4\n\x25\xe2\xe3\xcf\xd3\n"); } elsif ($xcmd eq 'X') { @@ -866,6 +873,85 @@ sub do_x $mark=$suspendmark; $suspendmark=undef; } + elsif (lc($xprm[1]) eq 'pagename') + { + if ($pginsert > -1) + { + $pgnames{$xprm[2]}=$pages->{Kids}->[$pginsert]; + } + else + { + $pgnames{$xprm[2]}='top'; + } + } + elsif (lc($xprm[1]) eq 'switchtopage') + { + my $ba=$xprm[2]; + my $want=$xprm[3]; + + if ($pginsert > -1) + { + if (!defined($want) or $want eq '') + { + # no before/after + $want=$ba; + $ba='before'; + } + + if (!defined($ba) or $ba eq '' or $ba eq 'bottom') + { + $pginsert=$#{$pages->{Kids}}; + } + elsif ($ba eq 'top') + { + $pginsert=-1; + } + else + { + if (exists($pgnames{$want})) + { + my $ref=$pgnames{$want}; + + if ($ref eq 'top') + { + $pginsert=-1; + } + else + { + + foreach my $j (0..$#{$pages->{Kids}}) + { + if ($ref eq $pages->{Kids}->[$j]) + { + if ($ba eq 'before') + { + $pginsert=$j-1; + return; + } + elsif ($ba eq 'after') + { + $pginsert=$j; + return; + } + else + { + Msg(0,"Parameter must be top|bottom|before|after not '$ba'"); + return; + } + } + } + + Msg(0,"Can't find page ref '$ref'"); + } + } + else + { + Msg(0,"Can't find page named '$want'"); + } + } + + } + } } elsif (lc(substr($xprm[0],0,9)) eq 'papersize') { @@ -2056,7 +2142,7 @@ sub do_p $cpageno=++$objct; - push(@{$pages->{Kids}},BuildObj($objct, + my $thispg=BuildObj($objct, {'Type' => '/Page', 'Group' => {'CS' => '/DeviceRGB', 'S' => '/Transparency'}, 'Parent' => '2 0 R', @@ -2064,8 +2150,10 @@ sub do_p {'Length' => 0} ) ], } - ) ); + + splice(@{$pages->{Kids}},++$pginsert,0,$thispg); + $objct+=1; $cpage=$obj[$cpageno]->{DATA}; $pages->{'Count'}++; @@ -2693,6 +2781,7 @@ sub LoadAhead { my $lin=<>; chomp($lin); + $lin=~s/\r$//; $lct++; push(@ahead,$lin); |