diff options
Diffstat (limited to 'Master/tlpkg/tlgs/lib')
42 files changed, 626 insertions, 268 deletions
diff --git a/Master/tlpkg/tlgs/lib/align.ps b/Master/tlpkg/tlgs/lib/align.ps index e73c2718b16..8f2ebf5a94f 100644 --- a/Master/tlpkg/tlgs/lib/align.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/caption.ps b/Master/tlpkg/tlgs/lib/caption.ps index 5d7806af1b1..1ec719a74c9 100644 --- a/Master/tlpkg/tlgs/lib/caption.ps +++ b/Master/tlpkg/tlgs/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 diff --git a/Master/tlpkg/tlgs/lib/cid2code.ps b/Master/tlpkg/tlgs/lib/cid2code.ps index 46bd1d29be3..98423fb7fd2 100644 --- a/Master/tlpkg/tlgs/lib/cid2code.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/docie.ps b/Master/tlpkg/tlgs/lib/docie.ps index 286ef2cb0ad..82a16bb0afe 100644 --- a/Master/tlpkg/tlgs/lib/docie.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/gs_ce_e.ps b/Master/tlpkg/tlgs/lib/gs_ce_e.ps index 41b29d9a30d..5db08a11ab5 100644 --- a/Master/tlpkg/tlgs/lib/gs_ce_e.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/gs_il2_e.ps b/Master/tlpkg/tlgs/lib/gs_il2_e.ps index 684c6bdeefc..7ef56d4595f 100644 --- a/Master/tlpkg/tlgs/lib/gs_il2_e.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/gs_kanji.ps b/Master/tlpkg/tlgs/lib/gs_kanji.ps index f93af381217..862f5ff333e 100644 --- a/Master/tlpkg/tlgs/lib/gs_kanji.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/gs_ksb_e.ps b/Master/tlpkg/tlgs/lib/gs_ksb_e.ps index d038190ba41..4d228765c5f 100644 --- a/Master/tlpkg/tlgs/lib/gs_ksb_e.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/gs_lgo_e.ps b/Master/tlpkg/tlgs/lib/gs_lgo_e.ps index b6707ae623a..dd04ff6673f 100644 --- a/Master/tlpkg/tlgs/lib/gs_lgo_e.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/gs_lgx_e.ps b/Master/tlpkg/tlgs/lib/gs_lgx_e.ps index c2e3217c5ad..0c12e2d871c 100644 --- a/Master/tlpkg/tlgs/lib/gs_lgx_e.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/gs_wl1_e.ps b/Master/tlpkg/tlgs/lib/gs_wl1_e.ps index ef05498bd04..72185fee271 100644 --- a/Master/tlpkg/tlgs/lib/gs_wl1_e.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/gs_wl2_e.ps b/Master/tlpkg/tlgs/lib/gs_wl2_e.ps index 5c337a4aa07..6b55c55743c 100644 --- a/Master/tlpkg/tlgs/lib/gs_wl2_e.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/gs_wl5_e.ps b/Master/tlpkg/tlgs/lib/gs_wl5_e.ps index 8d6ce40f3d2..4f259792f70 100644 --- a/Master/tlpkg/tlgs/lib/gs_wl5_e.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/gslp.ps b/Master/tlpkg/tlgs/lib/gslp.ps index 002dc9783dc..9e2c21bf304 100644 --- a/Master/tlpkg/tlgs/lib/gslp.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/gsnup.ps b/Master/tlpkg/tlgs/lib/gsnup.ps index 4ea81bdf5e7..ea01d874bb8 100644 --- a/Master/tlpkg/tlgs/lib/gsnup.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/image-qa.ps b/Master/tlpkg/tlgs/lib/image-qa.ps index 3dd10b6c641..307a951d31b 100644 --- a/Master/tlpkg/tlgs/lib/image-qa.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/jispaper.ps b/Master/tlpkg/tlgs/lib/jispaper.ps index 11d16fa87f9..d1e33e6acb7 100644 --- a/Master/tlpkg/tlgs/lib/jispaper.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/lines.ps b/Master/tlpkg/tlgs/lib/lines.ps index 2b77d8e9faa..287b6bdbea2 100644 --- a/Master/tlpkg/tlgs/lib/lines.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/mkcidfm.ps b/Master/tlpkg/tlgs/lib/mkcidfm.ps index bb6629ef543..7dd92fe39e3 100644 --- a/Master/tlpkg/tlgs/lib/mkcidfm.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/pdf2dsc.ps b/Master/tlpkg/tlgs/lib/pdf2dsc.ps index d836bf32038..88bc1536242 100644 --- a/Master/tlpkg/tlgs/lib/pdf2dsc.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/pdf_info.ps b/Master/tlpkg/tlgs/lib/pdf_info.ps new file mode 100644 index 00000000000..0b4654ab073 --- /dev/null +++ b/Master/tlpkg/tlgs/lib/pdf_info.ps @@ -0,0 +1,429 @@ +%!PS +% Copyright (C) 2001-2020 Artifex Software, Inc. +% All Rights Reserved. +% +% This software is provided AS-IS with no warranty, either express or +% implied. +% +% This software is distributed under license and may not be copied, +% modified or distributed except as expressly authorized under the terms +% of the license contained in the file LICENSE in this distribution. +% +% 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. +% +% +% $Id: pdf_info.ps 6300 2005-12-28 19:56:24Z alexcher $ + +% Dump some info from a PDF file + +% usage: gs -dNODISPLAY -q -sFile=____.pdf [-dDumpMediaSizes=false] [-dDumpFontsNeeded=false] [-dDumpXML] +% [-dDumpFontsUsed [-dShowEmbeddedFonts] ] lib/pdf_info.ps + +128 dict begin + +/QUIET true def % in case they forgot + +/showoptions { + ( where "options" are:) = + ( -dDumpMediaSizes=false (default true) MediaBox and CropBox for each page) = + ( -dDumpFontsNeeded=false (default true)Fonts used, but not embedded) = + ( -dDumpXML print the XML Metadata from the PDF, if present) = + ( -dDumpFontsUsed List all fonts used) = + ( -dShowEmbeddedFonts only meaningful with -dDumpFontsUsed) = + (\n If no options are given, the default is -dDumpMediaSizes -dDumpFontsNeeded) = + () = + flush +} bind def + +/DumpMediaSizes where { pop } { /DumpMediaSizes true def } ifelse +/DumpFontsNeeded where { pop } { /DumpFontsNeeded true def } ifelse + +[ {.shellarguments} stopped not + { + { counttomark 1 eq { + dup 0 get (-) 0 get ne { + % File specified on the command line using: -- lib/pdf_info.ps infile.pdf + /File exch def + false % don't show usage + } { + true % show usage and quit + } ifelse + } { true } ifelse + { + (\n*** Usage: gs [options] -- lib/pdf_info.ps infile.pdf ***\n\n) print + showoptions + quit + } if + } if + } if +/File where not { + (\n *** Missing input file name \(use -sFile=____.pdf\)\n) = + ( usage: gs -dNODISPLAY -q -sFile=____.pdf [ options ] lib/pdf_info.ps\n) = + showoptions + quit +} if +cleartomark % discard the dict from --where-- + +% ---- No more executable code on the top level after this line ----- +% ---- except 2 lines at the very end ----- + +%% When checking Resources for Font objects, we must ensure that we don't end +%% up following a circular reference. Circular references in Resources should +%% not, of course, be present but we've seen a number of cases. If we do detect +%% a circular reference, then stop checking that chain. + +/oforce_no_circular { + dup type /packedarraytype eq { + dup 0 get + currentdict /ProcessedResources known { + dup ProcessedResources exch known { + pop pop //null + } { + dup ProcessedResources 3 1 roll put + oforce + } ifelse + } { + oforce + } ifelse + } { + oforce + } ifelse +} bind def + +/printXML { % <string> printXML - + % print non-blank lines without trailing spaces + dup dup length 1 sub -1 0 { + 1 index 1 index get 32 eq { + 0 exch getinterval exch + } { + exch = exit % non-blank on this line + } + ifelse + } for + pop pop % clean up +} bind def + +/dump-pdf-info { % (fname) -> - + () = ( ) print print ( has ) print + PDFPageCount dup =print 10 mod 1 eq { ( page.\n) } { ( pages\n) } ifelse = flush + + Trailer /Root oget /AcroForm knownoget { + /XFA knownoget { + (File uses XFA forms.\n\n) print + pop + } if + } if + + /DumpXML where { + pop + Trailer /Root oget /Metadata knownoget { + //false resolvestream + { dup 256 string readline exch printXML not { exit } if } loop + pop % done with the stream + (_____________________________________________________________) = + flush + } if + } if + + % Print out the "Info" dictionary if present + Trailer /Info knownoget { + dup /Title knownoget { (Title: ) print = flush } if + dup /Author knownoget { (Author: ) print = flush } if + dup /Subject knownoget { (Subject: ) print = flush } if + dup /Keywords knownoget { (Keywords: ) print = flush } if + dup /Creator knownoget { (Creator: ) print = flush } if + dup /Producer knownoget { (Producer: ) print = flush } if + dup /CreationDate knownoget { (CreationDate: ) print = flush } if + dup /ModDate knownoget { (ModDate: ) print = flush } if + dup /Trapped knownoget { (Trapped: ) print = flush } if + pop + } if + +} bind def + +% <page index> <page dict> dump-media-sizes - +/dump-media-sizes { + DumpMediaSizes { + () = + % Print out the Page Size info for each page. + (Page ) print =print + dup /UserUnit pget { + ( UserUnit: ) print =print + } if + dup /MediaBox pget { + ( MediaBox: ) print oforce_array ==only + } if + dup /CropBox pget { + ( CropBox: ) print oforce_array ==only + } if + dup /BleedBox pget { + ( BleedBox: ) print oforce_array ==only + } if + dup /TrimBox pget { + ( TrimBox: ) print oforce_array ==only + } if + dup /ArtBox pget { + ( ArtBox: ) print oforce_array ==only + } if + dup /Rotate pget { + ( Rotate = ) print =print + } if + dup /Annots pget { + pop + ( Page contains Annotations) print + } if + pageusestransparency { + ( Page uses transparency features) print + } if + () = flush + } + { + pop pop + } ifelse +} bind def + +% List of standard font names for use when we are showing the FontsNeeded +/StdFontNames [ + /Times-Roman /Helvetica /Courier /Symbol + /Times-Bold /Helvetica-Bold /Courier-Bold /ZapfDingbats + /Times-Italic /Helvetica-Oblique /Courier-Oblique + /Times-BoldItalic /Helvetica-BoldOblique /Courier-BoldOblique +] def + +/res-type-dict 10 dict begin + /Font { + { + exch pop oforce_no_circular + dup //null ne { + dup /DescendantFonts knownoget { + exch pop 0 get oforce_no_circular + %% Check to see if a potentail circular reference was detected. This could be a + %% false positive caused by other fonts using the same DescendantFont(s), but if + %% so then we've already cehcked them anyway. + dup //null eq { pop << >>} if + } if + dup /FontDescriptor knownoget { + dup /FontFile known 1 index /FontFile2 known or exch /FontFile3 known or + /ShowEmbeddedFonts where { pop pop //false } if { + pop % skip embedded fonts + } { + /BaseFont knownoget { % not embedded + 2 index exch //null put + } if + } ifelse + } { + /BaseFont knownoget { % no FontDescriptor, not embedded + 2 index exch //null put + } if + } ifelse + } { + pop + } ifelse + } forall % traverse the dictionary + } bind def + + /XObject { + { + exch pop oforce_no_circular + dup //null ne { + dup /Subtype knownoget { + /Form eq { + /Resources knownoget { + get-fonts-from-res + } if + } { + pop + } ifelse + } { + pop + } ifelse + } { + pop + } ifelse + } forall + } bind def + + /Pattern { + { + exch pop oforce_no_circular + dup //null ne { + /Resources knownoget { + get-fonts-from-res + } if + } { + pop + } ifelse + } forall + } bind def +currentdict end readonly def + +% <dict for fonts> <<res-dict>> get-fonts-from-res - +/get-fonts-from-res { + oforce_no_circular + dup //null ne { + { + oforce_no_circular + dup //null ne { + //res-type-dict 3 -1 roll + .knownget { + exec + } { + pop + } ifelse + } { + pop pop + } ifelse + } forall + } { + pop + } ifelse +} bind def + +currentdict /res-type-dict undef + +/getPDFfonts { % <dict for fonts> <page dict> getPDFfonts - + /ProcessedResources 10 dict def + dup /Resources pget { get-fonts-from-res } if + /Annots knownoget { + { oforce_no_circular + dup //null ne { + /AP knownoget { + { exch pop oforce_no_circular + dup //null ne { + dup /Resources knownoget { + get-fonts-from-res + } if + { exch pop oforce_no_circular + dup type /dicttype eq { + /Resources knownoget { + get-fonts-from-res + } if + } { + pop + } ifelse + } forall + } { + pop + } ifelse + } forall + } if + } { + pop + } ifelse + } forall + } if + pop + currentdict /ProcessedResources undef +} bind def + +/dump-fonts-used { % <dict for fonts> dump-fonts-used - + % If DumpFontsUsed is not true, then remove the 'standard' fonts from the list + systemdict /DumpFontsUsed known not { + StdFontNames { + 1 index 1 index known { 1 index 1 index undef } if + pop + } forall + } if + + % Now dump the FontsUsed dict into an array so we can sort it. + [ 1 index { pop } forall ] + { 100 string cvs exch 100 string cvs exch lt } .sort + + systemdict /DumpFontsUsed known + { + (\nFont or CIDFont resources used (plain name and ASCIIHEX string representation):) = + { 128 string cvs dup print ( ) print (<) print 128 string cvs {16 8 string cvrs print} forall (>) print (\n) print} forall + } { + DumpFontsNeeded { + dup length 0 gt { + (\nFonts Needed that are not embedded \(system fonts required\):) = + { ( ) print 128 string cvs dup print ( ) print (<) print {16 8 string cvrs print} forall (>) print (\n) print} forall + } { + pop + (\nNo system fonts are needed.) = + } ifelse + } { + pop + } ifelse + } ifelse + pop +} bind def + +% Copy selected subfiles to temporary files and return the file names +% as a PostScript names to protect them from restore. +% Currently, all PDF files in the Portfolio are extracted and returned. +% +% - pdf_collection_files [ /temp_file_name ... /temp_file_name +/pdf_collection_files { + mark + Trailer /Root oget + dup /Collection oknown { + /Names knownoget { + /EmbeddedFiles knownoget { + pdf_collection_names + } if + } if + } { + pop + } ifelse +} bind def + +% Output all the info about the file +/dump { % (title) -> - + /PDFPageCount pdfpagecount def + dump-pdf-info + % dict will be populated with fonts through a call to 'getPDFfonts' + % per page, then the contents dumped out in 'dump-fonts-used' + 1000 dict + + 1 1 PDFPageCount + { + dup pdfgetpage dup 3 -1 roll + dump-media-sizes + 1 index exch getPDFfonts + } for + + dump-fonts-used + +} bind def + +% Choose between collection vs plain file. +% Enumerate collections and apply the dump procedure. +/enum-pdfs { % - -> - + File (r) file runpdfbegin + pdf_collection_files + dup mark eq { + pop + File dump + runpdfend + } { + runpdfend + ] 0 1 2 index length 1 sub { + 2 copy get exch % [file ... ] file i + 1 add (0123456789) cvs % [file ... ] file (i+1) + File exch ( part ) exch concatstrings concatstrings + exch % [file ... ] (fname part i+1) file + dup type /filetype eq { + runpdfbegin + dump + runpdfend + closefile + } { + 1024 string cvs % .namestring is deprecated +% .namestring + dup (r) file + runpdfbegin + exch dump + runpdfend + deletefile + } ifelse + } for + pop + } ifelse +} bind def + +enum-pdfs +end +quit diff --git a/Master/tlpkg/tlgs/lib/pfbtopfa.ps b/Master/tlpkg/tlgs/lib/pfbtopfa.ps index 0e6301c2ea3..2b69c58f63a 100644 --- a/Master/tlpkg/tlgs/lib/pfbtopfa.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/ppath.ps b/Master/tlpkg/tlgs/lib/ppath.ps index f37a9c5d3be..5c571019d05 100644 --- a/Master/tlpkg/tlgs/lib/ppath.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/pphs.ps b/Master/tlpkg/tlgs/lib/pphs.ps index 84fd99f4db4..8605f2dd367 100644 --- a/Master/tlpkg/tlgs/lib/pphs.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/prfont.ps b/Master/tlpkg/tlgs/lib/prfont.ps index a44563827bb..059d2a08483 100644 --- a/Master/tlpkg/tlgs/lib/prfont.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/ps2ai.ps b/Master/tlpkg/tlgs/lib/ps2ai.ps index e82fc497cab..20ae204eb04 100644 --- a/Master/tlpkg/tlgs/lib/ps2ai.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/ps2epsi.ps b/Master/tlpkg/tlgs/lib/ps2epsi.ps index 86f1d2ff677..54621f92834 100644 --- a/Master/tlpkg/tlgs/lib/ps2epsi.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/rollconv.ps b/Master/tlpkg/tlgs/lib/rollconv.ps index 031747f141c..3a39e02122a 100644 --- a/Master/tlpkg/tlgs/lib/rollconv.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/stocht.ps b/Master/tlpkg/tlgs/lib/stocht.ps index dcfa5f7c6c2..8c9bb438303 100644 --- a/Master/tlpkg/tlgs/lib/stocht.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/traceimg.ps b/Master/tlpkg/tlgs/lib/traceimg.ps index 1bb256a19d2..4ab8720f4b7 100644 --- a/Master/tlpkg/tlgs/lib/traceimg.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/traceop.ps b/Master/tlpkg/tlgs/lib/traceop.ps index 7d98d4a0cda..ecd8ce271df 100644 --- a/Master/tlpkg/tlgs/lib/traceop.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/uninfo.ps b/Master/tlpkg/tlgs/lib/uninfo.ps index dc93b8e20eb..98e89062fd6 100644 --- a/Master/tlpkg/tlgs/lib/uninfo.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/viewcmyk.ps b/Master/tlpkg/tlgs/lib/viewcmyk.ps index 5cc76981b40..e4250bf1d21 100644 --- a/Master/tlpkg/tlgs/lib/viewcmyk.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/viewgif.ps b/Master/tlpkg/tlgs/lib/viewgif.ps index 423bfff0857..55a39862b2c 100644 --- a/Master/tlpkg/tlgs/lib/viewgif.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/viewmiff.ps b/Master/tlpkg/tlgs/lib/viewmiff.ps index 2b60ccd050c..39d715d04c2 100644 --- a/Master/tlpkg/tlgs/lib/viewmiff.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/viewpbm.ps b/Master/tlpkg/tlgs/lib/viewpbm.ps index ab4ede66878..ec355313767 100644 --- a/Master/tlpkg/tlgs/lib/viewpbm.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/viewpcx.ps b/Master/tlpkg/tlgs/lib/viewpcx.ps index 81531aff95f..6840f1e5c0f 100644 --- a/Master/tlpkg/tlgs/lib/viewpcx.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/viewps2a.ps b/Master/tlpkg/tlgs/lib/viewps2a.ps index 91e5894f957..e0fb32bdab6 100644 --- a/Master/tlpkg/tlgs/lib/viewps2a.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/viewraw.ps b/Master/tlpkg/tlgs/lib/viewraw.ps index ec1e1d7a67f..f1a3f890147 100644 --- a/Master/tlpkg/tlgs/lib/viewraw.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/viewrgb.ps b/Master/tlpkg/tlgs/lib/viewrgb.ps index 8b77dd2dd39..adde24e4c5d 100644 --- a/Master/tlpkg/tlgs/lib/viewrgb.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/winmaps.ps b/Master/tlpkg/tlgs/lib/winmaps.ps index 06da63aa9e8..75933fc2e9d 100644 --- a/Master/tlpkg/tlgs/lib/winmaps.ps +++ b/Master/tlpkg/tlgs/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/Master/tlpkg/tlgs/lib/zeroline.ps b/Master/tlpkg/tlgs/lib/zeroline.ps index 521b1de0447..7ace3ca323b 100644 --- a/Master/tlpkg/tlgs/lib/zeroline.ps +++ b/Master/tlpkg/tlgs/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 |