diff options
author | wl <wl> | 2012-08-31 12:17:33 +0000 |
---|---|---|
committer | wl <wl> | 2012-08-31 12:17:33 +0000 |
commit | 847b504be937b13d472024555b5abd7f094aa739 (patch) | |
tree | 6b6a75bb27ec545a8cdf4c54f698a94675a59b05 | |
parent | a529116ae6922d775b4270adcdb2c0f227831957 (diff) | |
download | groff-847b504be937b13d472024555b5abd7f094aa739.tar.gz |
Add `pdfmom' to handle mom documents with gropdf.
* Makefile.in (OTHERDIRS): Move contrib/mom to be run after
devices/gropdf.
* src/devices/gropdf/gropdf.pl: Various fixes:
. Correct image scaling issue.
. Handle relative horizontal movement 'h' followed by absolute
vertical movement 'V'.
. Correct handling of track kerning.
* src/devices/gropdf/pdfmom.pl: New wrapper for mom (pdfmom)
using gropdf or grops driver.
* src/devices/gropdf/pdfmom.man: New man page.
* src/devices/gropdf/Makefile.sub: Updated to handle new files.
-rw-r--r-- | ChangeLog | 35 | ||||
-rw-r--r-- | Makefile.in | 5 | ||||
-rw-r--r-- | src/devices/gropdf/Makefile.sub | 17 | ||||
-rw-r--r-- | src/devices/gropdf/gropdf.pl | 15 | ||||
-rw-r--r-- | src/devices/gropdf/pdfmom.man | 140 | ||||
-rw-r--r-- | src/devices/gropdf/pdfmom.pl | 82 |
6 files changed, 282 insertions, 12 deletions
@@ -1,3 +1,38 @@ +2012-08-31 Deri James <deri@chuzzlewit.myzen.co.uk> + + Add `pdfmom' to handle mom documents with gropdf. + + * Makefile.in (OTHERDIRS): Move contrib/mom to be run after + devices/gropdf. + + * src/devices/gropdf/gropdf.pl: Various fixes: + + . Correct image scaling issue. + . Handle relative horizontal movement 'h' followed by absolute + vertical movement 'V'. + . Correct handling of track kerning. + + * src/devices/gropdf/pdfmom.pl: New wrapper for mom (pdfmom) + using gropdf or grops driver. + * src/devices/gropdf/pdfmom.man: New man page. + * src/devices/gropdf/Makefile.sub: Updated to handle new files. + +2012-08-31 Deri James <deri@chuzzlewit.myzen.co.uk> + + * Makefile.in (OTHERDIRS): Move contrib/mom to be run after + devices/gropdf. + + * src/devices/gropdf/gropdf.pl: Various fixes: + + . Correct image scaling issue. + . Handle relative horizontal movement 'h' followed by absolute + vertical movement 'V'. + . Correct handling of track kerning. + + * src/devices/gropdf/pdfmom.pl: New wrapper for mom (pdfmom) + using gropdf or grops driver. + * src/devices/gropdf/pdfmom.man: New man page. + * src/devices/gropdf/Makefile.sub: Updated to handle new files. 2012-08-31 Julien Moutinho <julm+groff@autogeree.net> * tmac/www.tmac (www-push-li): Fix indentation. diff --git a/Makefile.in b/Makefile.in index 59a8ec2d..e6f1e6d3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -607,7 +607,8 @@ ALLTTYDEVDIRS=\ font/devlatin1 \ font/devutf8 \ font/devcp1047 -# `doc' must be processed before `contrib/pdfmark'. +# `doc' must be processed before `contrib/pdfmark', +# pdf stuff must be processed before `contrib/mom OTHERDIRS=\ man \ tmac \ @@ -621,11 +622,11 @@ OTHERDIRS=\ contrib/eqn2graph \ contrib/grap2graph \ contrib/groffer \ - contrib/mom \ contrib/hdtbl \ contrib/pdfmark \ src/devices/gropdf \ font/devpdf \ + contrib/mom \ contrib/gdiffmk # OTHERDIRS is handled specially in the `$(TARGETS)' rule to avoid diff --git a/src/devices/gropdf/Makefile.sub b/src/devices/gropdf/Makefile.sub index 30991e52..6aa409d4 100644 --- a/src/devices/gropdf/Makefile.sub +++ b/src/devices/gropdf/Makefile.sub @@ -1,4 +1,4 @@ -# Copyright (C) 2011 Free Software Foundation, Inc. +# Copyright (C) 2011-2012 Free Software Foundation, Inc. # Written by Deri James <deri@chuzzlewit.demon.co.uk> # # This file is part of groff. @@ -17,10 +17,12 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. MAN1=\ - gropdf.n + gropdf.n \ + pdfmom.n CMDFILES=\ - gropdf + gropdf \ + pdfmom MOSTLYCLEANADD=\ gropdf \ @@ -30,7 +32,7 @@ MOSTLYCLEANADD=\ RM=rm -f -all: gropdf +all: gropdf pdfmom gropdf: gropdf.pl $(SH_DEPS_SED_SCRIPT) @@ -42,6 +44,13 @@ gropdf: gropdf.pl $(SH_DEPS_SED_SCRIPT) -e "s|@RT_SEP@|$(RT_SEP)|" $(srcdir)/gropdf.pl >$@ chmod +x $@ +pdfmom: pdfmom.pl $(SH_DEPS_SED_SCRIPT) + $(RM) $@ + sed -f $(SH_DEPS_SED_SCRIPT) \ + -e "s|@VERSION@|$(version)$(revision)|" \ + -e "s|@PERLPATH@|$(PERLPATH)|" $(srcdir)/pdfmom.pl >$@ + chmod +x $@ + install_data: -test -d $(DESTDIR)$(bindir) || $(mkinstalldirs) $(DESTDIR)$(bindir) for f in $(CMDFILES); do \ diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl index 0084b952..d8a21e25 100644 --- a/src/devices/gropdf/gropdf.pl +++ b/src/devices/gropdf/gropdf.pl @@ -907,13 +907,13 @@ sub do_x { IsGraphic(); my $bbox=$incfil{$fil}->[1]; - my $xscale=$wid/($bbox->[2]-$bbox->[0]+1); - my $yscale=($hgt<=0)?$xscale:($hgt/($bbox->[3]-$bbox->[1]+1)); + my $xscale=$wid/($bbox->[2]-$bbox->[0]); + my $yscale=($hgt<=0)?$xscale:($hgt/($bbox->[3]-$bbox->[1])); $xscale=($wid<=0)?$yscale:$xscale; $xscale=$yscale if $yscale < $xscale; $yscale=$xscale if $xscale < $yscale; - $wid=($bbox->[2]-$bbox->[0]+1)*$xscale; - $hgt=($bbox->[3]-$bbox->[1]+1)*$yscale; + $wid=($bbox->[2]-$bbox->[0])*$xscale; + $hgt=($bbox->[3]-$bbox->[1])*$yscale; if ($flag eq '-C' and $ll > $wid) { @@ -2978,7 +2978,7 @@ sub do_V } - $nomove=$pendmv=0; +# $nomove=$pendmv=0; $poschg=1; } @@ -2997,6 +2997,7 @@ sub TextWid { my $txt=shift; my $w=0; + my $ck=0; foreach my $c (split('',$txt)) { @@ -3005,7 +3006,9 @@ sub TextWid $w+=$widtbl->[$cn]; } - return($w/$unitwidth); + $ck=length($txt)*$curkern; + + return(($w/$unitwidth)+$ck); } sub do_t diff --git a/src/devices/gropdf/pdfmom.man b/src/devices/gropdf/pdfmom.man new file mode 100644 index 00000000..ef05d5e9 --- /dev/null +++ b/src/devices/gropdf/pdfmom.man @@ -0,0 +1,140 @@ +.ig +Copyright (C) 2012 + Free Software Foundation, Inc. +written by Deri James <deri@chuzzlewit.demon.co.uk> +and Peter Schaffter <peter@schaffter.ca) + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + +Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be included in +translations approved by the Free Software Foundation instead of in +the original English. +.. +. +.TH PDFMOM @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@" +. +. +.SH NAME +. +pdfmom \- Produce PDF documents using the mom macro set +. +. +.SH SYNOPSIS +. +.SY pdfmom +.OP \-Tps "\fR[pdfroff options]" +[groff options] +.I files .\|.\|. +.YS +. +.SY pdfmom +.OP \-Tpdf +[groff options] +.I files .\|.\|. +.YS +. +. +.SH DESCRIPTION +. +.B pdfmom +is a wrapper around +.B groff +that facilitates the production of PDF documents from files +formatted with the mom macros. +. +.P +.B pdfmom +prints to stdout, so output must be redirected to a destination +file. The size of the final PDF can be reduced by piping the output +through +.BR ps2pdf . +. +.P +If called with the +.B \-Tpdf +option (which is the default), +.B pdfmom +processes files using groff's native PDF driver, +.BR gropdf . +If +.B \-Tps +is given, processing is passed over to +.BR pdfroff , +which uses +.BR groff 's +PostScript driver. +In either case, multiple runs of the source file are peformed in +order to satisfy any forward references in the document. +. +.P +.B pdfmom +accepts all the same options as +.BR groff . +If +.B \-Tps +is given, the options associated with +.B pdfroff +are accepted as well. +Please note that when +.B pdfmom +calls +.BR pdfroff , +the +. +.P +.RS +.B -mpdfmark -mom --no-toc +.RE +. +.P +options are implied and should not be given on the +command line. +Equally, it is not necessary to supply the +.B -mom +or +.B "-m\~mom" +options when +.B \-Tps +is absent. +. +.P +PDF integration with the +.B mom +macros is discussed in full in the PDF manual, +.IR "Producing PDFs with groff and mom" . +. +. +.SH BUGS +. +.B pdfmom +sometimes issues warnings of the type +. +.P +.RS 2 +\&.\|.\|.: +.B can't transparently output node at top level +.RE +. +.P +This is more of an annoyance than a bug, and may safely be ignored. +. +. +.SH "SEE ALSO" +. +.BR groff (@MAN1EXT@), +.BR pdfroff (@MAN1EXT@), +.BR ps2pdf (@MAN1EXT@) +. +. +.\" Local Variables: +.\" mode: nroff +.\" End: diff --git a/src/devices/gropdf/pdfmom.pl b/src/devices/gropdf/pdfmom.pl new file mode 100644 index 00000000..a03bc83d --- /dev/null +++ b/src/devices/gropdf/pdfmom.pl @@ -0,0 +1,82 @@ +#!@PERLPATH@ -w +# +# pdfmom : Frontend to run groff -mom to produce PDFs +# Deri James : Friday 16 Mar 2012 +# + +# Copyright (C) 2012 Free Software Foundation, Inc. +# Written by Deri James <deri@chuzzlewit.demon.co.uk> +# +# This file is part of groff. +# +# groff is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# groff is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +use strict; +my @cmd; +my $dev='pdf'; + +while (my $c=shift) +{ + if (substr($c,0,2) eq '-T') + { + if (length($c) > 2) + { + $dev=substr($c,2); + } + else + { + $dev=shift; + } + + next; + } + elsif ($c eq '-z' or $c eq '-Z') + { + $dev=$c; + next; + } + + elsif ($c eq '-v') + { + print "GNU pdfmom (groff) version @VERSION@\n"; + exit; + } + + push(@cmd,$c); +} + +my $cmdstring=join(' ',@cmd); + +if ($dev eq 'pdf') +{ + system("groff -Tpdf -dPDF.EXPORT=1 -mom -z $cmdstring 2>&1 | grep '^.ds' | groff -Tpdf -mom - $cmdstring"); +} +elsif ($dev eq 'ps') +{ + system("pdfroff -mpdfmark -mom --no-toc $cmdstring"); +} +elsif ($dev eq '-z') # pseudo dev - just compile for warnings +{ + system("groff -Tpdf -mom -z $cmdstring"); +} +elsif ($dev eq '-Z') # pseudo dev - produce troff output +{ + system("groff -Tpdf -mom -Z $cmdstring"); +} +else +{ + print STDERR "Not compatible with device '-T $dev'\n"; + exit 1; +} + |