Date: Sun, 11 Jul 2004 22:55:34 +0900 (JST) From: Hiroki Sato <hrs@FreeBSD.org> To: doc@FreeBSD.org Subject: doc build with AFPL Ghostscript 8.14 Message-ID: <20040711.225534.98614992.hrs@eos.ocn.ne.jp>
next in thread | raw e-mail | index | archive | help
----Security_Multipart0(Sun_Jul_11_22_55_34_2004_030)-- Content-Type: Multipart/Mixed; boundary="--Next_Part(Sun_Jul_11_22_55_34_2004_283)--" Content-Transfer-Encoding: 7bit ----Next_Part(Sun_Jul_11_22_55_34_2004_283)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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(Sun_Jul_11_22_55_34_2004_283)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="docepsgeom.diff" 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(Sun_Jul_11_22_55_34_2004_283)---- ----Security_Multipart0(Sun_Jul_11_22_55_34_2004_030)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQBA8UbWTyzT2CeTzy0RAiQTAJ9bN12lBx1mhIeHyOneCYLO02ImtgCgnjGp pP6uHc/50gDgnxm3zSE+cxA= =HUCO -----END PGP SIGNATURE----- ----Security_Multipart0(Sun_Jul_11_22_55_34_2004_030)----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040711.225534.98614992.hrs>