Fix a build problem when print/ghostscript-afpl is used:
- epsgeom+gs now converts EPS files. graphics/peps is no longer used. - Add $PERL, $REALPATH, and $SETENV into doc.project.mk. Tested by: simon
This commit is contained in:
parent
debb63c736
commit
c8277d756c
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=21640
3 changed files with 142 additions and 20 deletions
102
share/misc/epsgeom
Normal file
102
share/misc/epsgeom
Normal file
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/perl -w
|
||||
# $FreeBSD$
|
||||
#
|
||||
# epsgeom - extract geometry from a EPS file.
|
||||
#
|
||||
# Copyright (C) 2004 The FreeBSD Project. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
|
||||
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>) {
|
||||
last if (($x,$y,$width,$height) =
|
||||
/^%%BoundingBox:\s+([-\d]+)\s+([-\d]+)\s+([-\d]+)\s+([-\d]+)/);
|
||||
#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__
|
|
@ -122,7 +122,7 @@ LOCAL_IMAGES_TXT+= ${IMAGES_SCR_TXT}
|
|||
# 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,18 @@ SCR2PNGOPTS?= ${SCR2PNGFLAGS}
|
|||
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 is a perl script for 1) extracting geometry information
|
||||
# from a .eps file and 2) arrange it for ghostscript's pnm driver.
|
||||
#
|
||||
EPSGEOM?= ${PERL} ${DOC_PREFIX}/share/misc/epsgeom
|
||||
EPSGEOMOPTS?= ${EPS2PNM_RES} ${EPS2PNM_RES}
|
||||
PNMTOPNG?= ${PREFIX}/bin/pnmtopng
|
||||
PNMTOPNGOPTS?= ${PNGTOPNGFLAGS}
|
||||
PNGTOPNM?= ${PREFIX}/bin/pngtopnm
|
||||
PNGTOPNMOPTS?= ${PNGTOPNMFLAGS}
|
||||
PPMTOPGM?= ${PREFIX}/bin/ppmtopgm
|
||||
|
@ -151,9 +161,6 @@ PS2EPSOPTS?= -q -dNOPAUSE -dSAFER -dDELAYSAFER \
|
|||
-sPAPERSIZE=letter -r72 -sDEVICE=bit \
|
||||
-sOutputFile=/dev/null ${PS2EPSFLAGS} ps2epsi.ps
|
||||
#
|
||||
SETENV?= /usr/bin/env
|
||||
REALPATH?= /bin/realpath
|
||||
|
||||
# Use suffix rules to convert .scr files to other formats
|
||||
.SUFFIXES: .scr .pic .png .ps .eps .txt
|
||||
|
||||
|
@ -180,12 +187,11 @@ REALPATH?= /bin/realpath
|
|||
.scr.txt:
|
||||
${SCR2TXT} ${SCR2TXTOPTS} < ${.IMPSRC} | ${SED} -E -e 's/ +$$//' > ${.TARGET}
|
||||
|
||||
# Some versions of ghostscript (7.04) have problems with the use of
|
||||
# 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 +204,20 @@ REALPATH?= /bin/realpath
|
|||
# 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 +226,10 @@ REALPATH?= /bin/realpath
|
|||
|
||||
.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}
|
||||
|
|
|
@ -82,6 +82,15 @@ HTML2TXT?= ${PREFIX}/bin/links
|
|||
HTML2TXTOPTS?= -dump ${HTML2TXTFLAGS}
|
||||
ISPELL?= ispell
|
||||
ISPELLOPTS?= -l -p /usr/share/dict/freebsd ${ISPELLFLAGS}
|
||||
.if exists(/usr/bin/perl)
|
||||
PERL?= /usr/bin/perl
|
||||
.elif exists(/usr/local/bin/perl)
|
||||
PERL?= /usr/local/bin/perl
|
||||
.else
|
||||
PERL?= perl
|
||||
.endif
|
||||
REALPATH?= /bin/realpath
|
||||
SETENV?= /usr/bin/env
|
||||
|
||||
# Image processing (contains code used by the doc.<format>.mk files, so must
|
||||
# be listed first).
|
||||
|
|
Loading…
Reference in a new issue