diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2020-09-10 18:10:49 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2020-09-11 20:06:36 +0200 |
commit | acfc02c1747065fe450c7cfeb6f1844b62335f08 (patch) | |
tree | 5887806a2e6b99bbb0255e013a9028810e230a7f /lib | |
parent | Import Ghostscript 9.52 (diff) | |
download | ghostscript-gpl-patches-acfc02c1747065fe450c7cfeb6f1844b62335f08.tar.gz ghostscript-gpl-patches-acfc02c1747065fe450c7cfeb6f1844b62335f08.tar.bz2 ghostscript-gpl-patches-acfc02c1747065fe450c7cfeb6f1844b62335f08.zip |
Import Ghostscript 9.53ghostscript-9.53
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'lib')
59 files changed, 236 insertions, 415 deletions
diff --git a/lib/FCOfontmap-PCLPS3 b/lib/FCOfontmap-PCLPS3 index 1dd130e0..2a01896f 100644 --- a/lib/FCOfontmap-PCLPS3 +++ b/lib/FCOfontmap-PCLPS3 @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/FCOfontmap-PS3 b/lib/FCOfontmap-PS3 index 58e66a80..17e597df 100644 --- a/lib/FCOfontmap-PS3 +++ b/lib/FCOfontmap-PS3 @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/Fontmap.ATB b/lib/Fontmap.ATB index ffd754e1..9f7f92c0 100644 --- a/lib/Fontmap.ATB +++ b/lib/Fontmap.ATB @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/Fontmap.ATM b/lib/Fontmap.ATM index 06bec7b8..5080f767 100644 --- a/lib/Fontmap.ATM +++ b/lib/Fontmap.ATM @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/Fontmap.OS2 b/lib/Fontmap.OS2 index ec425235..404deb7a 100644 --- a/lib/Fontmap.OS2 +++ b/lib/Fontmap.OS2 @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/Fontmap.SGI b/lib/Fontmap.SGI index 353ea833..a6087f06 100644 --- a/lib/Fontmap.SGI +++ b/lib/Fontmap.SGI @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/Fontmap.Sol b/lib/Fontmap.Sol index 453031a6..add5a3cc 100644 --- a/lib/Fontmap.Sol +++ b/lib/Fontmap.Sol @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/Fontmap.Ult b/lib/Fontmap.Ult index 85e3006c..45329670 100644 --- a/lib/Fontmap.Ult +++ b/lib/Fontmap.Ult @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/Fontmap.VMS b/lib/Fontmap.VMS index 210dd736..1707191c 100644 --- a/lib/Fontmap.VMS +++ b/lib/Fontmap.VMS @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/align.ps b/lib/align.ps index e73c2718..8f2ebf5a 100644 --- a/lib/align.ps +++ b/lib/align.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/caption.ps b/lib/caption.ps index 5d7806af..1ec719a7 100644 --- a/lib/caption.ps +++ b/lib/caption.ps @@ -1,5 +1,5 @@ %! -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/cid2code.ps b/lib/cid2code.ps index 46bd1d29..98423fb7 100644 --- a/lib/cid2code.ps +++ b/lib/cid2code.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/docie.ps b/lib/docie.ps index 286ef2cb..82a16bb0 100644 --- a/lib/docie.ps +++ b/lib/docie.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/font2pcl.ps b/lib/font2pcl.ps index db0131a2..2ce2c3d7 100644 --- a/lib/font2pcl.ps +++ b/lib/font2pcl.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gs_ce_e.ps b/lib/gs_ce_e.ps index 41b29d9a..5db08a11 100644 --- a/lib/gs_ce_e.ps +++ b/lib/gs_ce_e.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gs_il2_e.ps b/lib/gs_il2_e.ps index 684c6bde..7ef56d45 100644 --- a/lib/gs_il2_e.ps +++ b/lib/gs_il2_e.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gs_kanji.ps b/lib/gs_kanji.ps index f93af381..862f5ff3 100644 --- a/lib/gs_kanji.ps +++ b/lib/gs_kanji.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gs_ksb_e.ps b/lib/gs_ksb_e.ps index d038190b..4d228765 100644 --- a/lib/gs_ksb_e.ps +++ b/lib/gs_ksb_e.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gs_lgo_e.ps b/lib/gs_lgo_e.ps index b6707ae6..dd04ff66 100644 --- a/lib/gs_lgo_e.ps +++ b/lib/gs_lgo_e.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gs_lgx_e.ps b/lib/gs_lgx_e.ps index c2e3217c..0c12e2d8 100644 --- a/lib/gs_lgx_e.ps +++ b/lib/gs_lgx_e.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gs_wl1_e.ps b/lib/gs_wl1_e.ps index ef05498b..72185fee 100644 --- a/lib/gs_wl1_e.ps +++ b/lib/gs_wl1_e.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gs_wl2_e.ps b/lib/gs_wl2_e.ps index 5c337a4a..6b55c557 100644 --- a/lib/gs_wl2_e.ps +++ b/lib/gs_wl2_e.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gs_wl5_e.ps b/lib/gs_wl5_e.ps index 8d6ce40f..4f259792 100644 --- a/lib/gs_wl5_e.ps +++ b/lib/gs_wl5_e.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gslp.ps b/lib/gslp.ps index 002dc978..9e2c21bf 100644 --- a/lib/gslp.ps +++ b/lib/gslp.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gsnup.ps b/lib/gsnup.ps index 4ea81bdf..ea01d874 100644 --- a/lib/gsnup.ps +++ b/lib/gsnup.ps @@ -1,5 +1,5 @@ %! -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/gssetgs.bat b/lib/gssetgs.bat index e2805617..7c0b8000 100644 --- a/lib/gssetgs.bat +++ b/lib/gssetgs.bat @@ -2,13 +2,16 @@ rem Set default values for GS (gs with graphics window) and GSC rem (console mode gs) if the user hasn't set them. +rem if 64-bit version is available, prefer that. if NOT %GS%/==/ goto :gsset if EXIST %~dp0..\bin\gswin32.exe set GS=%~dp0..\bin\gswin32 +if EXIST %~dp0..\bin\gswin64.exe set GS=%~dp0..\bin\gswin64 if %GS/==/ set GS=gswin32 :gsset if NOT %GSC%/==/ goto :gscset if EXIST %~dp0..\bin\gswin32c.exe set GSC=%~dp0..\bin\gswin32c +if EXIST %~dp0..\bin\gswin64c.exe set GS=%~dp0..\bin\gswin64c if %GSC%/==/ set GSC=gswin32c :gscset diff --git a/lib/image-qa.ps b/lib/image-qa.ps index 3dd10b6c..307a951d 100644 --- a/lib/image-qa.ps +++ b/lib/image-qa.ps @@ -1,5 +1,5 @@ %!PS -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/jispaper.ps b/lib/jispaper.ps index 11d16fa8..d1e33e6a 100644 --- a/lib/jispaper.ps +++ b/lib/jispaper.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/lines.ps b/lib/lines.ps index 2b77d8e9..287b6bdb 100644 --- a/lib/lines.ps +++ b/lib/lines.ps @@ -1,5 +1,5 @@ %! -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/mkcidfm.ps b/lib/mkcidfm.ps index bb6629ef..7dd92fe3 100644 --- a/lib/mkcidfm.ps +++ b/lib/mkcidfm.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/pdf2dsc.ps b/lib/pdf2dsc.ps index d836bf32..88bc1536 100644 --- a/lib/pdf2dsc.ps +++ b/lib/pdf2dsc.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/pdf_info.ps b/lib/pdf_info.ps index 547809c8..0b4654ab 100644 --- a/lib/pdf_info.ps +++ b/lib/pdf_info.ps @@ -1,5 +1,5 @@ %!PS -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/pfbtopfa.ps b/lib/pfbtopfa.ps index 0e6301c2..2b69c58f 100644 --- a/lib/pfbtopfa.ps +++ b/lib/pfbtopfa.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/ppath.ps b/lib/ppath.ps index f37a9c5d..5c571019 100644 --- a/lib/ppath.ps +++ b/lib/ppath.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/pphs.ps b/lib/pphs.ps index 84fd99f4..8605f2dd 100644 --- a/lib/pphs.ps +++ b/lib/pphs.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/prfont.ps b/lib/prfont.ps index a4456382..059d2a08 100644 --- a/lib/prfont.ps +++ b/lib/prfont.ps @@ -1,7 +1,7 @@ %! %%Creator: Eric Gisin <egisin@waterloo.csnet> %%Title: Print font catalog -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/ps2ai.ps b/lib/ps2ai.ps index e82fc497..20ae204e 100644 --- a/lib/ps2ai.ps +++ b/lib/ps2ai.ps @@ -1,5 +1,5 @@ %! -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/ps2epsi b/lib/ps2epsi index d992180f..7590cb5a 100755 --- a/lib/ps2epsi +++ b/lib/ps2epsi @@ -1,30 +1,22 @@ #!/bin/sh +# Revised in 2020 to use the eps2write device (within ps2epsi.ps) + # This definition is changed on install to match the -# executable name set in the makefile +# executable name set in the makefile, but we check a couple of other +# places (bin/ sibling to $LIBDIR and 'gs' on the $PATH) GS_EXECUTABLE=gs -gs="`dirname \"$0\"`/$GS_EXECUTABLE" +LIBDIR=`dirname $0` +gs="$LIBDIR/$GS_EXECUTABLE" if test ! -x "$gs"; then - gs="$GS_EXECUTABLE" -fi -GS_EXECUTABLE="$gs" - -# try to create a temporary file securely -if test -z "$TMPDIR"; then - TMPDIR=/tmp -fi -if which mktemp >/dev/null 2>/dev/null; then - tmpfile="`mktemp $TMPDIR/ps2epsi.XXXXXX`" -else - tmpdir=$TMPDIR/ps2epsi.$$ - (umask 077 && mkdir "$tmpdir") - if test ! -d "$tmpdir"; then - echo "failed: could not create temporary file" - exit 1 + # Might be executing lib/ps2epsi with bin/ as sibling to lib/ + gs="$LIBDIR/../bin/$GS_EXECUTABLE" + if test ! -x "$gs"; then + # Fallback to using any 'gs' on the path + gs="$GS_EXECUTABLE" fi - tmpfile="$tmpdir"/ps2epsi$$ fi -trap "rm -rf \"$tmpfile\"" 0 1 2 3 7 13 15 +GS_EXECUTABLE="$gs" export outfile @@ -35,8 +27,7 @@ fi infile=$1; -if [ $# -eq 1 ] -then +if [ $# -eq 1 ]; then case "${infile}" in *.ps) base=`basename "${infile}" .ps` ;; *.cps) base=`basename "${infile}" .cps` ;; @@ -49,70 +40,8 @@ else outfile=$2 fi -"$GS_EXECUTABLE" -q -dBATCH -dNOPAUSE -P- -sDEVICE=bbox -sOutputFile=/dev/null "${infile}" 2>${outfile} - -ls -l "${infile}" | -awk 'F==1 { - cd="%%CreationDate: " $6 " " $7 " " $8; - t="%%Title: " $9; - f="%%For:" U " " $3; - c="%%Creator: Ghostscript ps2epsi from " $9; - next; - } - /^%!/ {next;} - /^%%Title:/ {t=$0; next;} - /^%%Creator:/ {c=$0; next;} - /^%%CreationDate:/ {cd=$0; next;} - /^%%For:/ {f=$0; next;} - !/^%/ { - print "/ps2edict 30 dict def"; - print "ps2edict begin"; - print "/epsititle (" t "\\n) def"; - print "/epsicreator (" c "\\n) def"; - print "/epsicrdt (" cd "\\n) def"; - print "/epsifor (" f "\\n) def"; - exit(0); - } - ' U="$USERNAME$LOGNAME" F=1 - F=2 "${infile}" >"$tmpfile" - -ls -l "${outfile}" | -awk 'F==1 { - b="%%BoundingBox: 0 0 0 0\\n"; - } - /^%%BoundingBox:/ {b=$0; next;} - /^%%HiResBoundingBox:/ { - hb=$0; - print "ps2edict where {pop} {/ps2edict 30 dict def} ifelse"; - print "ps2edict begin"; - print "/BBoxString (" b "\\n) def"; - print "/HiresBBoxString (" hb "\\n) def"; - print "end"; - exit(0); - } - ' F=1 - F=2 "${outfile}" >>"$tmpfile" - -"$GS_EXECUTABLE" -q -dNOPAUSE -P- -r72 -sDEVICE=bit -sOutputFile=/dev/null "$tmpfile" ps2epsi.ps "$tmpfile" <"${infile}" 1>&2 -rm -f "$tmpfile" -rm -rf "$tmpdir" - -( -cat << BEGINEPS -save countdictstack mark newpath /showpage {} def /setpagedevice /pop load def -%%EndProlog -%%Page 1 1 -BEGINEPS - -cat "${infile}" | -LC_ALL=C \ -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' - -cat << ENDEPS -%%Trailer -cleartomark countdictstack exch sub { end } repeat restore -%%EOF -ENDEPS - -) >> "${outfile}" +# Note, we expect 'ps2epsi.ps' to be in the same directory as 'ps2epsi' +"$GS_EXECUTABLE" -q -dNOOUTERSAVE -dNODISPLAY -dLastPage=1 -sOutputFile="${outfile}" \ + --permit-file-all="${infile}" -- "$LIBDIR/ps2epsi.ps" "${infile}" 1>&2 exit 0 diff --git a/lib/ps2epsi.bat b/lib/ps2epsi.bat index f5e7b3e5..b5ac5c28 100755 --- a/lib/ps2epsi.bat +++ b/lib/ps2epsi.bat @@ -1,33 +1,15 @@ -@echo off +@echo off if %1/==/ goto usage if %2/==/ goto usage call "%~dp0gssetgs.bat" + set infile=%~1 set outfile=%~2 -rem First we need to determine the bounding box. ps2epsi.ps below will pick -rem the result up from %outfile% -%GSC% -q -dNOPAUSE -dBATCH -P- -sDEVICE=bbox -sOutputFile=NUL %1 2> %2 - -rem Ghostscript uses %outfile% to define the output file -%GSC% -q -dNOPAUSE -P- -sDEVICE=bit -sOutputFile=NUL ps2epsi.ps < %1 - -rem We bracket the actual file with a few commands to help encapsulation -echo %%%%Page: 1 1 >> %2 -echo %%%%BeginDocument: %2 >> %2 -echo /InitDictCount countdictstack def gsave save mark newpath >> %2 -echo userdict /setpagedevice /pop load put >> %2 - -rem Append the original onto the preview header -rem cat.ps uses the %infile% and %outfile% environment variables for the filenames -%GSC% -q -dNOPAUSE -dBATCH -P- -sDEVICE=bit -sOutputFile=NUL cat.ps - - -echo %%%%EndDocument >> %2 -echo countdictstack InitDictCount sub { end } repeat >> %2 -echo cleartomark restore grestore >> %2 +rem Now convert the input to EPSF and add the Preview to the EPSF file +%GSC% -q -dNOOUTERSAVE -dNODISPLAY -dLastPage=1 -sOutputFile=%outfile% --permit-file-read=%infile% -- %~dp0ps2epsi.ps %infile% goto end diff --git a/lib/ps2epsi.cmd b/lib/ps2epsi.cmd index 9eafdbd8..c87d82e6 100755 --- a/lib/ps2epsi.cmd +++ b/lib/ps2epsi.cmd @@ -1,8 +1,3 @@ -/* - * This file is maintained by a user: if you have any questions about it, - * please contact Mark Hale (mark.hale@physics.org). - */ - @echo off if %1/==/ goto usage if %2/==/ goto usage @@ -10,25 +5,8 @@ if %2/==/ goto usage set infile=%1 set outfile=%2 -rem First we need to determine the bounding box. ps2epsi.ps below will pick -rem the result up from %outfile% -gsos2 -q -dNOPAUSE -dBATCH -P- -sDEVICE=bbox -sOutputFile=NUL %infile% 2> %outfile% - -rem Ghostscript uses %outfile% to define the output file -gsos2 -q -dNOPAUSE -P- -sDEVICE=bit -sOutputFile=NUL ps2epsi.ps < %infile% - -rem We bracket the actual file with a few commands to help encapsulation -echo %%%%Page: 1 1 >> %outfile% -echo %%%%BeginDocument: %outfile% >> %outfile% -echo /InitDictCount countdictstack def gsave save mark newpath >> %outfile% -echo userdict /setpagedevice /pop load put >> %outfile% - -rem Append the original onto the preview header -copy %outfile% + %infile% - -echo %%%%EndDocument >> %outfile% -echo countdictstack InitDictCount sub { end } repeat >> %outfile% -echo cleartomark restore grestore >> %outfile% +rem Now convert the input to EPSF and add the Preview to the EPSF file +gsos2 -q -dNOOUTERSAVE -dNODISPLAY -dLastPage=1 -sOutputFile=%outfile% --permit-file-read=%infile% %~dp0ps2epsi.ps %infile% goto end diff --git a/lib/ps2epsi.ps b/lib/ps2epsi.ps index 86f1d2ff..54621f92 100644 --- a/lib/ps2epsi.ps +++ b/lib/ps2epsi.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or @@ -11,234 +11,163 @@ % Refer to licensing information at http://www.artifex.com or contact % Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, % CA 94945, U.S.A., +1(415)492-9861, for further information. -% - -% Convert an arbitrary PostScript file to an EPSI file. -% -% Please do not contact these users if you have questions. They no longer -% have the time, interest, or current expertise to keep this code working. -% If you find bugs, please send proposed fixes to bug-gs@ghostscript.com. -% -% Bug fix 2002-04-20 by rayjj: Bounding box was incorrect since it depended -% on the dither pattern and gray shade at the boundary. Changed to use -% 8-bit grayscale preview image to allow correct bounding box (at the -% expense of a 8x larger preview image). Also moved .setsafe until after -% the device and file operations are complete (but still before the input -% file is processed. -% Bug fix 2000-04-11 by lpd: if a font didn't have a FontName (which is the -% case for bitmap fonts produced by recent versions of dvips), setfont -% caused an error. -% Bug fix 8/21/99 by lpd: many of the margin and width computations were -% wrong (off by 1). The code only "worked" because the bugs were -% (mostly) in conservative directions. -% Modified 3/17/98 by lpd to make it possible to run this file without -% running the ps2epsi script first, for debugging. -% Bug fix 9/29/97 by lpd <ghost@aladdin.com>: if the page size wasn't an -% exact multiple of 8 bits, an incorrect bounding box (or a rangecheck -% error) could occur. -% Patched 7/26/95 by -% Greg P. Kochanski <gpk@bell-labs.com> -% to add many new DSC comments and make the comments conforming. -% Original version contributed by -% George Cameron <george@bio-medical-physics.aberdeen.ac.uk> -% -% Initialize, and redefine copypage and showpage. - -% ps2edict is normally defined in the pre-loaded code created by the -% ps2epsi script. -/ps2edict where { pop } { /ps2edict 25 dict def } ifelse -ps2edict begin - - % The main procedure - /ps2epsi - { - % bbox written to outfile by bbox device from ps2epsi command file - outfile (r) file /epsifile exch def - /BBoxString epsifile 256 string readline pop def - /HiresBBoxString epsifile 256 string readline pop def - epsifile closefile - % Open the file - outfile (w) file /epsifile exch def - % Get the device parameters - currentdevice getdeviceprops .dicttomark - /HWSize get aload pop - /devheight exch def - /devwidth exch def - matrix defaultmatrix - /devmatrix exch def - % Make a corresponding 8-bit deep memory device - devmatrix devwidth devheight - 256 string 0 1 255 { 1 index exch dup 255 exch sub put } for - makeimagedevice - /arraydevice exch def - arraydevice - % Turn on anti-aliasing - mark /TextAlphaBits 4 /GraphicsAlphaBits 4 6 -1 roll - putdeviceprops - setdevice % (does an erasepage) - /rowwidth devwidth def - /row rowwidth string def - /zerorow rowwidth string def % all zero - % Replace the definition of showpage - userdict /showpage { ps2edict begin epsipage end } bind put - userdict /setfont { ps2edict begin epsisetfont end } bind put - userdict /setpagedevice /pop load put - } bind def - - /epsifontdict 100 dict def - - /epsisetfont - { - % code here keeps a list of font names in dictionary epsifontdict - /tmpfont exch def - tmpfont /FontName known { - /tmpfontname tmpfont /FontName get def - epsifontdict tmpfontname known not { epsifontdict tmpfontname 0 put } if - epsifontdict tmpfontname 2 copy get 1 add put - } if - tmpfont setfont - } bind def - -% Get a scan line from the memory device, zeroing any bits beyond -% the device width. -/getscanline { % <device> <y> <string> getscanline <string> - dup 4 1 roll copyscanlines pop - 16#ff00 devwidth 7 and neg bitshift 255 and - dup 0 ne { - 1 index dup length 1 sub 2 copy get 4 -1 roll and put - } { - pop - } ifelse -} bind def - -/margintest { % <y-start> <step> <y-limit> margintest <y-non-blank> - % <y-start> <step> <y-limit> margintest - - { dup arraydevice exch row getscanline - zerorow ne { exit } if pop - } for -} bind def - - /epsiNameStr 200 string def - /epsiNpages 0 def - /epsiNpageStr 20 string def - /epsipage - { - /epsiNpages epsiNpages 1 add def - /loopcount devheight 1 sub def - - % Find top margin -- minimum Y of non-blank scan line. - -1 0 1 loopcount margintest - dup -1 eq { (blank page!!\n) print quit }{ exch pop } ifelse - /tm exch def - - % Find bottom margin -- maximum Y of non-blank scan line. - loopcount -1 0 margintest - /bm exch def - - % Initialise limit variables - /loopcount rowwidth 1 sub def - /lm loopcount def - /rm 0 def - - % Find left and right boundaries of image - tm 1 bm - { % Get more data - arraydevice exch row getscanline pop - % Scan from left to find first non-zero element - % We save first the element, then the index - -1 0 1 loopcount - { dup row exch get 0 ne { exch pop exit }{ pop } ifelse - } for - % If we found -1, row is blank .. - dup -1 ne - { % Find the leftmost index - dup lm lt - % If the new index is less, we save index and element - { /lm exch def } { pop } ifelse - % Now find the rightmost index - loopcount -1 0 - { dup row exch get 0 ne { exit }{ pop } ifelse - } for - dup rm gt - % If the new index is greater, we save index and element - { /rm exch def } { pop } ifelse - } { - pop - } ifelse - } for - - % Write out the magic string and bounding box information - epsifile (%!PS-Adobe-2.0 EPSF-1.2\n) writestring - /epsititle where { pop epsifile epsititle writestring } if - /epsicreator where { pop epsifile epsicreator writestring } if - /epsicrdt where { pop epsifile epsicrdt writestring } if - /epsifor where { pop epsifile epsifor writestring } if - epsifile flushfile - - % Write out the page count: - epsifile (%%Pages: ) writestring - epsifile epsiNpages epsiNpageStr cvs writestring - epsifile (\n) writestring - epsifile flushfile - - % Write out the list of used fonts: - epsifile (%%DocumentFonts:) writestring - epsifontdict { - epsifile ( ) writestring - pop epsiNameStr cvs epsifile exch writestring - } forall - epsifile (\n) writestring - epsifile flushfile - - epsifile BBoxString writestring epsifile (\n) writestring - epsifile HiresBBoxString writestring epsifile (\n) writestring - - % Define character and bit widths for the output line buffer: - /cwidth rm lm sub 1 add def - /out cwidth string def - - epsifile (%%EndComments\n\n) writestring - epsifile (%%BeginProlog\n) writestring - epsifile (%%BeginPreview: ) writestring - epsifile cwidth write==only epsifile ( ) writestring - epsifile bm tm sub 1 add write==only epsifile ( 8 ) writestring - epsifile bm tm sub 1 add - cwidth 39 add 40 idiv mul write== - epsifile flushfile - - gsave - - tm 1 bm - { % Get a scan line interval from the array device - arraydevice exch row copyscanlines lm cwidth getinterval - % Write out the hex data as 40 bytes per line (82 chars) - 0 40 cwidth - { epsifile (% ) writestring - epsifile exch 2 index exch - dup cwidth exch sub 40 .min getinterval writehexstring - epsifile (\n) writestring - } for - pop - } for - - epsifile (%%EndImage\n) writestring - epsifile (%%EndPreview\n) writestring - epsifile flushfile - grestore - erasepage initgraphics - - DonePage 0 1 put - } bind def - -(outfile) getenv - { /outfile exch def - ps2epsi - - /DonePage 1 string def - (%stdin) (r) file cvx execute0 - DonePage 0 get 0 eq { showpage } if +% Convert a PostScript file to an EPSI file, adding the Preview Image. + +% If the file is already EPSF, then skip the creation of an EPSF, and +% only add the preview. A warning is issued if the %%Pages: comment +% indicates that there is more than a single page in the input file. + +% Expected invocation: +% gs -q -dNOOUTERSAVE -dNODISPLAY -dLastPage=1 -sOutputFile=out.epsi --permit-file-read=in.ps -- ps2epsi.ps in.ps + +% Usually this will be invoked by the ps2epsi script (or .bat or .cmd versions) + +false % no errors from initial param check +% NOOUTERSAVE is needed for the SAVE to not remove the tempfile (if one was needed) +vmstatus pop pop 0 gt { (Error: missing -dNOOUTERSAVE option) = pop true } if +% NODISPLAY may not be strictly needed, but we don't want to open the default device +/NODISPLAY where { pop } { (Error: missing -dNODISPLAY option) = pop true } ifelse +% LastPage is needed if we are using eps2write on a PostScript (or PDF) file that has multiple pages. +/LastPage where { pop } { (Error: missing -dLastPage option) = pop true } ifelse +% OutputFile is needed so that it gets on the permit-file-writing list +/OutputFile where { pop } { (Error: missing -sOutputFile option) = pop true } ifelse + +.shellarguments not count 3 lt or count -1 roll or +{ + (usage: gs -q -dNOOUTERSAVE -dNODISPLAY -dLastPage=1 -sOutputFile=out.epsi --permit-file-read=in.eps -- ps2epsi.ps in.ps) = + quit +} { + dup /InputFile exch def + (r) file /I exch def +} ifelse + +/O OutputFile (w) file def + +/S 65535 string def + +/R { I S readline not { (Error: Unexpected end of file.) = quit } if } bind def +/WL { O exch writestring O (\n) writestring } bind def % Write with linefeed +/TName null def + +/EPSFheader (%!PS-Adobe-3.0 EPSF-3.0) def +% Read the header to check if this file was EPSF +R +dup EPSFheader ne { + % InputFile was not EPSF + pop % discard the first line of the InputFile + % run the file through eps2write (into a tempfile) to make an EPSF + (_ps2epsi) (w+) .tempfile closefile /TName exch def + /SAVE save def + (eps2write) finddevice mark /OutputFile TName 3 index putdeviceprops pop + setdevice + InputFile run + SAVE restore + /I TName (r) file def + R +} if +WL % Write the first line (either from InputFile or the tempfile + +% From the "5002 Encapsulated PostScript File Format Specification Version 3.0 1 May 1992" +% The preview section must appear after the header comment section, but +% before the document prologue definitions. That is, it should immediately +% follow the %%EndComments: line in the EPS file. +{ % loop until we see the %%EndComments line, writing those lines to output + R + dup (%%EndComments) anchorsearch exch pop { % discard the match or extra copy of the string + pop exit % found it } if + % Check the %%Pages: comment to issue a warning if there is more than one page. + dup (%%Pages:) anchorsearch exch pop { % discard the match or extra copy of the string + cvi 1 gt { + (Warning: EPSI files can only have 1 page, Only the first page will be in the preview.) = + } if + } if + % Collect the BoundingBox data that will be used when generating the preview + dup (%%BoundingBox:) anchorsearch exch pop { % discard the match or extra copy of the string + mark + exch token not { (Error: invalid BoundingBox parameters) = quit } if + exch token not { (Error: invalid BoundingBox parameters) = quit } if + exch token not { (Error: invalid BoundingBox parameters) = quit } if + exch token not { (Error: invalid BoundingBox parameters) = quit } if + exch pop ] + /BBox exch def + % Preview dimensions + /PWidth BBox dup 2 get exch 0 get sub def + /PHeight BBox dup 3 get exch 1 get sub def + } if + WL % send to output file with linefeed. +} loop + +WL % send to output file with linefeed. + +% If the InputFile already has a preview, skip past it +R +dup (%%BeginPreview) anchorsearch exch pop { % discard the match or extra copy of the string + pop + % Read lines until after the %%EndPreview + { + R + (%%EndPreview) anchorsearch exch pop { % discard the match or extra copy of the string + pop pop exit % found it + } if + } loop + % Get the next line for use after the generated preview + R +} +if +/LineAfterEndComments exch def + +//null (w+) .tempfile +closefile % will be opened by bit device +/Pname exch def + +(bit) selectdevice +<< + /GrayValues 256 % Gray, not monochrome + /OutputFile Pname + /TextAlphaBits 4 + /GraphicsAlphaBits 4 + /LastPage 1 % TBD: does this work? + /.IgnoreNumCopies true + /Install { BBox 0 get neg BBox 1 get neg translate { 1.0 exch sub } settransfer } % EPSI 00 is white + /HWResolution [ 72. 72. ] + /PageSize [ PWidth PHeight ] +>> setpagedevice + +InputFile run + +/P Pname (r) file def % Preview data file +/SP PWidth string def % One string per image line + +% Write the preview +O (%%BeginPreview: ) writestring +O PWidth write==only O ( ) writestring +O PHeight write==only O ( 8 ) writestring +O PHeight PWidth 39 add 40 idiv mul write== % 40 bytes per line +O flushfile +0 1 PHeight 1 sub { + pop + P SP readstring pop + 0 40 PWidth { + O (% ) writestring % 82 bytes on each line, plus EOL + SP exch 40 PWidth 2 index sub .min getinterval + O exch writehexstring + O (\n) writestring + } for + pop +} for +(%%EndPreview) WL + +% Write the line that followed the %%EndComments +LineAfterEndComments WL + +% Copy the remainder of the inputfile +{ + I S readstring exch O exch writestring not { exit } if +} loop + +% If we created a tempfile, delete it +TName null ne { TName deletefile } if -end quit diff --git a/lib/rollconv.ps b/lib/rollconv.ps index 031747f1..3a39e021 100644 --- a/lib/rollconv.ps +++ b/lib/rollconv.ps @@ -1,5 +1,5 @@ %! -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/stcinfo.ps b/lib/stcinfo.ps index beda3a29..dd0477c3 100644 --- a/lib/stcinfo.ps +++ b/lib/stcinfo.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/stcolor.ps b/lib/stcolor.ps index 7f0ca3ab..f14b44b8 100644 --- a/lib/stcolor.ps +++ b/lib/stcolor.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/stocht.ps b/lib/stocht.ps index dcfa5f7c..8c9bb438 100644 --- a/lib/stocht.ps +++ b/lib/stocht.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/traceimg.ps b/lib/traceimg.ps index 1bb256a1..4ab8720f 100644 --- a/lib/traceimg.ps +++ b/lib/traceimg.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/traceop.ps b/lib/traceop.ps index 7d98d4a0..ecd8ce27 100644 --- a/lib/traceop.ps +++ b/lib/traceop.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/uninfo.ps b/lib/uninfo.ps index dc93b8e2..98e89062 100644 --- a/lib/uninfo.ps +++ b/lib/uninfo.ps @@ -1,5 +1,5 @@ %! -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/viewcmyk.ps b/lib/viewcmyk.ps index 5cc76981..e4250bf1 100644 --- a/lib/viewcmyk.ps +++ b/lib/viewcmyk.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/viewgif.ps b/lib/viewgif.ps index 423bfff0..55a39862 100644 --- a/lib/viewgif.ps +++ b/lib/viewgif.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/viewmiff.ps b/lib/viewmiff.ps index 2b60ccd0..39d715d0 100644 --- a/lib/viewmiff.ps +++ b/lib/viewmiff.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/viewpbm.ps b/lib/viewpbm.ps index ab4ede66..ec355313 100644 --- a/lib/viewpbm.ps +++ b/lib/viewpbm.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/viewpcx.ps b/lib/viewpcx.ps index 81531aff..6840f1e5 100644 --- a/lib/viewpcx.ps +++ b/lib/viewpcx.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/viewps2a.ps b/lib/viewps2a.ps index 91e5894f..e0fb32bd 100644 --- a/lib/viewps2a.ps +++ b/lib/viewps2a.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/viewraw.ps b/lib/viewraw.ps index ec1e1d7a..f1a3f890 100644 --- a/lib/viewraw.ps +++ b/lib/viewraw.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/viewrgb.ps b/lib/viewrgb.ps index 8b77dd2d..adde24e4 100644 --- a/lib/viewrgb.ps +++ b/lib/viewrgb.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/winmaps.ps b/lib/winmaps.ps index 06da63aa..75933fc2 100644 --- a/lib/winmaps.ps +++ b/lib/winmaps.ps @@ -1,4 +1,4 @@ -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or diff --git a/lib/zeroline.ps b/lib/zeroline.ps index 521b1de0..7ace3ca3 100644 --- a/lib/zeroline.ps +++ b/lib/zeroline.ps @@ -1,5 +1,5 @@ %! -% Copyright (C) 2001-2019 Artifex Software, Inc. +% Copyright (C) 2001-2020 Artifex Software, Inc. % All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or |