doc build with AFPL Ghostscript 8.14
Hiroki Sato
hrs at FreeBSD.org
Sun Jul 11 13:56:32 UTC 2004
Hi,
I made a patch to solve a doc build problem when AFPL Ghostscript 8.14
is used. This patch should be compatible with both of GNU Ghostscript
7.07, which the docproj port depends on via graphics/peps, and gs 8.14.
The problem was that graphics/peps cannot be used with gs 8.14. After
applying this patch, peps is no longer used.
Comments? If there is no objection, I think I will commit this
with some additional comments in doc.images.mk.
--
| Hiroki SATO
-------------- next part --------------
Index: share/mk/doc.images.mk
===================================================================
RCS file: /home/ncvs/doc/share/mk/doc.images.mk,v
retrieving revision 1.27
diff -d -u -I\$FreeBSD:.*\$ -I\$NetBSD:.*\$ -I\$OpenBSD:.*\$ -I\$DragonFly:.*\$ -I\$Id:.*\$ -I\$hrs:.*\$ -r1.27 doc.images.mk
--- share/mk/doc.images.mk 5 Apr 2004 22:53:43 -0000 1.27
+++ share/mk/doc.images.mk 11 Jul 2004 13:26:56 -0000
@@ -122,7 +122,7 @@
# low for the typical monitor in use today. The resolution of 100 looks
# much better on these monitors without making the image too large for
# a 640x480 monitor.
-EPS2PNG_RES?= 100
+EPS2PNM_RES?= 100
# We need to list ${_IMAGES_PNG} here since the images might be in a
# shared image directory.
@@ -133,8 +133,14 @@
SCR2TXT?= ${PREFIX}/bin/scr2txt
SCR2TXTOPTS?= -l ${SCR2TXTFLAGS}
SED?= /usr/bin/sed
-EPS2PNG?= ${PREFIX}/bin/peps
-EPS2PNGOPTS?= -p -r ${EPS2PNG_RES} ${EPS2PNGFLAGS}
+EPS2PNM?= ${PREFIX}/bin/gs
+EPS2PNMOPTS?= -q -dBATCH -dGraphicsAlphaBits=4 -dTextAlphaBits=4 \
+ -dEPSCrop -r${EPS2PNM_RES}x${EPS2PNM_RES} \
+ -dNOPAUSE -dSAFER -sDEVICE=pnm -sOutputFile=-
+EPSGEOM?= ${PERL} ${DOC_PREFIX}/share/mk/epsgeom
+EPSGEOMOPTS?= ${EPS2PNM_RES} ${EPS2PNM_RES}
+PNMTOPNG?= ${PREFIX}/bin/pnmtopng
+PNMTOPNGOPTS?= ${PNGTOPNGFLAGS}
PNGTOPNM?= ${PREFIX}/bin/pngtopnm
PNGTOPNMOPTS?= ${PNGTOPNMFLAGS}
PPMTOPGM?= ${PREFIX}/bin/ppmtopgm
@@ -153,6 +159,13 @@
#
SETENV?= /usr/bin/env
REALPATH?= /bin/realpath
+.if exists(/usr/bin/perl)
+PERL?= /usr/bin/perl
+.elif exists(/usr/local/bin/perl)
+PERL?= /usr/local/bin/perl
+.else
+PERL?= perl
+.endif
# Use suffix rules to convert .scr files to other formats
.SUFFIXES: .scr .pic .png .ps .eps .txt
@@ -184,8 +197,10 @@
# relative path when the arguments are passed by peps; realpath will
# correct the problem.
.pic.png: ${.TARGET:S/.png$/.eps/}
- ${EPS2PNG} ${EPS2PNGOPTS} -o ${.TARGET} \
- `${REALPATH} ${.TARGET:S/.png$/.eps/}`
+ ${EPSGEOM} -offset ${EPSGEOMOPTS} ${.TARGET:S/.png$/.eps/} \
+ | ${EPS2PNM} ${EPS2PNMOPTS} \
+ -g`${EPSGEOM} -geom ${EPSGEOMOPTS} ${.TARGET:S/.png$/.eps/}` - \
+ | ${PNMTOPNG} > ${.TARGET}
.pic.ps:
${PIC2PS} ${.ALLSRC} > ${.TARGET}
@@ -198,18 +213,20 @@
# bounding box.
.ps.eps:
${SETENV} outfile=${.TARGET} ${PS2EPS} ${PS2EPSOPTS} < ${.ALLSRC} 1>&2
- echo "save countdictstack mark newpath /showpage {} def /setpagedevice {pop} def" >> ${.TARGET}
- echo "%%EndProlog" >> ${.TARGET}
- echo "%%Page: 1 1" >> ${.TARGET}
- echo "%%BeginDocument: ${.ALLSRC}" >> ${.TARGET}
+ (echo "save countdictstack mark newpath /showpage {} def /setpagedevice {pop} def";\
+ echo "%%EndProlog";\
+ echo "%%Page: 1 1";\
+ echo "%%BeginDocument: ${.ALLSRC}";\
+ ) >> ${.TARGET}
${SED} -e '/^%%BeginPreview:/,/^%%EndPreview[^!-~]*$$/d' \
-e '/^%!PS-Adobe/d' \
-e '/^%%[A-Za-z][A-Za-z]*[^!-~]*$$/d'\
-e '/^%%[A-Za-z][A-Za-z]*: /d' < ${.ALLSRC} >> ${.TARGET}
- echo "%%EndDocument" >> ${.TARGET}
- echo "%%Trailer" >> ${.TARGET}
- echo "cleartomark countdictstack exch sub { end } repeat restore" >> ${.TARGET}
- echo "%%EOF" >> ${.TARGET}
+ (echo "%%EndDocument";\
+ echo "%%Trailer";\
+ echo "cleartomark countdictstack exch sub { end } repeat restore";\
+ echo "%%EOF";\
+ ) >> ${.TARGET}
# We can't use suffix rules to generate the rules to convert EPS to PNG and
# PNG to EPS. This is because a .png file can depend on a .eps file, and
@@ -218,7 +235,10 @@
.for _curimage in ${IMAGES_GEN_PNG}
${_curimage}: ${_curimage:S/.png$/.eps/}
- ${EPS2PNG} ${EPS2PNGOPTS} -o ${.TARGET} `${REALPATH} ${.ALLSRC}`
+ ${EPSGEOM} -offset ${EPSGEOMOPTS} ${.ALLSRC} \
+ | ${EPS2PNM} ${EPS2PNMOPTS} \
+ -g`${EPSGEOM} -geom ${EPSGEOMOPTS} ${.ALLSRC}` - \
+ | ${PNMTOPNG} > ${.TARGET}
.endfor
.for _curimage in ${IMAGES_GEN_EPS}
Index: share/mk/epsgeom
===================================================================
RCS file: share/mk/epsgeom
diff -N share/mk/epsgeom
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ share/mk/epsgeom 11 Jul 2004 13:27:58 -0000
@@ -0,0 +1,81 @@
+#!/usr/bin/perl -w
+# $FreeBSD$
+#
+# epsgeom - extract geometry from a EPS file.
+#
+
+my $x;
+my $y;
+my $width;
+my $height;
+
+my $gx;
+my $gy;
+
+if (@ARGV != 4) {
+ die "Error: invalid arguments.\n";
+}
+
+my $mode = shift @ARGV;
+my $hres = shift @ARGV;
+my $vres = shift @ARGV;
+my $file = shift @ARGV;
+
+my $realfile = `realpath ${file}`;
+chomp $realfile;
+
+open IN, "<$realfile" or die "Error: cannot open $realfile.\n";
+while(<IN>) {
+ if (($x,$y,$width,$height) =
+ /^%%BoundingBox:\s+([-\d]+)\s+([-\d]+)\s+([-\d]+)\s+([-\d]+)/) {
+ last;
+ }
+ #print STDERR "DEBUG: $_";
+}
+close IN;
+
+if (not defined($x)) {
+ die "Error: no BoundingBox found.\n";
+}
+
+$width -= $x;
+$height -= $y;
+
+# (int)(((double)hres * (double)width / 72.0) + 0.5),
+$gx = $hres * $width / 72.0 + 0.5;
+# (int)(((double)vres * (double)height / 72.0) + 0.5),
+$gy = $vres * $height / 72.0 + 0.5;
+
+my %replace = (
+ '@X@' => int $x,
+ '@Y@' => int $y,
+ '@MX@' => int -$x,
+ '@MY@' => int -$y,
+ '@WIDTH@' => int $width,
+ '@MWIDTH@' => int -$width,
+ '@HEIGHT@' => int $height,
+ '@MHEIGHT@' => int -$height,
+ '@ANGLE@' => int 0,
+ '@INPUT@' => $realfile,
+ );
+
+if ($mode eq "-replace") {
+ foreach my $i (keys %replace) {
+ printf "-e s,%s,%s,g ", $i, $replace{$i};
+ }
+} elsif ($mode eq "-offset") {
+ #print STDERR "DEBUG: (int -$x), $y\n";
+ printf "<< /PageOffset [%d %d] >> setpagedevice\n", (int -$x), $y;
+ open IN, "<$realfile" or die "Error: cannot open $realfile.\n";
+ print while(<IN>);
+ close IN;
+ print "\n";
+ print "showpage\n";
+} elsif ($mode eq "-geom") {
+ #print STDERR "DEBUG: $x,$y,$width,$height\n";
+ printf "%dx%d", $gx, $gy;
+} else {
+ die "Error: invalid mode specified.\n";
+}
+
+__END__
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-doc/attachments/20040711/569be8b6/attachment.sig>
More information about the freebsd-doc
mailing list