From 8abbce681f8658c931f1403643d08ad2e7fb6d7e Mon Sep 17 00:00:00 2001 From: Reinhard Kotucha Date: Thu, 2 Apr 2015 23:03:05 +0000 Subject: tlpkg/tlgs: upgrade: gs-9.15 -> gs-9.16 git-svn-id: svn://tug.org/texlive/trunk@36707 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/tlgs/README.TEXLIVE | 2 +- Master/tlpkg/tlgs/bin/gsdll32.dll | Bin 13139968 -> 14012416 bytes Master/tlpkg/tlgs/bin/gsdll32.lib | Bin 9838 -> 9838 bytes Master/tlpkg/tlgs/bin/gswin32.exe | Bin 151552 -> 151552 bytes Master/tlpkg/tlgs/bin/gswin32c.exe | Bin 143360 -> 143360 bytes Master/tlpkg/tlgs/lib/EndOfTask.ps | 1 - Master/tlpkg/tlgs/lib/FAPIconfig-FCO | 13 - Master/tlpkg/tlgs/lib/FCOfontmap-PCLPS3 | 197 -- Master/tlpkg/tlgs/lib/FCOfontmap-PS3 | 158 -- Master/tlpkg/tlgs/lib/Fontmap | 2 +- Master/tlpkg/tlgs/lib/Fontmap.TeXLive | 2 +- Master/tlpkg/tlgs/lib/bj8.rpd | 17 - Master/tlpkg/tlgs/lib/cat.ps | 74 - Master/tlpkg/tlgs/lib/dumphint.ps | 755 ----- Master/tlpkg/tlgs/lib/ghostpdf.inf | 44 - Master/tlpkg/tlgs/lib/gs_fform.ps | 91 - Master/tlpkg/tlgs/lib/jobseparator.ps | 3 - Master/tlpkg/tlgs/lib/opdfread.ps | 4694 ------------------------------- Master/tlpkg/tlgs/lib/pdfopt.ps | 15 +- Master/tlpkg/tlgs/lib/stcinfo.ps | 794 ------ Master/tlpkg/tlgs/lib/stcolor.ps | 169 -- Master/tlpkg/tlgs/lib/viewraw.ps | 142 +- 22 files changed, 137 insertions(+), 7036 deletions(-) delete mode 100644 Master/tlpkg/tlgs/lib/EndOfTask.ps delete mode 100644 Master/tlpkg/tlgs/lib/FAPIconfig-FCO delete mode 100644 Master/tlpkg/tlgs/lib/FCOfontmap-PCLPS3 delete mode 100644 Master/tlpkg/tlgs/lib/FCOfontmap-PS3 delete mode 100644 Master/tlpkg/tlgs/lib/bj8.rpd delete mode 100644 Master/tlpkg/tlgs/lib/cat.ps delete mode 100644 Master/tlpkg/tlgs/lib/dumphint.ps delete mode 100644 Master/tlpkg/tlgs/lib/ghostpdf.inf delete mode 100644 Master/tlpkg/tlgs/lib/gs_fform.ps delete mode 100644 Master/tlpkg/tlgs/lib/jobseparator.ps delete mode 100644 Master/tlpkg/tlgs/lib/opdfread.ps delete mode 100644 Master/tlpkg/tlgs/lib/stcinfo.ps delete mode 100644 Master/tlpkg/tlgs/lib/stcolor.ps (limited to 'Master/tlpkg/tlgs') diff --git a/Master/tlpkg/tlgs/README.TEXLIVE b/Master/tlpkg/tlgs/README.TEXLIVE index f24672968ed..f405a8d33a5 100644 --- a/Master/tlpkg/tlgs/README.TEXLIVE +++ b/Master/tlpkg/tlgs/README.TEXLIVE @@ -1,5 +1,5 @@ -This directory contains a subset of the Ghostscript 9.15 distribution +This directory contains a subset of the Ghostscript 9.16 distribution for Windows. The only purpose of this package is to support programs shipped with TeX Live. It's not intended for general use. diff --git a/Master/tlpkg/tlgs/bin/gsdll32.dll b/Master/tlpkg/tlgs/bin/gsdll32.dll index 9da961bfdab..791a5a6e7c9 100755 Binary files a/Master/tlpkg/tlgs/bin/gsdll32.dll and b/Master/tlpkg/tlgs/bin/gsdll32.dll differ diff --git a/Master/tlpkg/tlgs/bin/gsdll32.lib b/Master/tlpkg/tlgs/bin/gsdll32.lib index fe0bb1cc6dd..789cdd0c55b 100644 Binary files a/Master/tlpkg/tlgs/bin/gsdll32.lib and b/Master/tlpkg/tlgs/bin/gsdll32.lib differ diff --git a/Master/tlpkg/tlgs/bin/gswin32.exe b/Master/tlpkg/tlgs/bin/gswin32.exe index 1a735e26d63..fa1484ea5c0 100755 Binary files a/Master/tlpkg/tlgs/bin/gswin32.exe and b/Master/tlpkg/tlgs/bin/gswin32.exe differ diff --git a/Master/tlpkg/tlgs/bin/gswin32c.exe b/Master/tlpkg/tlgs/bin/gswin32c.exe index d37c04a0784..640d32f7d30 100755 Binary files a/Master/tlpkg/tlgs/bin/gswin32c.exe and b/Master/tlpkg/tlgs/bin/gswin32c.exe differ diff --git a/Master/tlpkg/tlgs/lib/EndOfTask.ps b/Master/tlpkg/tlgs/lib/EndOfTask.ps deleted file mode 100644 index ce9a8a9d59b..00000000000 --- a/Master/tlpkg/tlgs/lib/EndOfTask.ps +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Master/tlpkg/tlgs/lib/FAPIconfig-FCO b/Master/tlpkg/tlgs/lib/FAPIconfig-FCO deleted file mode 100644 index 6df21e3d6ab..00000000000 --- a/Master/tlpkg/tlgs/lib/FAPIconfig-FCO +++ /dev/null @@ -1,13 +0,0 @@ -%! -% This is configuration file for FAPI client. - -/FontPath () % A default directory for FAPI-handled font files path in FAPIfontmap. -/CIDFontPath () % A default directory for FAPI-handled CID font files path in FAPIcidfmap. -/HookDiskFonts [] % FontType values for disk PS fonts to be redirected to FAPI. -/HookEmbeddedFonts [] % FontType values for embedded PS fonts to be redirected to FAPI. - -% Values allowed for HookDiskFonts and HookEmbeddedFonts are 1, 2, 9, 11, 42. -% "Disk fonts" are fonts being installed to Ghostscript with 'lib/Fontmap' or with GS_FONTPATH, -% and CID font resource files. -% "Embedded fonts" are fonts and CID fonts being embedded into a document. - diff --git a/Master/tlpkg/tlgs/lib/FCOfontmap-PCLPS3 b/Master/tlpkg/tlgs/lib/FCOfontmap-PCLPS3 deleted file mode 100644 index 1cd79526947..00000000000 --- a/Master/tlpkg/tlgs/lib/FCOfontmap-PCLPS3 +++ /dev/null @@ -1,197 +0,0 @@ -% Copyright (C) 2001-2012 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., 7 Mt. Lassen Drive - Suite A-134, San Rafael, -% CA 94903, U.S.A., +1(415)492-9861, for further information. -% - - -% May add general FAPIfontmap records here like this : -/Wingdings-Regular << /Path FCOfontfile2 /FontType 1 /FAPI /UFST /SubfontId 0 /Encoding /Wingdings /Decoding /FCO_Wingdings>> ; - -% Mapping Postscript fonts to pclp2_xj.fco FCO members : -FCOfontfile ReadFCOfontmap: -0 Albertus-Medium -1 Albertus-ExtraBold -2 AntiqueOlive -3 AntiqueOlive-Italic -4 AntiqueOlive-Bold -5 Arial -6 Arial-Italic -7 Arial-Bold -8 Arial-BoldItalic -9 Clarendon-Condensed-Bold -10 Coronet -11 CourierHP -12 CourierHP-Italic -13 CourierHP-Bold -14 CourierHP-BoldItalic -15 Garamond-Antiqua -16 Garamond-Kursiv -17 Garamond-Halbfett -18 Garamond-KursivHalbfett -19 LetterGothic -20 LetterGothic-Italic -21 LetterGothic-Bold -22 Marigold -23 CGOmega -24 CGOmega-Italic -25 CGOmega-Bold -26 CGOmega-BoldItalic -27 SymbolMT SymbolEncoding FCO_Symbol -28 CGTimes -29 CGTimes-Italic -30 CGTimes-Bold -31 CGTimes-BoldItalic -32 TimesNewRoman -33 TimesNewRoman-Italic -34 TimesNewRoman-Bold -35 TimesNewRoman-BoldItalic -36 Univers-Medium -37 Univers-MediumItalic -38 Univers-Bold -39 Univers-BoldItalic -40 Univers-Condensed-Medium -41 Univers-Condensed-MediumItalic -42 Univers-Condensed-Bold -43 Univers-Condensed-BoldItalic -44 Courier -45 Courier-Italic -46 Courier-Bold -47 Courier-BoldItalic -48 AlbertusMT-Light -49 AlbertusMT -50 AlbertusMT-Italic -51 AntiqueOlive-Roman -52 AntiqueOlive-Italic -53 AntiqueOlive-Bold -54 AntiqueOlive-Compact -55 AvantGarde-Book -56 AvantGarde-BookOblique -57 AvantGarde-Demi -58 AvantGarde-DemiOblique -59 Bodoni -60 Bodoni-Italic -61 Bodoni-Bold -62 Bodoni-BoldItalic -63 Bodoni-Poster -64 Bodoni-PosterCompressed -65 Bookman-Light -66 Bookman-LightItalic -67 Bookman-Demi -68 Bookman-DemiItalic -69 Candid -70 Apple-Chancery -71 Chicago -72 Clarendon-Light -73 Clarendon -74 Clarendon-Bold -75 CooperBlack -76 CooperBlack-Italic -77 Copperplate-ThirtyTwoBC -78 Copperplate-ThirtyThreeBC -79 Coronet-Regular -80 Courier -81 Courier-Oblique -82 Courier-Bold -83 Courier-BoldOblique -84 Eurostile -85 Eurostile-Bold -86 Eurostile-ExtendedTwo -87 Eurostile-BoldExtendedTwo -88 StempelGaramond-Roman -89 StempelGaramond-Italic -90 StempelGaramond-Bold -91 StempelGaramond-BoldItalic -92 Geneva -93 GillSans-Light -94 GillSans-LightItalic -95 GillSans -96 GillSans-Italic -97 GillSans-Bold -98 GillSans-BoldItalic -99 GillSans-ExtraBold -100 GillSans-Condensed -101 GillSans-BoldCondensed -102 Goudy -103 Goudy-Italic -104 Goudy-Bold -105 Goudy-BoldItalic -106 Goudy-ExtraBold -107 Helvetica-Condensed -108 Helvetica-Condensed-Oblique -109 Helvetica-Condensed-Bold -110 Helvetica-Condensed-BoldObl -111 Helvetica -112 Helvetica-Oblique -113 Helvetica-Bold -114 Helvetica-BoldOblique -115 Helvetica-Narrow -116 Helvetica-Narrow-Oblique -117 Helvetica-Narrow-Bold -118 Helvetica-Narrow-BoldOblique -119 HoeflerText-Regular -120 HoeflerText-Italic -121 HoeflerText-Black -122 HoeflerText-BlackItalic -123 HoeflerText-Ornaments -124 JoannaMT -125 JoannaMT-Italic -126 JoannaMT-Bold -127 JoannaMT-BoldItalic -128 LetterGothic -129 LetterGothic-Slanted -130 LetterGothic-Bold -131 LetterGothic-BoldSlanted -132 LubalinGraph-Book -133 LubalinGraph-BookOblique -134 LubalinGraph-Demi -135 LubalinGraph-DemiOblique -136 Monaco -137 MonaLisa-Recut -138 NewYork -139 NewCenturySchlbk-Roman -140 NewCenturySchlbk-Italic -141 NewCenturySchlbk-Bold -142 NewCenturySchlbk-BoldItalic -143 Optima -144 Optima-Italic -145 Optima-Bold -146 Optima-BoldItalic -147 Oxford -148 Palatino-Roman -149 Palatino-Italic -150 Palatino-Bold -151 Palatino-BoldItalic -152 Symbol SymbolEncoding FCO_Symbol -153 Taffy -154 Times-Roman -155 Times-Italic -156 Times-Bold -157 Times-BoldItalic -158 Univers -159 Univers-Oblique -160 Univers-Bold -161 Univers-BoldOblique -162 Univers-Condensed -163 Univers-CondensedOblique -164 Univers-CondensedBold -165 Univers-CondensedBoldOblique -166 Univers-Light -167 Univers-LightOblique -168 Univers-Extended -169 Univers-ExtendedObl -170 Univers-BoldExt -171 Univers-BoldExtObl -172 ZapfChancery-MediumItalic -173 ZapfDingbats DingbatsEncoding FCO_Dingbats -EndFCOfontmap -%EOF diff --git a/Master/tlpkg/tlgs/lib/FCOfontmap-PS3 b/Master/tlpkg/tlgs/lib/FCOfontmap-PS3 deleted file mode 100644 index 0962cfcef4c..00000000000 --- a/Master/tlpkg/tlgs/lib/FCOfontmap-PS3 +++ /dev/null @@ -1,158 +0,0 @@ -% Copyright (C) 2001-2012 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., 7 Mt. Lassen Drive - Suite A-134, San Rafael, -% CA 94903, U.S.A., +1(415)492-9861, for further information. -% - - -% May add general FAPIfontmap records here like this : -/Wingdings-Regular << /Path FCOfontfile2 /FontType 1 /FAPI /UFST /SubfontId 0 /Encoding /Wingdings /Decoding /FCO_Wingdings>> ; - -% Mapping Postscript fonts to ps3___xh.fco FCO members : -FCOfontfile ReadFCOfontmap: -0 AlbertusMT-Light -1 AlbertusMT -2 AlbertusMT-Italic -3 AntiqueOlive-Roman -4 AntiqueOlive-Italic -5 AntiqueOlive-Bold -6 AntiqueOlive-Compact -7 ArialMT -8 Arial-ItalicMT -9 Arial-BoldMT -10 Arial-BoldItalicMT -11 AvantGarde-Book -12 AvantGarde-BookOblique -13 AvantGarde-Demi -14 AvantGarde-DemiOblique -15 Bodoni -16 Bodoni-Italic -17 Bodoni-Bold -18 Bodoni-BoldItalic -19 Bodoni-Poster -20 Bodoni-PosterCompressed -21 Bookman-Light -22 Bookman-LightItalic -23 Bookman-Demi -24 Bookman-DemiItalic -% 25 Candid % Disabled due to unknown glyph names. -26 Apple-Chancery -27 Chicago -28 Clarendon-Light -29 Clarendon -30 Clarendon-Bold -31 CooperBlack -32 CooperBlack-Italic -33 Copperplate-ThirtyTwoBC -34 Copperplate-ThirtyThreeBC -35 Coronet-Regular -36 Courier -37 Courier-Oblique -38 Courier-Bold -39 Courier-BoldOblique -40 Eurostile -41 Eurostile-Bold -42 Eurostile-ExtendedTwo -43 Eurostile-BoldExtendedTwo -44 StempelGaramond-Roman -45 StempelGaramond-Italic -46 StempelGaramond-Bold -47 StempelGaramond-BoldItalic -48 Geneva -49 GillSans-Light -50 GillSans-LightItalic -51 GillSans -52 GillSans-Italic -53 GillSans-Bold -54 GillSans-BoldItalic -55 GillSans-ExtraBold -56 GillSans-Condensed -57 GillSans-BoldCondensed -58 Goudy -59 Goudy-Italic -60 Goudy-Bold -61 Goudy-BoldItalic -62 Goudy-ExtraBold -63 Helvetica-Condensed -64 Helvetica-Condensed-Oblique -65 Helvetica-Condensed-Bold -66 Helvetica-Condensed-BoldObl -67 Helvetica -68 Helvetica-Oblique -69 Helvetica-Bold -70 Helvetica-BoldOblique -71 Helvetica-Narrow -72 Helvetica-Narrow-Oblique -73 Helvetica-Narrow-Bold -74 Helvetica-Narrow-BdOblique -75 HoeflerText-Regular -76 HoeflerText-Italic -77 HoeflerText-Black -78 HoeflerText-BlackItalic -79 HoeflerText-Ornaments -80 JoannaMT -81 JoannaMT-Italic -82 JoannaMT-Bold -83 JoannaMT-BoldItalic -84 LetterGothic -85 LetterGothic-Slanted -86 LetterGothic-Bold -87 LetterGothic-BoldSlanted -88 LubalinGraph-Book -89 LubalinGraph-BookOblique -90 LubalinGraph-Demi -91 LubalinGraph-DemiOblique -92 Marigold -93 Monaco -94 MonaLisa-Recut -95 NewYork -96 NewCenturySchlbk-Roman -97 NewCenturySchlbk-Italic -98 NewCenturySchlbk-Bold -99 NewCenturySchlbk-BoldItalic -100 Optima -101 Optima-Italic -102 Optima-Bold -103 Optima-BoldItalic -104 Oxford -105 Palatino-Roman -106 Palatino-Italic -107 Palatino-Bold -108 Palatino-BoldItalic -109 Symbol SymbolEncoding FCO_Symbol -110 Taffy -111 Times-Roman -112 Times-Italic -113 Times-Bold -114 Times-BoldItalic -115 TimesNewRomanPSMT -116 TimesNewRomanPS-ItalicMT -117 TimesNewRomanPS-BoldMT -118 TimesNewRomanPS-BdItMT -119 Univers -120 Univers-Oblique -121 Univers-Bold -122 Univers-BoldOblique -123 Univers-Condensed -124 Univers-CondensedOblique -125 Univers-CondensedBold -126 Univers-CondensedBdOblique -127 Univers-Light -128 Univers-LightOblique -129 Univers-Extended -130 Univers-ExtendedObl -131 Univers-BoldExt -132 Univers-BoldExtObl -133 ZapfChancery-MediumItalic -134 ZapfDingbats DingbatsEncoding FCO_Dingbats -EndFCOfontmap -%EOF diff --git a/Master/tlpkg/tlgs/lib/Fontmap b/Master/tlpkg/tlgs/lib/Fontmap index 04702bb5e72..b9b9951a231 100644 --- a/Master/tlpkg/tlgs/lib/Fontmap +++ b/Master/tlpkg/tlgs/lib/Fontmap @@ -1,5 +1,5 @@ %! -%% $Id: Fontmap 7680 2008-04-27 12:21:15Z reinhardk $ +%% $Id$ % See Fontmap.TeXLive for the syntax of real Fontmap files. %% Replace 1 (Fontmap.TeXLive) diff --git a/Master/tlpkg/tlgs/lib/Fontmap.TeXLive b/Master/tlpkg/tlgs/lib/Fontmap.TeXLive index ed079d50fc1..3dc7fe38cef 100644 --- a/Master/tlpkg/tlgs/lib/Fontmap.TeXLive +++ b/Master/tlpkg/tlgs/lib/Fontmap.TeXLive @@ -1,5 +1,5 @@ %% Fontmap.TeXLive -%% $Id: Fontmap.TeXLive 7680 2008-04-27 12:21:15Z reinhardk $ +%% $Id$ %% This file is part of TeXLive. %% You may freely use, modify and/or distribute this file. diff --git a/Master/tlpkg/tlgs/lib/bj8.rpd b/Master/tlpkg/tlgs/lib/bj8.rpd deleted file mode 100644 index fce6c2d4b7d..00000000000 --- a/Master/tlpkg/tlgs/lib/bj8.rpd +++ /dev/null @@ -1,17 +0,0 @@ - -StartEntry: U_CanonBJC8200 -GSDriver: uniprint -Description: {Canon BJC-8200 (UP)} -About: { \ - Canon BJC-8200 uniprint driver settings.\ - } -Resolution: {NA} {NA} {} - BitsPerPixel: {bj8pp12f} {1200x1200DpI, photo paper pro, color, rendered} - BitsPerPixel: {bj8hg12f} {1200x1200DpI, high gloss photo film, color, rendered} - BitsPerPixel: {bj8gc12f} {1200x1200DpI, glossy photo cards, color, rendered} - BitsPerPixel: {bj8oh06n} {600x600DpI, transparencies, color, rendered} - BitsPerPixel: {bj8ts06n} {600x600DpI, t-shirt transfer, color, rendered} - BitsPerPixel: {bj8pa06n} {600x600DpI, plain paper, color, rendered} - -EndEntry -# diff --git a/Master/tlpkg/tlgs/lib/cat.ps b/Master/tlpkg/tlgs/lib/cat.ps deleted file mode 100644 index 1dec040db76..00000000000 --- a/Master/tlpkg/tlgs/lib/cat.ps +++ /dev/null @@ -1,74 +0,0 @@ -% Copyright (C) 2001-2012 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., 7 Mt. Lassen Drive - Suite A-134, San Rafael, -% CA 94903, U.S.A., +1(415)492-9861, for further information. -% -% -% $Id: cat.ps 8331 2008-02-05 11:07:00Z kens $ -% -% Appends one file to another. Primarily used to overcome the -% 'copy' limitation of Windows command shell for ps2epsi -% -% the files to be appended are given by the environament -% variables %infile% and %outfile%. %infile% is appended to -% %outfile% -% - -/datastring 1024 string def - -{ - (outfile) getenv - { - /outfilename exch def - (infile) getenv - { - /infilename exch def - - infilename status - { - pop pop pop pop outfilename status - { - pop pop pop pop - infilename (r) file /infile exch def - outfilename (a+) file /outfile exch def - { - infile datastring readstring - { - outfile exch writestring - } - { - dup length 0 gt - {outfile exch writestring} {pop} ifelse - exit - } ifelse - } loop - infile closefile - outfile closefile - } - { - (Failed to find file ) print outfilename == - } ifelse - } - { - (Failed to find file ) print infilename == - } ifelse - } - { - (Couldn't find %infile% environment variable) == - } ifelse - } - { - (Couldn't find %outfile% environment variable) == - } - ifelse -} bind -exec diff --git a/Master/tlpkg/tlgs/lib/dumphint.ps b/Master/tlpkg/tlgs/lib/dumphint.ps deleted file mode 100644 index 444692a0c83..00000000000 --- a/Master/tlpkg/tlgs/lib/dumphint.ps +++ /dev/null @@ -1,755 +0,0 @@ -% Copyright (C) 2000, 2001 Aladdin Enterprises. 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. -% -% For more information about licensing, please refer to -% http://www.ghostscript.com/licensing/. For information on -% commercial licensing, go to http://www.artifex.com/licensing/ or -% contact Artifex Software, Inc., 101 Lucas Valley Road #110, -% San Rafael, CA 94903, U.S.A., +1(415)492-9861. - -% $Id$ -% Linearized PDF hint formatting utility. - -% -% Linearized PDF hints generated by Acrobat suite seem to deviate from -% the published specification. -% -% /P (page offset hint table) key in hint stream is not generated by -% Adobe products. The key is no longer required in PDF 1.5. -% -% Per-page items 4 and 5 of the page offset hint table start from 1st -% page rather than 2nd page as the spec claims. -% -% All array entries start from the new byte boundary. -% - -/table_width 79 def -/col1_width 66 def - -% Skip bits to the next byte boundary -/bytealign { % bytealign - - begin /N 0 def /B 0 def end -} bind def - -% Set bit stream position and align it to byte boundary -/set_align { % <<>> pos set_align - - exch begin - S exch setfileposition - /N 0 def /B 0 def - end -} bind def - -% Read requested number of bits from the bit stream. -/bitread { % bitwrite - exch begin - 0 % bit val - { - 1 index N .min % bit val m - dup 3 1 roll % bit m val m - bitshift % bit m val<>(N-m) - 3 -1 roll % m val' bit - 2 index sub % m val' bit' - 3 -1 roll % val' bit' m - N exch sub dup % val' bit' N' N' - 1 exch bitshift % val' bit' N' 1<)= - } { - hint_stream /S get 128 string - readstring pop - dup length 128 eq { - == - } { pop (Error reading nd5 string.) == - } ifelse - } ifelse - } forall - } { - () = (none) = - } ifelse - - (4. The number of objects in the group.) array_header - hint_stream bytealign - /shint_group_cnt [ - shint_all_shared { - hint_stream shint_group_bits bitread - } repeat - ] readonly def - - shint_group_cnt dump_array - - } bind def - -% Analyze the thumbnail hint table. -/dump_thumbnail_table { - hint_stream - - dup 32 bitread - dup /thint_1st_obj_id exch def - (1. Object number of the first thumbnail image.) two_column - - dup 32 bitread - dup /thint_1st_obj_pos exch def - (2. Location of the first thumbnail image.) two_column - - dup 32 bitread - dup /thint_page_cnt exch def - (3. Number of pages that have thumbnail images.) two_column - - dup 16 bitread - dup /thint_no_thumbnail_bits exch def - (4. Bits for the max number of consecutive pages without a thumbnail image.) two_column - - dup 32 bitread - dup /thint_min_sz exch def - (5. The least length of a thumbnail image in bytes.) two_column - - dup 15 bitread - dup /thint_obj_sz_bits exch def - (6. Bits for the difference between max and min length of a thumbnail image.) two_column - - dup 32 bitread - dup /thint_min_obj_cnt exch def - (7. The least number of objects in a thumbnail image.) two_column - - dup 16 bitread - dup /thint_obj_cnt_bits exch def - (8. Bits for the difference between max and min number of objects in a thumbnail image.) two_column - - dup 32 bitread - dup /thint_1st_shared_obj exch def - (9. First object in the thumbnail shared objects section.) two_column - - dup 32 bitread - dup /thint_1st_shared_pos exch def - (10. Location of the first object in the thumbnail shared objects section.) two_column - - dup 32 bitread - dup /thint_shared_cnt exch def - (11. Number of thumbnail shared objects.) two_column - - dup 32 bitread - dup /thint_shared_section_sz exch def - (12. Length of the thumbnail shared objects section in bytes.) two_column - - pop - LinearizationParams /N get - - (1. The number of preceding pages lacking a thumbnail image.) array_header - hint_stream bytealign - /thint_no_thumbnail_pages [ - 2 index { - hint_stream thint_no_thumbnail_bits bitread - } repeat - ] readonly def - - thint_no_thumbnail_pages dump_array - - (2. Number of objects in this page's thumbnail image.) array_header - hint_stream bytealign - /thint_page_obj_cnt [ - 2 index { - hint_stream thint_obj_cnt_bits bitread - thint_min_obj_cnt add - } repeat - ] readonly def - - thint_page_obj_cnt dump_array - - (3. Length of this page's thumbnail image in bytes.) array_header - hint_stream bytealign - /thint_page_obj_sz [ - 2 index { - hint_stream thint_obj_sz_bits bitread - thint_min_sz add - } repeat - ] readonly def - - thint_page_obj_sz dump_array - pop -} bind def - -% Analyze the generic hint table. -% The hint field names are re-used. -/dump_generic_table { - hint_stream - - dup 32 bitread - dup /ghint_1st_obj exch def - (1. Object number of the first object in the group.) two_column - - dup 32 bitread - dup /ghint_1st_obj_pos exch def - (2. Location of the first object in the group.) two_column - - dup 32 bitread - dup /ghint_obj_cnt exch def - (3. Number of objects in the group.) two_column - - dup 32 bitread - dup /ghint_group_sz exch def - (4. Length of the object group in bytes.) two_column - - pop -} bind def - -% Analyze the interactive hint table. -% The hint field names are re-used. -/dump_interactive_table { - hint_stream - - dup 32 bitread - dup /ihint_1st_obj exch def - (1. Object number of the first object in the group.) two_column - - dup 32 bitread - dup /ihint_1st_obj_pos exch def - (2. Location of the first object in the group.) two_column - - dup 32 bitread - dup /ihint_obj_cnt exch def - (3. Number of objects in the group.) two_column - - dup 32 bitread - dup /ihint_group_sz exch def - (4. Length of the object group in bytes.) two_column - - dup 32 bitread - dup /ihint_shared_cnt exch def - (5. Number of shared object references.) two_column - - dup 16 bitread - dup /ihint_shared_obj_bits exch def - (6. Bits for the max shared object id used by the interactive form or the logical structure hierarchy.) - 1 index hint_sobits ne { - (\n*** This fiels is not equal to max shared object ID bits ***) concatstrings - } if - - pop - - (7. Shared object identifier.) array_header - hint_stream bytealign - /ihint_shared_obj_id [ - ihint_shared_cnt { - hint_stream hint_sobits bitread - } repeat - ] readonly def - - ihint_shared_obj_id dump_array -} bind def - -% Enumerate all documented hint tables. -/dump_all_tables { % <> dump_all_tables - - (Page offset hint table) table_header - hint_stream 0 set_align - dump_page_offset_table - - (S, Shared object hint table) table_header - dup /S .knownget { - hint_stream exch set_align - dump_shared_object_table - } { - (Required table is not found.) error_msg - } ifelse - - dup /T .knownget { - (T, Thumbnail hint table) table_header - hint_stream exch set_align - dump_thumbnail_table - } if - - dup /O .knownget { - (O, Outline hint table) table_header - hint_stream exch set_align - dump_generic_table - } if - - dup /A .knownget { - (A, Thread information hint table) table_header - hint_stream exch set_align - dump_generic_table - } if - - dup /E .knownget { - (E, Named destination hint table) table_header - hint_stream exch set_align - dump_generic_table - } if - - dup /V .knownget { - (V, Interactive form hint table) table_header - hint_stream exch set_align - dump_interactive_table - } if - - dup /I .knownget { - (I, Information dictionary hint table) table_header - hint_stream exch set_align - dump_generic_table - } if - - dup /C .knownget { - (C, Logical structure hint table) table_header - hint_stream exch set_align - dump_interactive_table - } if - - dup /L .knownget { - (L, Page label hint table) table_header - hint_stream exch set_align - dump_generic_table - } if - - pop -} bind def - -% Load PDF file and extract the hint stream. -/pdf_dump_hints { % pdf_dump_hints - - dup (r) file % fname - false exch % fname F file - { - dup 7 string readstring pop % fname F file () - (%PDF-1.) ne { pop exit } if % fname F file - dup 0 setfileposition - dup token not { pop exit } if % fname F file obj - dup type /integertype ne { pop exit } if % fname F file obj - 1 index token not { pop pop exit } if % fname F file obj gen - dup type /integertype ne {pop pop exit}if % fname F file obj gen - 4 2 roll % fname obj gen F file - dup 0 setfileposition - exch true or % fname obj gen file T - exit - } loop - { - pdfdict begin - pdfopenfile dup begin - 40 dict begin - /IDict exch def - .setsafe - - % Read all objects into memory. - Trailer touch - resolveR % fname <<>> - dup /Linearized known { - dup /L get % fname <<>> Len - 3 -1 roll status not { 0 0 0 0 } if % <<>> Len - pop pop exch pop % <<>> Len len - eq { - /LinearizationParams exch def - LinearizationParams /H get - dup length 2 eq { - 0 get PDFoffset add PDFfile exch setfileposition - PDFfile token pop - PDFfile token pop - resolveR dup true resolvestream - /ReusableStreamDecode filter - bitstream dup bytealign - /hint_stream exch def - - dump_all_tables - } { - pop - (Overflow hint stream is not supported.) = - } ifelse - } { - pop - (Wrong file length in linearization dictionary.) = - } ifelse - } { - pop (The file is not linearized.) = - } ifelse - end % temporary dict - end % IDict - end - } { - pop - (Input file is not a valid PDF file.) = - } ifelse -} bind def - -% Initial setup -/dump_hints { - counttomark 1 eq { - exch pop - save exch - 3000000 setvmthreshold - pdfoptdict begin - pdf_dump_hints - end - restore - true - } { - cleartomark false - } ifelse -} bind def - -/shellarguments {false} def -(pdfopt.ps) runlibfile -currentdict /shellarguments undef - -% Check for command line arguments. -mark shellarguments { - dump_hints not { - (Usage: gs -dNODISPLAY -- dumphint.ps input.pdf) = flush - } if -} { - pop -} ifelse - -% EOF diff --git a/Master/tlpkg/tlgs/lib/ghostpdf.inf b/Master/tlpkg/tlgs/lib/ghostpdf.inf deleted file mode 100644 index a3536f7c6c3..00000000000 --- a/Master/tlpkg/tlgs/lib/ghostpdf.inf +++ /dev/null @@ -1,44 +0,0 @@ -; GHOSTPDF.INF (for Windows 2k, XP and XP x64 edition) - -[Version] -Signature="$Windows NT$" -Provider=Ghostgum Software Pty Ltd -ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318} -Class=Printer -CatalogFile=oemprint.cat - -DriverVer=01/02/2007,1.0.0.1 - -; Manufacturer section -[Manufacturer] -"Ghostscript"=Ghostscript,NTamd64,NTia64 - -; Model sections -[Ghostscript] -"Ghostscript PDF" = GHOSTPDF.PPD, Ghostscript_PDF, Ghostscript_PDF_Writer - -[Ghostscript.NTamd64] -"Ghostscript PDF" = GHOSTPDF.PPD, Ghostscript_PDF, Ghostscript_PDF_Writer - -[Ghostscript.NTia64] -"Ghostscript PDF" = GHOSTPDF.PPD, Ghostscript_PDF, Ghostscript_PDF_Writer - -; Installer section -[GHOSTPDF.PPD] -CopyFiles=@GHOSTPDF.PPD -DataSection=PSCRIPT_DATA -Include=NTPRINT.INF -Needs=PSCRIPT.OEM - -[DestinationDirs] -DefaultDestDir=66000 - -[SourceDisksNames] -1=%Disk1%,,,"" - -[SourceDisksFiles] -GHOSTPDF.PPD =1 - -[Strings] -Disk1="Ghostscript PPD Setup Disk 1" -; end of ghostpdf.inf diff --git a/Master/tlpkg/tlgs/lib/gs_fform.ps b/Master/tlpkg/tlgs/lib/gs_fform.ps deleted file mode 100644 index 235ce5af72c..00000000000 --- a/Master/tlpkg/tlgs/lib/gs_fform.ps +++ /dev/null @@ -1,91 +0,0 @@ -% Copyright (C) 2001-2012 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., 7 Mt. Lassen Drive - Suite A-134, San Rafael, -% CA 94903, U.S.A., +1(415)492-9861, for further information. -% - -% Form caching implemented in PostScript. - -% This implementation doesn't do the right thing about halftone or -% Pattern phase, but the Pattern cache doesn't either.... - -% The Form cache key is the Form dictionary; the value is an array -% of 2 elements [CTM pattern_instance]. -% -% In order to prevent restore from clearing the cache, we explicitly -% push the cache entries on the stack before a restore and reinstall them. -currentglobal false setglobal -/.formcachedict 20 dict def % must be local -true setglobal -/restore { - mark .formcachedict { } forall - counttomark 1 add index { //restore } .internalstopped - { cleartomark //restore } - { counttomark 2 idiv { .formcachedict 3 1 roll put } repeat pop pop } - ifelse -} bind odef - -/.execform1 { - dup /Implementation known not { - dup /FormType get 1 ne { /rangecheck signalerror } if - % The Implementation is a Pattern that will draw the form. - currentglobal 1 index gcheck setglobal - % Stack: form global - 10 dict begin - /PatternType 1 def - /PaintType 1 def % colored - /TilingType 1 def % irrelevant - % Copy the BBox to the correct VM. - /BBox 2 index /BBox get 4 array copy exch 1 index def - % Set XStep and YStep to very large numbers, - % so we won't get multiple copies of the form. - /XStep 1 index dup 2 get exch 0 get sub 100 mul def - /YStep exch dup 3 get exch 1 get sub 100 mul def - /PaintProc 2 index /PaintProc get def - currentdict end readonly - % Stack: form global impl - exch setglobal - 1 index /Implementation 3 -1 roll .forceput - } if - .formcachedict 1 index .knownget { - % Check whether we can use the cached value. - % Stack: form cachevalue - matrix currentmatrix true 0 1 3 { - % Stack: form cachevalue curmat true index - 3 index 0 get 1 index get exch 3 index exch get ne { - pop pop false exit - } if - } for exch pop - } { - false - } ifelse not - { % Make a new cache entry. - gsave - matrix currentmatrix dup 4 0 put dup 5 0 put dup setmatrix - % Stack: form mat - 1 index /Implementation get - 2 index /Matrix get - makepattern 2 array astore - .formcachedict 2 index 2 index put - grestore - } if - % Stack: form cachevalue - -1 0 0 transform - 2 { exch round cvi } repeat .setscreenphase - 1 get setpattern - /BBox get aload pop - exch 3 index sub exch 2 index sub rectfill -} .bind odef % must bind .forceput - -.formtypes 1 /.execform1 load put - -setglobal diff --git a/Master/tlpkg/tlgs/lib/jobseparator.ps b/Master/tlpkg/tlgs/lib/jobseparator.ps deleted file mode 100644 index fbb6920842f..00000000000 --- a/Master/tlpkg/tlgs/lib/jobseparator.ps +++ /dev/null @@ -1,3 +0,0 @@ -% Execute the "real" system version of the ^D to separate jobs -% when -dJOBDSERVER is being used. -<04> cvn .systemvar exec diff --git a/Master/tlpkg/tlgs/lib/opdfread.ps b/Master/tlpkg/tlgs/lib/opdfread.ps deleted file mode 100644 index 62da258f098..00000000000 --- a/Master/tlpkg/tlgs/lib/opdfread.ps +++ /dev/null @@ -1,4694 +0,0 @@ -%!PS-Adobe-2.0 -% -% Copyright (C) 2001-2012 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., 7 Mt. Lassen Drive - Suite A-134, San Rafael, -% CA 94903, U.S.A., +1(415)492-9861, for further information. -% - -% $Id: opdfread.ps 11951 2010-12-15 08:22:58Z ken $ -% pdfread.ps - A procset for interpreting an ordered PDF 1.3 file. - -% This module defines routines for interpreting a PDF file with -% a Postscript interpreter. To convert a PDF file into Postscript -% just pre-contcatenate this file. The PDF file must satisfy -% few constraints : -% -% 1. It must contain only Postscript level 2 objects encoded with -% the PDF 1.3 language. Higher PDF levels must be re-distilled -% with CompatibilityLevel=1.3 . -% -% 2. Objects must be ordered so that any resource be defined before -% its usage. -% -% 3. The PDF file must not include other PDF files. -% Consequently we have a single instance of the PDF reader. -% We use this fact to simplify binding of the routines. -% -% 4. The PDF root object must always have the object id 1. -% -% 5. Generations besides 0 are not allowed. -% -% 6. xref must appear after all objects. -% -% Assuming the currentfile isn't positionable. -% As a consequence, the reader fully ignores xref. - -% ====================== Error handler ======================= -% A general error handler prints an error to page. - -% -% See if our notification from ps2write is present. If it is -% then pick it up. Otherwise define it as false. Used to prevent -% use of setmatrix at start of each page. The DSC-compliant -% output from ps2write wraps pages in a save/restore, so we don't -% need the setmatrix, and it breaks use of psnup with the output. -% -currentdict /DSC_OPDFREAD known { - currentdict /DSC_OPDFREAD get -}{ - false -} ifelse - -10 dict begin % A dictionary for local binding - -% This switch used to control paeg independent values, like -% whether to use InitialMatrix in SetupPageView -% -/DSC_OPDFREAD exch def - -/this currentdict def -/y 720 def -/ebuf 200 string def - -/prnt { - 36 //this /y get moveto //ebuf cvs show - //this /y 2 copy get 12 sub put -} bind def - -/newline { - 36 //this /y get moveto - //this /y 2 copy get 12 sub put -} bind def - -errordict /handleerror -{ systemdict begin - $error begin - newerror - { (%%[ Error handled by opdfread.ps : ) print errorname //ebuf cvs print (; OffendingCommand: ) - print /command load //ebuf cvs print ( ]%%) = flush - /newerror false store vmstatus pop pop 0 ne - { grestoreall - } if - errorname (VMerror) ne - { showpage - } if - initgraphics - 0 720 moveto - errorname (VMerror) eq - { //this /ehsave known - { clear //this /ehsave get restore 2 vmreclaim - } if - vmstatus exch pop exch pop - } - /Courier 12 selectfont - { - (ERROR: ) //prnt exec errorname //prnt exec - (OFFENDING COMMAND: ) //prnt exec - /command load //prnt exec - $error /ostack known { - (%%[STACK:) = - (STACK:) //prnt exec - $error /ostack get aload length { - //newline exec - dup mark eq { - (-mark-) dup = show - } { - dup type /nametype eq { - dup xcheck not { - (/) show - (/) print - } if - } if - dup = //ebuf cvs show - } ifelse - } repeat - } if - } ifelse - (%%]%) = - //systemdict /showpage get exec - quit - } if - end - end -} bind readonly put - -end % A dictionary for local binding - - -50 dict begin - -% ===================== Debugging ========================================= - -/DefaultSwitch % DefaultSwitch - -{ - dup where { - pop pop - } { - false def - } ifelse -} bind def - -/=string 256 string def - -/=only { - //=string cvs print -} bind def - -/HexDigits (0123456789ABCDEF) readonly def - -%% This routine assumes that a PostScript int is only 32 bits -%% we partially address that by and'ing 15 with the 4 bits of -%% data in order to ensure that we don't index off the end of -%% the string above. However, if the integer is genuinely -%% more than 32 bits we still only print the first 32. -/PrintHex % PrintHex - -{ 8 { - dup -28 bitshift 15 and //HexDigits exch 1 getinterval //=only exec - 4 bitshift - } repeat - pop -} bind def - -/PDFR_DEBUG DefaultSwitch -/PDFR_DUMP DefaultSwitch -/PDFR_STREAM DefaultSwitch -/TTFDEBUG DefaultSwitch -/RotatePages DefaultSwitch -/FitPages DefaultSwitch -/CenterPages DefaultSwitch -/SetPageSize DefaultSwitch - -/error % mark .... error - -{ % A stub for a while. - counttomark 1 sub -1 0 { - index dup type /arraytype eq { == } { =only } ifelse - } for - () = - cleartomark - % Assuming ....Undefined is never defined. - % Use it to emit an error. - ....Undefined -} bind def - -//SetPageSize { - //RotatePages //FitPages or //CenterPages or{ - mark (/RotatePages, /FitPages and CenterPages are not allowed with /SetPageSize) //error exec - } if -} -{ - //FitPages //CenterPages and { - mark (CenterPages is not allowed with /FitPages) //error exec - } if -} -ifelse - -% ===================== Utilities ========================================= - -/knownget % knownget true - % knownget false -{ - 2 copy known { - get true - } { - pop pop false - } ifelse -} bind def - -/IsUpper % IsUpper -{ dup (A) 0 get ge exch (Z) 0 get le and -} bind def - -% Copy (recursive) packedarray|array to to global VM -% NOTE: a packedarray will be converted to non-packed (too bad) -/cpa2g { % cpa2g - dup length array % - 0 1 2 index length 1 sub { - % index - dup 3 index exch get cp2g - % index - 3 copy put pop pop - } for - exch pop -} bind def - -% Copy (recursive) dict to to global VM -/cpd2g { - dup length dict exch { - cp2g 2 index 3 1 roll put - } forall -} bind def - -% Copy string to to global VM -/cps2g { % cps2g - dup length string copy -} bind def - -/cp2gprocs -<< /arraytype //cpa2g /dicttype //cpd2g /packedarraytype //cpa2g /stringtype //cps2g >> -def - -/cp2g { % cp2g - % where is array | dict | string | packedarray - % NOTE: The object must be readable (not executeonly or noaccess) - dup gcheck not { - dup //cp2gprocs 1 index type - 2 copy known { - get currentglobal 3 1 roll true setglobal exec exch setglobal - % set the attributes appropriately (we must have 'read' access to get this far) - 1 index wcheck not { readonly } if - 1 index xcheck { cvx } if - exch pop % discard original (local) object - } { - pop pop % discard type - } ifelse - } if -} bind def - -% ===================== Work Data ========================================= - -/BlockBuffer 65535 string def % Make it big to load entire TrueType font -/PDFReader currentdict def -/ObjectRegistryMaxLength 50000 def -/ObjectRegistry 10 dict def -ObjectRegistry -begin - 0 ObjectRegistryMaxLength dict def -end -/CurrentObject null def -/DoneDocumentStructure false def -/GraphicState 20 dict begin - /InitialTextMatrix matrix def - /InitialMatrix matrix currentmatrix def -currentdict end def -/TempMatrix matrix def -/GraphicStateStack 20 array def -/GraphicStateStackPointer 0 def -/InitialTextMatrixStack 20 array def -/InitialTextMatrixStackPointer 0 def -/PDFColorSpaces 50 dict def -/InstalledFonts 50 dict def -/MacRomanEncodingInverse null def - -% We need some structures in local VM, put then into the userdict : -currentglobal false setglobal -userdict /PDFR_InitialGS gstate put -userdict /PDFR_Patterns 50 dict put -userdict /FuncDataReader 10 dict put -setglobal - -% ===================== Constants ========================================= - -% The ExtGState elements are composite, thus need to be copied to -% global VM (in case they aren't already global). -/InitialExtGState 20 dict begin - /BG2 currentblackgeneration cp2g def - /UCR2 currentundercolorremoval cp2g def - /TR2 currentglobal false setglobal [ currentcolortransfer ] exch setglobal cp2g def - /HT currenthalftone cp2g def -currentdict end readonly def - -/InitialGraphicState 20 dict begin - /FontSize 0 def - /CharacterSpacing 0 def - /TextLeading 0 def - /TextRenderingMode 0 def - /WordSpacing 0 def -currentdict end readonly def - -/SimpleColorSpaceNames 15 dict begin - /DeviceGray true def - /DeviceRGB true def - /DeviceCMYK true def -currentdict end readonly def - -/1_24_bitshift_1_sub 1 24 bitshift 1 sub def - -/ReadFontProcs 10 dict def % Will be filled below. - -/GetObject % GetObject obj true - % GetObject false -{ - dup ObjectRegistryMaxLength idiv - //PDFReader /ObjectRegistry get exch knownget { - exch knownget - } { - pop false - }ifelse -} bind def - -/PutObject % PutObject -{ - 1 index ObjectRegistryMaxLength idiv % id obj oregnr - //PDFReader /ObjectRegistry get 1 index knownget { - % object already defined in Objectregistry - % id obj oregnr dict - exch pop % id obj dict - 3 1 roll put - }{ - % object not already defined in ObjectRegistry - % id obj oregnr - //PDFReader /ObjectRegistry get dup - begin % new Objectregistry entry: - 1 index ObjectRegistryMaxLength dict def - end - exch get % id obj dict - 3 1 roll put - }ifelse -} bind def - -% ===================== Reading PDF objects =============================== - -/Register % Register - -{ - 1 index GetObject { - % d id obj e - dup xcheck { - 4 3 roll pop % id obj e - //PDFR_DEBUG { - (Have a daemon for ) print 2 index == - } if - %% We've got a definition daamon, execute it: - exec - } { - dup null ne { - mark (The object ) 4 index (is already defined : ) 4 index //error exec - } { - pop % d id obj - } ifelse - 3 2 roll % id obj d - %% Execute the default Daemon - exec - }ifelse - } { - % d id obj - 3 2 roll % id obj d - exec % execute the default deamon - }ifelse - PutObject -} bind def - -/IsRegistered % GetRegistered -{ - GetObject { - null ne - } { - false - }ifelse -} bind def - -/GetRegistered % GetRegistered -{ - dup GetObject not { - exch mark exch (Object ) exch ( isn't defined before needed (1).) //error exec - } if - % id obj - dup xcheck { - exch mark exch (Object ) exch ( isn't defined before needed (2).) //error exec - } { - dup null eq { - exch mark exch (Object ) exch ( isn't defined before needed (3).) //error exec - } if - exch pop % e - } ifelse -} bind def - -/StandardFontNames << - /Times-Roman true - /Helvetica true - /Courier true - /Symbol true - /Times-Bold true - /Helvetica-Bold true - /Courier-Bold true - /ZapfDingbats true - /Times-Italic true - /Helvetica-Oblique true - /Courier-Oblique true - /Times-BoldItalic true - /Helvetica-BoldOblique true - /Courier-BoldOblique true ->> def - -/CleanAllResources % - CleanAllResources - -{ //PDFR_DEBUG { - (CleanAllResources beg) = - } if - //PDFReader /ObjectRegistry get { - dup length 0 exch 1 exch 1 sub { % R i - 2 copy get dup xcheck { - % Don't clean a daemon. - pop pop - } { - dup null eq { - pop pop - } { - dup type /dicttype eq { /.Global known } { pop false } ifelse { - pop - } { - //PDFR_DEBUG { - (Dropping ) print dup = - } if - 1 index exch /DroppedObject put - } ifelse - } ifelse - } ifelse - } for - pop - }forall % Check each dictionary in the ObjectRegistry - FontDirectory length dict begin - FontDirectory { - pop - dup //StandardFontNames exch known not { - dup null def - } if - pop - } forall - currentdict - end { - pop - //PDFR_DEBUG { - (Undefining font ) print dup = - } if - undefinefont - } forall - //PDFR_DEBUG { - (CleanAllResources end) = - } if -} bind def - -/PrintReference % PrintReference -{ - //PDFR_DEBUG { - ({ ) print - dup { - =only ( ) print - } forall - ( }) = - } if -} bind def - -/R % R -{ % Make a reference daemon. - 0 ne { - exch mark exch (A referred object generation ) exch ( isn't 0.) //error exec - } if % id - [ % proc - exch //GetRegistered /exec load - ] cvx - //PrintReference exec -} bind def - -/IsObjRef % IsObjRef -{ - dup type /arraytype eq { - dup length 3 eq { - dup xcheck exch - dup 0 get type /integertype eq 3 2 roll and exch - dup 1 get //GetRegistered eq 3 2 roll and exch - 2 get /exec load eq and - } { - pop false - } ifelse - } { - pop false - } ifelse -} bind def - -/DoNothing -{ -} def - -/RunTypeDaemon % RunTypeDaemon -{ - dup type /dicttype eq { - dup /Type //knownget exec { - //PDFReader /TypeDaemons get exch - //knownget exec { - exec - } if - } if - } if -} bind def - -/obj % obj -{ - //PDFR_DEBUG { - (Defining ) print 1 index =only ( ) print dup =only ( obj) = - } if - 0 ne { - exch mark exch (An object generation ) exch ( isn't 0.) //error exec - } if -} bind def - -/endobj % endobj - -{ - //PDFR_DEBUG { - (endobj ) = - } if - dup type /dicttype eq { - dup /.endobj_daemon //knownget exec { - //PDFR_DEBUG { (.endobj_daemon for ) print 2 index = } if - exec - } if - } if - dup type /dicttype eq { dup /ImmediateExec known } { false } ifelse { - pop pop - } { - //PDFR_DEBUG { - (Storing ) print 1 index = - } if - //RunTypeDaemon exec - //DoNothing 3 1 roll //Register exec - } ifelse -} bind def - -/StoreBlock % StoreBlock - -{ % Stores a (encoded) stream data block to the current object. - //PDFR_DEBUG { - (StoreBlock ) print //PDFReader /BlockCount get =only (, Length = ) print dup length = - } if - dup length string copy - //PDFReader /BlockCount get exch % i s - //PDFReader /CurrentObject get 3 1 roll % o i s - put % - //PDFReader /BlockCount get 1 add - //PDFReader exch /BlockCount exch put -} bind def - -/CheckLength % CheckNumber -{ dup type /integertype ne { - mark (Object length isn't an integer.) //error exec - } if -} bind def - -/ResolveD % ResolveD -{ - 3 copy pop get % <> key {} e - dup //IsObjRef exec { - % We've got a reference daemon, execute it : - //PDFR_DEBUG { - (Resolving ) print //PrintReference exec - } if - exec % <> key {} val - exch exec % <> key val - } { - exch pop - } ifelse - dup 4 1 roll % val <> key val - put % val -} bind def - -/ResolveA % ResolveA -{ 2 index 2 index get - dup //IsObjRef exec { - exec - exch exec - 3 copy put - } { - exch pop - } ifelse - exch pop exch pop -} bind def - -/StoreStream % StoreStream -{ % Stores a (encoded) data stream copy to the current object. - dup //PDFReader exch /CurrentObject exch put % id obj - //PDFReader /BlockCount 0 put - dup /Length //CheckLength //ResolveD exec % id obj l - //PDFR_DEBUG { - (StoreStream Length = ) print dup = - } if - currentfile exch () /SubFileDecode filter % id obj file - { dup //BlockBuffer readstring { % id obj file buf - //StoreBlock exec - } { - //StoreBlock exec - exit - } ifelse % id obj file - } loop - pop % id obj - //PDFReader /CurrentObject null put - //PDFR_DEBUG { - (StoreStream end.) = - } if -} bind def - -/MakeStreamDumper % MakeStreamDumper -{ % Debug purpose only. - //PDFR_DEBUG { - (MakeStreamDumper beg.) = - } if - currentglobal exch dup gcheck setglobal - [ exch % f - 1 dict dup /c 0 put exch % d f - 1024 string % d f s - { readstring pop % d s - (StreamDumper ) print 1 index /c get =string cvs print ( ) print - dup length =string cvs print ( <) print dup print (>\n) print - dup length % d s l - 3 2 roll % s l d - dup /c get % s l d c - 3 2 roll % s d c l - add /c exch put % s - } /exec load - ] - cvx 0 () /SubFileDecode filter - exch setglobal - //PDFR_DEBUG { - (MakeStreamDumper end.) = - } if -} bind def - -/ShortFilterNames 15 dict begin - /AHx /ASCIIHexDecode def - /A85 /ASCII85Decode def - /LZW /LZWDecode def - /Fl /FlateDecode def - /RL /RunLengthDecode def - /CCF /CCITTFaxDecode def - /DCT /DCTDecode def -currentdict end readonly def - -/AppendFilters % AppendFilters -{ - //PDFR_DEBUG { - (AppendFilters beg.) = - } if - dup 3 1 roll % d f d - /Filter //knownget exec { % d f F - dup type /nametype eq { % d f /F - dup //ShortFilterNames exch //knownget exec { - exch pop - } if - 2 index /DecodeParms //knownget exec { % d f p /F - exch - } if - filter % d f' - } { % d f [] - dup 0 exch 1 exch length 1 sub { % d f [] i - 2 copy get % d f [] i /F - dup //ShortFilterNames exch //knownget exec { - exch pop - } if - 3 1 roll % d f /F [] i - 4 index /DecodeParms //knownget exec { % d f /F [] i DP - exch get % d f /F [] dp - } { % d f /F [] i - pop null % d f /F [] dp - } ifelse - dup null eq { % d f /F [] dp - pop 3 1 roll filter exch % d f' [] - } { % d f /F [] dp - 3 1 roll % d f dp /F [] - 4 1 roll filter exch % d f' [] - } ifelse - } for - pop % d f' - } ifelse - //PDFR_DEBUG //PDFR_DUMP and { - //MakeStreamDumper exec - } if - } if - exch pop - //PDFR_DEBUG { - (AppendFilters end.) = - } if -} bind def - -/ExecuteStream % ExecuteStream -{ % Executes a (encoded) data stream. - dup //PDFReader exch /CurrentObject exch put % id obj - dup /Length //CheckLength //ResolveD exec % id obj l - //PDFR_DEBUG { - (ExecuteStream id = ) print 2 index =only ( Length = ) print dup = - } if - //PDFReader /InitialGraphicState get - //PDFReader /GraphicState get copy pop - //PDFReader /Operators get begin - % currentfile exch () /SubFileDecode filter % id obj file - % We would like to use the code above, - % but HP LaserJet 1320 continues parsing after the byte count exceeds. - pop currentfile 0 (endstream) /SubFileDecode filter % id obj file - 1 index //AppendFilters exec - cvx mark exch % id obj mark file - exec - counttomark 0 ne { - mark (Data left on ostack after an immediate stream execution.) //error exec - } if - cleartomark % id obj - end % Operators - //PDFR_DEBUG { - (ExecuteStream end.) = - } if - //PDFReader /CurrentObject null put - dup /IsPage known { - dup /Context get /NumCopies //knownget exec { - 1 sub { - copypage - } repeat - } if - EPS2Write not {showpage} if - } if -} bind def - -/stream % stream -{ - //PDFR_DEBUG { - 1 index =only ( stream) = - } if % id obj - % Run the object definition daemon, if exists : - 1 index GetObject { - % id obj e - dup xcheck { - exec - % Disable the daemon : - 1 index null PutObject - } { - pop - } ifelse - }if - dup /ImmediateExec known { - dup /GlobalExec //knownget exec { - currentglobal 4 1 roll - setglobal - //ExecuteStream exec - 3 2 roll setglobal - } { - //ExecuteStream exec - } ifelse - } { - //StoreStream exec - } ifelse - dup /.CleanResources //knownget exec { - /All eq { - //CleanAllResources exec - } if - } if -} bind def - -/HookFont % HookFont -{ - //PDFR_DEBUG { - (Loaded the font ) print dup /FontName get = - } if - { - dup /FontFileType get dup /Type1 eq exch /MMType1 eq or { % id obj fd - % We assume that the Type 1 font has same name with no prefix - % due to pdfwrite specifics. - % We use it to find the font after it is defined. - % We could redefine 'definefont' for hooking the font, - % but we don't think that it could be guaranteedly portable : - % a 3d party PS interpreter may set a special context - % when running the font file. - % Note that this mechanizm does not depend on the - % font name uniquity, because the last 'definefont' - % is only important. - dup /FontName get % id obj fd fn - //PDFReader /RemoveFontNamePrefix get exec - findfont % id obj fd g f - exit - } if - dup /FontFileType get /TrueType eq { % id obj fd - //PDFReader /MakeType42 get exec - //PDFR_DEBUG { - (Font dict <<) = - dup { - 1 index /sfnts eq { - exch pop - (/sfnts [) print - { - (-string\() print length //=only exec (\)- ) = - } forall - (]) = - } { - exch //=only exec ( ) print == - } ifelse - } forall - (>>) = - } if - dup /FontName get exch definefont - exit - } if - mark (FontHook has no proc for ) 2 index /FontFileType get //error exec - } loop - /Font exch put % id obj -} bind def - -/endstream % endstream -{ -} bind def - -/xref % - xref - -{ - //PDFR_DEBUG { - (xref) = - //PDFR_DUMP { - //PDFReader /ObjectRegistry get == - } if - } if - end % The procset - count 0 ne { - mark (Excessive data on estack at the end of the interpretation.) //error exec - } if - currentfile 1 (%%EOF) /SubFileDecode filter - flushfile - cleardictstack -} bind def - -% ===================== Restoring the PDF Document Structure =============== - -/ResolveDict % /ResolveDict - -{ dup { % d key val - pop 1 index exch % d cp key - //DoNothing //ResolveD exec % d obj - pop % d - } forall - pop % -} bind def - -/SetupPageView % SetupPageView - -{ - //PDFR_DEBUG { - (SetupPageView beg) = - } if -//DSC_OPDFREAD not { - //GraphicState /InitialMatrix get setmatrix -} if - /MediaBox get aload pop % bx0 by0 bx1 by1 - 3 index neg 3 index neg translate % Temporary move to origin - 3 -1 roll sub 3 1 roll exch sub exch % bw bh - userdict /.HWMargins //knownget exec { - aload pop - } { - currentpagedevice /.HWMargins //knownget exec { - aload pop - } { - 0 0 0 0 - } ifelse - } ifelse - currentpagedevice /PageSize get aload pop - 3 -1 roll sub 3 1 roll exch sub exch % bw bh px0 py0 px1 py1 - exch 3 index sub exch 3 index sub % bw bh px0 py0 pw ph - //SetPageSize { - //PDFR_DEBUG { - (Setting page size to ) print 1 index //=only exec ( ) print dup = - } if - pop pop 3 index 3 index 2 copy % bw bh px0 py0 bw bh bw bh - currentglobal false setglobal 3 1 roll % bw bh px0 py0 bw bh bool bw bh - currentpagedevice dup /PageSize known { - /PageSize get aload pop % Get current page size - } { - 0 0 % dummy page size values if not known - }ifelse - % bw bh px0 py0 bw bh bool bw bh Width Height - round cvi 2 index round cvi eq % bw bh px0 py0 bw bh bool bw bh Width bool - exch round cvi 3 index round cvi eq and % bw bh px0 py0 bw bh bool bw bh bool - { % Page Size unchanged, do not emit setpagedevice - pop pop % bw bh px0 py0 bw bh bool - } { - /MediaRequested where { - % bw bh px0 py0 bw bh - /MediaRequested get aload pop % bw bh px0 py0 bw bh Width Height - round cvi 2 index round cvi eq % bw bh px0 py0 bw bh bool bw bh Width bool - exch round cvi 3 index round cvi eq and % bw bh px0 py0 bw bh bool bw bh bool - {pop pop false} % We already requested this media size, so don't re-request - {true} ifelse % Media request different to last request - } { - true % No stored media request, so apply setpagedevice - } ifelse - { - 2 array astore % bw bh px0 py0 bw bh bool [] - dup /MediaRequested exch def - << exch /PageSize exch >> setpagedevice % bw bh px0 py0 bw bh bool - /pagesave save def - } if - } ifelse - userdict /PDFR_InitialGS gstate put - setglobal % bw bh px0 py0 bw bh - } if - //RotatePages { - 2 copy gt 6 index 6 index gt ne { - % a rotation is useful except it fits with no rotation. - 1 index 5 index le 1 index 5 index le and not - } { - false - } ifelse - } { - false - } ifelse - { //CenterPages { - //PDFR_DEBUG { - (Rotating page, and then centering it) == - } if - 90 rotate - 0 5 index neg translate - 5 index 1 index exch sub 2 div - 2 index 6 index sub 2 div neg % bw bh px0 py0 pw ph lm bm - translate - } { - //FitPages { - 1 index 5 index div 1 index 7 index div % bw bh px0 py0 pw ph sx sy - 2 copy gt { - exch - } if - pop dup scale % bw bh px0 py0 pw ph - } if - 90 rotate - 0 5 index neg translate - } ifelse - } { - //CenterPages { - //PDFR_DEBUG { - (Ccentering page) == - } if - 1 index 6 index sub 2 div - 1 index 6 index sub 2 div % bw bh px0 py0 pw ph lm bm - translate - } { - //FitPages { - 1 index 6 index div 1 index 6 index div % bw bh px0 py0 pw ph sx sy - 2 copy gt { - exch - } if - pop dup scale % bw bh px0 py0 pw ph - } if - } ifelse - } ifelse - pop pop % bw bh px0 py0 - translate % bw bh - pop pop % - //PDFR_DEBUG { - (SetupPageView end) = - } if -} bind def - -/PageContentsDaemon % PageContentsDaemon -{ % Note: an excessive operand from a prebond procedure. - //PDFR_DEBUG { - (Executing PageContentsDaemon for ) print 2 index = - } if % id obj node - 1 index exch /Context exch put % id obj - dup /ImmediateExec true put - dup /IsPage true put - SetPageSize {dup /Context get //SetupPageView exec} if -} bind def - -/FontFileDaemon % FontFileDaemon -{ % Note: an excessive operand from a prebond procedure. - //PDFR_DEBUG { - (Executing FontFileDaemon for ) print 2 index = - } if - % We need any font resource that refers this descriptor - % to know the font type. Assuming that FontDescriptorDaemon - % provided FontFileType. - dup /FontFileType get % id obj fd ft - 2 index exch % id obj fd obj ft - dup //ReadFontProcs exch //knownget exec { % id obj fd obj ft proc - exch pop exec % id obj fd - } { - mark (FontFile reader for ) 2 index ( isn't implemented yet.) //error exec - } ifelse - //PDFR_DEBUG { - (FontFileDaemon end) = - } if % id obj fd - pop -} bind def - -/FontDescriptorDaemon % FontDescriptorDaemon -{ % Note: an excessive operand from a prebond procedure. - //PDFR_DEBUG { - (Executing FontDescriptorDaemon for ) print 2 index = - } if % id obj fr - %HACK BEG assuming an own font for each font descriptor - % to provide an access to PDFEncoding - % from MakeType42, ComposeCharStrings. - 2 copy /FontResource exch put - %HACK END - /Subtype get 1 index exch /FontFileType exch put -} bind def - -/UnPDFEscape { % UnPDFEscape - dup dup length string cvs % /namepdf (name) - dup (#) search { - % name contains PDF-style escapes ("#hh") that need to be removed - { % ... (po..st) (#) (pre) - pop % ... (po..st) (#) - (16#--) 2 index 0 2 getinterval % ... (po..st) (#) (16#--) (po) - 1 index 3 2 getinterval copy pop % ... (po..st) (#) (16#po) - cvi % ... (po..st) (#) 16#po - 0 exch put % ... (po..st); 16#po patched into (#) - 0 % ... (po..st) 0 - 1 index 2 1 index length 2 sub getinterval % ... (po..st) 0 (..st) - 3 copy putinterval % ... (..stst) 0 (XXst) - length % ... (..stst) 0 LEN_OF_(po..st)-2 - 3 copy exch put % ... (..st\0t) 0 LEN_OF_(po..st)-2 - getinterval % ... (..st), stored at begining of old (po..st) - (#) search not { - pop exit % /namepdf (nameps\0..) - } if - } loop - % we have a '\0' marker (not allowed in PDF names) after all usefull characters - (\0) search pop exch pop exch pop - cvn - exch pop - } { - pop pop - } ifelse -} bind def - -/TypeDaemons << % proc - /Page - { //PDFR_DEBUG { - (Recognized a page.) = - } if - dup /Contents //knownget exec { % id obj c - 0 get //DoNothing exch % id obj dn id1 - [ % proc - 3 index //PageContentsDaemon /exec load - ] cvx % id obj {} - //Register exec % id obj - } { - (fixme: page with no Contents won't be printed.) = - } ifelse - } bind - /FontDescriptor - { //PDFR_DEBUG { - (Recognized a font descriptor.) = - } if - dup /FontName //knownget exec { - 1 index /FontName 3 -1 roll //UnPDFEscape exec put - } if - dup dup /FontFile known {/FontFile} {/FontFile2} ifelse - //knownget exec { % id obj ff - 0 get //DoNothing exch % id obj dn id1 - [ % proc - 3 index //FontFileDaemon /exec load - ] cvx % id obj {} - //Register exec % id obj - } { - % FontFile3 are not implemented yet. - (Font descriptor ) print 1 index =only ( has no FontFile.) = - } ifelse - } bind - /Font - { //PDFR_DEBUG { - (Recognized a font resource.) = - } if - dup /BaseFont //knownget exec { - //UnPDFEscape exec 2 copy /BaseFont exch put - % cache the installed font (if any) before replacing it. - //PDFReader /RemoveFontNamePrefix get exec - currentglobal exch % A hack against HP LaserJet 1320 bug : - % It sets the local allocation mode - % when 'resourcestatus' fails. - dup /Font resourcestatus { - pop pop - //PDFReader /GetInstalledFont get exec pop - } { - pop - } ifelse - setglobal - } if - dup /FontDescriptor //knownget exec { % id obj fd - 0 get % id obj id1 - dup //IsRegistered exec { % id obj id1 - //PDFR_DEBUG { - (already registered ) print dup = - } if - pop - } { - //DoNothing exch % id obj dn id1 - [ % proc - 3 index //FontDescriptorDaemon /exec load - ] cvx % id obj {} - //Register exec % id obj - } ifelse - } if - } bind ->> def - -/MakeStreamReader % MakeStreamReader -{ dup - [ - exch - //PDFR_DEBUG { - (Stream proc ) - /print load - //PDFR_STREAM { - (<) - /print load - } if - } if - 1 dict dup /i -1 put - /dup load - /i - /get load - 1 - /add load - /dup load - 3 - 1 - /roll load - /i - /exch load - /put load - //knownget - /exec load - /not load - { () } - /if load - //PDFR_DEBUG { - //PDFR_STREAM { - /dup load - /print load - (>) - /print load - } if - ( end of stream proc.\n) - /print load - } if - ] cvx - //PDFR_DEBUG { - (Stream reader ) print dup == - } if - 0 () /SubFileDecode filter - exch //AppendFilters exec -} bind def - -/RunDelayedStream % RunDelayedStream - -{ - % Save InitialTextMatrix, as this is local to each content stream - //GraphicState /InitialTextMatrix get - //InitialTextMatrixStack //PDFReader /InitialTextMatrixStackPointer get - 2 copy get null eq { - 2 copy currentglobal true setglobal matrix exch setglobal put - } if - get copy pop - //PDFReader /InitialTextMatrixStackPointer 2 copy get 1 add put - % Execute the stream - //MakeStreamReader exec % file - mark exch - cvx exec % - counttomark 0 ne { - mark (Data left on ostack after a delayed stream execution.) //error exec - } if - cleartomark - % Restore InitialTextMatrix - //PDFReader /InitialTextMatrixStackPointer 2 copy get 1 sub put - //InitialTextMatrixStack //PDFReader /InitialTextMatrixStackPointer get get - //GraphicState /InitialTextMatrix get - copy pop -} bind def - -% ===================== Font Management ====================== - -//ReadFontProcs begin - /Type1 % Type1 - { //PDFR_DEBUG { - (ReadFontProcs.Type1) = - } if - dup /.endobj_daemon [ 4 index //HookFont /exec load ] cvx put - dup /ImmediateExec true put - /GlobalExec true put - } bind def - /MMType1 //Type1 def - /TrueType % TrueType - { //PDFR_DEBUG { - (ReadFontProcs.TrueType) = - } if - dup /.endobj_daemon [ 4 index //HookFont /exec load ] cvx put - pop - } bind def -end - -% A working dictionary to hold items related to reading a TrueType font -% and converting into a type 42 font, especially regarding creating the sfnts -% array of strings, and ensuring strings are split on table boundaries and -% for the glyf table, on glyph boundaries. -% -/.opdloadttfontdict 50 dict def -.opdloadttfontdict begin - -/maxstring 65400 def % less than the maximum length of a PostScript string, - % must be a multiple of 4 (for hmtx / loca / vmtx) -end - -% Uses an insertion sort to sort the contents of an array, -% the sorted array is returned. Takes the array to sort and a -% comparison procedure. The comparison procedure must take two -% arguments, and return a boolean. The return value should be -% false if arguments incorrectly ordered, true if they are -% already in the correct order. -% -% [Array to sort] {comparisaon proc} InsertionSort [Sorted array] -% -/.InsertionSort -{ - /CompareProc exch def - /Array exch def - 1 1 Array length 1 sub - { - /Ix exch def - /Value1 Array Ix get def - - /Jx Ix 1 sub def - { - Jx 0 lt { - exit - } if - /Value2 Array Jx get def - Value1 Value2 CompareProc { - exit - } if - - Array Jx 1 add Value2 put - /Jx Jx 1 sub def - } loop - Array Jx 1 add Value1 put - } for - Array -} bind def - -% -% Utility rourtines to insert a TrueType data type -% -% putu16 - -/putu16 { - 3 copy -8 bitshift put - exch 1 add exch 16#ff and put -} bind def -% putu32 - -/putu32 { - 3 copy -16 bitshift putu16 - exch 2 add exch 16#ffff and putu16 -} bind def - -% -% Utility routines to read TrueType table data, returning -% either a string or an array of strings depending on the -% table length. -% - -% Read a table as a single string. -% .readtable -/.readtable { - dup dup 1 and add string - % Stack: f len str - dup 0 4 -1 roll getinterval - % Stack: f str str1 - % Because of the absurd PostScript specification that gives an - % error for reading into an empty string, we have to check for - % this explicitly here. - 3 -1 roll exch - dup () ne { readstring } if pop pop -} bind def - -% Read a big table (one that may exceed 64K). -% .readbigtable -/.readbigtable { - dup maxstring lt { - .readtable - } { - currentuserparams /VMReclaim get -2 vmreclaim - [ 4 2 roll { - % Stack: mark ... f left - dup maxstring le { exit } if - 1 index maxstring string readstring pop 3 1 roll maxstring sub - } loop .readtable ] - exch vmreclaim - } ifelse -} bind def - -% ReadTTF reads the tables and so on from a TreuType font into memory -% so that they are available for later processing. -% -% ReadTTF - -% -/ReadTTF -{ - .opdloadttfontdict begin - /TTFontFile exch def - - % Table directory: - % version - fixed (4 bytes) - % numTables - USHORT (2 bytes) - % searchRange - USHORT (2 bytes) - % entrySelector - USHORT (2 bytes) - % Read Table - /TableDir TTFontFile 12 string readstring pop def - - % There are numTables table directory entries: - % tag - ULONG (4 bytes) - % checkSum - ULONG (4 bytes) - % offset - ULONG (4 bytes) - % length - ULONG (4 bytes) - % Read entries - /tables TTFontFile TableDir 4 getu16 16 mul string readstring pop def - - % Create dictionary to store directory entries. - /tabarray tables length 16 idiv array def - - % Check version for TrueType collection - TableDir 0 4 getinterval (ttcf) eq { - QUIET not { (Can't handle TrueType font Collections.) = } if - /.loadttfonttables cvx /invalidfont signalerror - } { - % There are ((length of tables string) / 16) Table directory entries - % Get and store each in turn - 0 16 tables length 1 sub { - % Get each directory entry as a 16-byte string - dup % index index - tables exch 16 getinterval % index (string) - exch 16 div cvi exch % index/16 (string) - tabarray 3 1 roll put - } for - } ifelse - - % We need the tables in the order they occur in the file, so sort - % by 'offset'. - tabarray { exch 8 getu32 exch 8 getu32 gt} .InsertionSort pop - - % Now we read the content of each table in turn. If the table is < 64K - % then we store it in a single string. If its more, we store it in an - % array of strings. The table contents are stored in 'tabs' in the same - % order as they are read from the file, as per the sorted array 'tabarray'. - /Read TableDir length tables length add def - /tabs [ - tabarray { - % Get offset (from start of file) of next table - dup 8 getu32 % () offset - % Subtract amount read so far - Read sub % () offset-Read - dup 0 gt { - % Read and discard any extra padding bytes % () offset-Read - dup string TTFontFile exch readstring pop pop % () offset-Read - % Update bytes read - Read add /Read exch def % () - } { - pop % () - } ifelse - % Find length of this table and add it to bytes read - 12 getu32 % () tablelength - dup Read add % () tablelength tablelength+Read - /Read exch def % () tablelength - TTFontFile exch .readbigtable - } forall - ] def - end % .opdloadttfontdict -} bind def - -% GetLocaType finds the head table in tabarray, which gives -% an index into the 'tabs' array where the data is stored. -% From that data we extract the loca type (short or long). -% -% - GetLocaType - -% -/GetLocaType -{ - 0 1 tabarray length 1 sub{ - % control-variable - dup tabarray exch get % control-variable () - 0 4 getinterval (head) eq{ % control-variable bool - tabs exch get % () - 50 gets16 - /LocaType exch def - exit - } { - pop % control variable % - - } ifelse - } for -} bind def - -% GetNumGlyphs finds the maxp table in tabarray, which gives -% an index into the 'tabs' array where the data is stored. -% From that data we extract the number of glyphs in the font. -% -% - GetNumGlyphs - -% -/GetNumGlyphs -{ - 0 1 tabarray length 1 sub{ - % control-variable - dup tabarray exch get % control-variable () - 0 4 getinterval (maxp) eq{ % control-variable bool - % Get the maxp string - % from the tabs array - tabs exch get % () - 4 getu16 % int - /NumGlyphs exch def - exit % int - } { - pop % control variable % - - } ifelse - } for -} bind def - -% StringtoLoca takes a string, and an index in to an array -% where the loca results should be stored from. It reads -% along the string getting either 2-byte or 4-byte values -% (depends on loca type) and stores them in the array at -% successive locations. Leaves the next unused location -% on the stack at end (easy to process multiple strings). -% -% string ArrayIndex StringToLoca ArrayIndex -% -/StringToLoca -{ - /LocaIndex exch def % () - /StringOffset 0 def % () - { - dup length StringOffset gt { % () - dup % () - LocaType 1 eq{ - StringOffset getu32 % () loca - LocaArray LocaIndex 3 -1 roll put % () - /LocaIndex LocaIndex 1 add def % () - /StringOffset StringOffset 4 add % () - def - } { - StringOffset getu16 2 mul % () loca - LocaArray length LocaIndex gt { % take account of apdding in the string - LocaArray LocaIndex 3 -1 roll put % () - }{ % - pop % ignore indices off the end of the array - }ifelse % - /LocaIndex LocaIndex 1 add def % () - /StringOffset StringOffset 2 add % () - def - } ifelse - }{ % () - pop % - - LocaIndex % return index - exit - }ifelse - } loop -} bind def - -% GetSortedLoca reads the loca table, and sorts it by offset -% this is so that we can walk up the array looking for an approporiate -% place to split strings. The result is stored in LocArray -% -% - GetSortedLoca - -% -/GetSortedLoca -{ - NumGlyphs 1 add array /LocaArray exch def - - % Get the loca table - 0 1 tabarray length 1 sub{ - % control-variable - dup tabarray exch get % control-variable () - 0 4 getinterval (loca) eq{ % control-variable bool - % Get the loca string - % from the tabs array - tabs exch get % () - exit - } { - pop % control variable % - - } ifelse - } for - - % If its a single string handle the easy way - dup type /stringtype eq { - 0 StringToLoca pop - }{ - % Otherwise its an array, process each string in the array - 0 exch % Starting LocaArray index - { - exch StringToLoca - }forall - pop % final LocaArray index - }ifelse - - % Now we've read all the locations, sort them so - % we can figure out where to break the strings - LocaArray {gt} .InsertionSort pop -} bind def - -% Updates internal storage with a new string from the -% GlyfArray -% - GetWorkingString - -/GetWorkingString -{ - WorkString 0 - GlyfArray GlyfStringIndex get - putinterval - % Update the available bytes - /WorkBytes GlyfArray GlyfStringIndex get length def - % Set index to get data from next string in array - /GlyfStringIndex GlyfStringIndex 1 add def -} bind def - -% Returns a string with the requested number of bytes taken -% from WorkingString. There must be enough data in WorkingString to -% satisfy the request -% -/GetWorkingBytes -{ - /BytesToRead exch def - % Get 'BytesToRead' bytes from working store - WorkString 0 BytesToRead getinterval - dup length string copy - % Get remaining bytes from working store - WorkString BytesToRead WorkBytes BytesToRead sub getinterval - dup length string copy - % replace first 'n' bytes of working store with unread bytes - WorkString 0 3 -1 roll putinterval - % Subtract bytes read from bytes available - /WorkBytes WorkBytes BytesToRead sub def -} bind def - -% Read 'int' bytes from GlyfArray strings, return string composed -% of those bytes -% -% int GetGlyfBytes string -/GetGlyfBytes -{ - /ToRead exch def - - % If we have no available data, get soem from the array of - % glyf strings - WorkBytes 0 eq { - GetWorkingString - } if - - WorkBytes ToRead ge { - ToRead string dup 0 - ToRead GetWorkingBytes putinterval - }{ - % Create a string sized to hold the target data - ToRead string - % Get remaining stored bytes, and put at the start - % of the string - dup - % Start of string - 0 - % Get remaining bytes - WorkString 0 WorkBytes getinterval - % store at start of output string - putinterval - - dup - % Location in output to store data from next string - WorkBytes - % amout of data required to read from next string - ToRead WorkBytes sub - % Get the next string from the array of strings - GetWorkingString - % Get a string containing the required data, updating - % the internal data storage - GetWorkingBytes - % put the data at the end of the stored data in the - % output string - putinterval - } ifelse -} bind def - -% Given an array of glyf strings, returns an array of strings -% split on glyf boundaries -% -% [] SplitGlyf [] -% -/SplitGlyf -{ - /GlyfArray exch def - /DestArray GlyfArray length 2 mul array def - /DestArrayIndex 0 def - - /LastLoca 0 def - /NextLocaIndex 0 def - /LastLocaIndex 0 def - - /GlyfStringIndex 0 def - /WorkString maxstring string def - /WorkBytes 0 def - - % Find appropriate next loca - { - % Get location of next glyph - LocaArray NextLocaIndex get % int - % subtract location of last point to get - % the actual bytes between - LastLoca sub maxstring gt % int bool - { - LocaArray LastLocaIndex get LastLoca sub - GetGlyfBytes % () - DestArray DestArrayIndex 3 -1 roll put % - - /DestArrayIndex DestArrayIndex 1 add def % - - LocaArray LastLocaIndex get /LastLoca exch def % - - } { % int - /LastLocaIndex NextLocaIndex def % - - /NextLocaIndex NextLocaIndex 1 add def % - - NextLocaIndex NumGlyphs gt % bool - { - WorkBytes % int - GlyfStringIndex GlyfArray length lt { % int bool - GlyfArray GlyfStringIndex get length % int - add string dup % (d) (d) - 0 % (d) (d) 0 - WorkString 0 WorkBytes getinterval % (d) (d) (s) - putinterval % (d) - dup % (d) (d) - WorkBytes % (d) (d) int - GetWorkingString % (d) (d) int - WorkString 0 WorkBytes getinterval % (d) (d) int (s) - putinterval % (d) - } { - pop % - - WorkString 0 WorkBytes getinterval % () - } ifelse - dup length string copy - DestArray DestArrayIndex 3 -1 roll put - exit - } if - } ifelse - } loop - DestArray - -} bind def - -% ProcessTTData looks at the data stored in the 'tabs' array and does several things: -% 1) Make sure strings representing tables are multiples of 4 bytes long -% 2) For arrays representing tables, make sure the total string length is a multiple -% of 4 bytes long, to ensure the table is a multiple of 4 bytes. -% 3) Handle the glyf table specislly, each string in this array must be split on the -% boundary of a glyf. Use the loca table to determine where the split should happen -% and build a new array of strings split appropriately. -% -% - ProcessTTData - -% -/ProcessTTData -{ - .opdloadttfontdict begin - % Make sure all the strings are a multiple of 4 bytes - 0 1 tabarray length 1 sub{ - /ix exch def - tabarray ix get - 12 getu32 dup maxstring le { - % String < 64Kb, still need to check if its a multiple of 4 - dup 4 mod 0 ne { - 4 div cvi 1 add 4 mul string /newstring exch def - /oldstring tabs ix get def - newstring 0 oldstring putinterval - 0 1 newstring length oldstring length sub 1 sub { - newstring exch oldstring length add 0 put - } for - tabs ix newstring put - } { - % table size is a multiple of 4, don't need to promote it - pop - } ifelse - }{ - % table size > 64K, so this is an array of strings, not a string - % We still need to make sure that the tables end on 4-byte - % boundaries. - dup 4 mod 0 ne { - % First we need to work out how many strings of size maxstring - % are present, and how much they contribute to the overall size. - dup maxstring idiv maxstring mul sub - % Promote final string length to multiple of 4 - 4 idiv 1 add 4 mul string /newstring exch def - % Get array of strings - tabs ix get - % find size of table and get last string - dup length 1 sub dup /iy exch def get /oldstring exch def - newstring 0 oldstring putinterval - 0 1 newstring length oldstring length sub 1 sub { - newstring exch oldstring length add 0 put - } for - tabs ix get iy newstring put - } { - % table size is a multiple of 4, don't need to promote it - pop - } ifelse - } ifelse - } for - - % Now, if glyf table > 64Kb, then it will be an array of strings - % We need to make sure the strings are split on glyph boundaries - 0 1 tabarray length 1 sub { % int - dup tabarray exch get % int () - dup 12 getu32 maxstring gt { % int () bool - 0 4 getinterval dup (glyf) eq{ % int () bool - % Need to split the glyf strings on glyph boundaries, hmmm. - pop % int - % We need to know the number of glyphs (from the maxp table) and the - % position of each glyph (from the loca table). - GetLocaType % int - GetNumGlyphs % int - GetSortedLoca % int - % Get the array of strings from tabs - dup tabs exch get % int - SplitGlyf % int [] - tabs 3 1 roll put % - - } { % int () - (Warning, table ) print print ( > 64Kb\n) print - pop % - - } ifelse - }{ % int () - % Table less than 64K, so don't worry - pop % directory entry % int - pop % 'for' control variable % - - } ifelse - } for - end % .opdloadttfontdict -} bind def - -% Makesfnts uses the accumulated data to create an array of strings -% containing only the required data. -% -% - Makesfnts array -% -/Makesfnts -{ - .opdloadttfontdict begin - % Determine size of sfnts array - % length of tabarray + header - 0 - tabs { % int obj - dup type /stringtype eq { % int obj bool - pop % int - 1 add % int - }{ % int obj - { % int obj - type /stringtype eq { % int bool - 1 add % int - } if - } forall - } ifelse - } forall - - 1 add % add header and table directory - % to determine total # strings - % Need to recalculate the lengths of the TT - % tables, just in case any have changed. If required we - % could also resort the tables here, ideally we should do so - % and recalculate checksums, but this should never be necessary - % for fonts produced by pdfwrite. - /TTOffset - TableDir length % initial table offset is header length - tabarray length 16 mul add % + (NumTables * 16) bytes - def - - 0 - tabarray { % index () - exch dup 1 add % () index index+1 - 3 1 roll % index+1 () index - dup % index+1 () index index - tabs exch get % index+1 () index ()/[] - dup type /stringtype eq { % index+1 () index ()/[] bool - length % index+1 () index int - 2 index exch % index+1 () index () int - TTOffset - dup 3 1 roll add % add the running total of offsets - /TTOffset exch def % update running total of offsets - 8 exch putu32 % index+1 () index - exch tabarray 3 1 roll % index+1 [] index () - put % index+1 - } { % index+1 () index ()/[] - 0 exch % add all string lengths - { % starting from 0 - dup type /stringtype eq { - length add % - } { - pop - } ifelse - } forall % - 2 index exch % index+1 () index () int - TTOffset - dup 3 1 roll add % add the running total of offsets - /TTOffset exch def % update running total of offsets - 8 exch putu32 % index+1 () index - exch tabarray 3 1 roll % index+1 [] index () - put % index+1 - } ifelse - } forall - pop % index+1 - - array % [] - dup 0 % [] [] 0 - TableDir length - tables length add % [] [] 0 header_length - string % [] [] 0 () - dup 0 TableDir putinterval % [] [] 0 () - dup 12 tables putinterval % [] [] 0 () - put % [] - dup % [] [] - /ix 1 def - tabs { % [] [] obj - dup type /stringtype eq { % [] [] obj bool - ix exch % [] [] int obj - put dup % [] [] - /ix ix 1 add def % [] [] - }{ - { - dup type /stringtype eq { % [] [] obj bool - ix exch put dup % [] [] - /ix ix 1 add def % - } { - pop % [] [] - } ifelse - } forall - } ifelse - } forall - pop % [] - end %.opdloadttfontdict -} bind def - -/MakeType42 % MakeType42 -{ - //PDFR_DEBUG { - (MakeType42 beg) = - } if - 10 dict begin - /FontName 1 index /FontName get def - /FontType 42 def - /FontMatrix [1 0 0 1 0 0] def - /FontBBox 1 index /FontBBox get def % fo fd - dup /FontResource get % fo fd fr - dup /Encoding known { % fo fd fr - //PDFReader /ObtainEncoding get exec % fo fd fr - /Encoding get % fo fd e - } { - pop null - } ifelse - /PDFEncoding exch def % fo fd - /CharStrings 2 index //PDFReader /MakeTTCharStrings get exec def - /sfnts 2 index //MakeStreamReader exec - ReadTTF - ProcessTTData - Makesfnts - def - /Encoding StandardEncoding def % A stub - will be replaced by font resource. - /PaintType 0 def - currentdict end - //PDFR_DEBUG { - (MakeType42 end) = - } if -} bind def - -/GetInstalledFont % GetInstalledFont -{ - dup //InstalledFonts exch knownget { % n f - exch pop % f - } { % n - dup findfont dup 3 1 roll % f n f - //InstalledFonts 3 1 roll put % f - } ifelse -} bind def - -/RemoveFontNamePrefix % RemoveFontNamePrefix -{ //=string cvs true - 0 1 5 { - 2 index exch get //IsUpper exec not { - pop false exit - } if - } for - { (+) search { - pop pop - } if - } if - cvn -} bind def - -/CheckFont % CheckFont -{ dup /Type get /Font ne { - mark (Resource ) 3 index ( must have /Type/Font .) //error exec - } if -} bind def - -/CheckEncoding % CheckEncoding -{ dup type /nametype ne { - dup /Type get /Encoding ne { - mark (Resource ) 3 index ( must have /Type/Encoding .) //error exec - } if - } if -} bind def - -/ObtainEncoding % ObtainEncoding -{ dup /Encoding known { - dup dup /Encoding //CheckEncoding //ResolveD exec % fr fr er|e|n - dup type dup /arraytype eq exch /packedarraytype eq or { - % Already resolved. - pop pop - } { - dup type /nametype eq { - /Encoding findresource % fr fr e - } { - dup /BaseEncoding //knownget exec not { - /StandardEncoding - } if - /Encoding findresource % fr fr er e - exch % fr fr e er - /Differences //knownget exec { % fr fr e d - exch dup length array copy exch - 0 exch % fr fr e 0 d - { % fr fr e i v - dup type /integertype eq { - exch pop - } { - 3 copy put pop % fr fr e i - 1 add - } ifelse - } forall - pop % fr fr e - } if % fr fr e - } ifelse % fr fr e - /Encoding exch put % fr - } ifelse - } { - dup /Encoding /StandardEncoding /Encoding findresource put - } ifelse -} bind def - -/ObtainMetrics % ObtainMetrics -{ dup /Widths //knownget exec { % fr W - 1 index /Encoding get % fr W E - 256 dict % fr W E M - 3 index /Subtype get /TrueType eq { - 1000 - } { - 1 - } ifelse % fr W E M s - 4 index /MissingWidth //knownget exec not { - 0 - } if % fr W E M s mw - 5 index /FirstChar //knownget exec not { - 0 - } if % fr W E M s mw c0 - 6 5 roll % fr E M s mw c0 W - dup 0 exch 1 exch length 1 sub { % fr E M s mw c0 W i - 2 copy get % fr E M s mw c0 W i w - exch 3 index add % fr E M s mw c0 W w c - 7 index exch get % fr E M s mw c0 W w n - dup dup null ne exch /.notdef ne and { - 6 index 3 1 roll exch % fr E M s mw c0 W M n w - 6 index div - 3 copy pop //knownget exec { - 0 eq - } { - true - } ifelse - { put % fr E M s mw c0 W - } { - pop pop pop - } ifelse - } { - pop pop - } ifelse - } for - pop pop pop pop exch pop % fr M - 1 index exch /Metrics exch put % fr - } { - dup /MissingWidth //knownget exec { % fr mw - 256 dict % fr mw M - 2 index /Encoding get { % fr mw M e - dup null ne { - 3 copy 3 2 roll put % fr mw M e - } if - pop % fr mw M - } forall - exch pop % fr M - 1 index exch /Metrics exch put % fr - } if - } ifelse -} bind def - -/NotDef % - NotDef - -{ % A Type 3 font is on dstack. - FontMatrix aload pop pop pop exch pop exch pop % sx sy - 1 exch div exch - 1 exch div exch % wx wy - 1 index 0 setcharwidth - 0 setlinewidth - 0 0 moveto - 2 copy rlineto - 1 index 0 rlineto - neg exch neg exch rlineto % - closepath stroke -} bind def - -%% These two routines may have more general application. -%% When executing BuildChar we need to run in the context of the font -%% as far as resources are concerned (in case the glyph uses another font) -%% but since we are executing a page stream, we must not lose the original -%% context, or we won't be able to find page resources. Originally this was -%% a simpler routine, but this failed when presented with a type 3 font -%% whose BuildChar/CharProcs used another type 3 font -/SaveResourcesToStack -{ - [ - //PDFReader /OldResources known { - //PDFReader /OldResources get - }{ - null - } ifelse - //PDFReader /CurrentObject get /Context get /Resources get - ] - //PDFReader /OldResources 3 -1 roll put -}bind def - -/RestoreResourcesFromStack -{ - //PDFReader /OldResources get dup - 0 get //PDFReader /OldResources 3 -1 roll put - 1 get //PDFReader /CurrentObject get /Context get /Resources 3 -1 roll put -} bind def - -/BuildChar % BuildChar - -{ //PDFR_DEBUG { - (BuildChar ) print dup //=only exec ( ) print - } if - exch begin - Encoding exch get % n - //PDFR_DEBUG { - dup = - } if - dup null eq { - pop //NotDef exec % - } - { % n - CharProcs exch//knownget exec - { - currentfont /Font get /Resources //knownget exec{ %% Does the Font have any Resources ? - exec %% Get them - SaveResourcesToStack %% Save the current Resources - //PDFReader /CurrentObject get /Context get %% Replace the current resources - /Resources 3 -1 roll put %% With the Font resources - //RunDelayedStream exec - RestoreResourcesFromStack %% Restore the previous Resources - } { - //RunDelayedStream exec - } ifelse - } - { - //NotDef exec - }ifelse - } ifelse % - end % font -} bind def - -/printdict % printdict - -{ (<<) = - { exch = == } forall - (>>) = -} bind def - -/printfont % printfont - -{ - dup { - exch dup = - dup /Encoding eq { - pop = - } { - dup /FontInfo eq exch /Private eq or { - //printdict exec - } { - == - } ifelse - } ifelse - } forall -} bind def - -/ScaleMetrics % ScaleMetrics -{ 1 index { % M s n v - 2 index div % M s n v' - 3 index % M s n v' M - 3 1 roll put % M s - } forall - pop -} bind def - -/ResolveAndSetFontAux % ResolveAndSetFont - -{ exch dup % s rn rn - //PDFReader /CurrentObject get /Context get /Resources get - /Font //DoNothing //ResolveD exec - exch //CheckFont //ResolveD exec % s rn fr - dup /Font //knownget exec { % s rn fr f - exch pop exch pop - } { - { - dup /Subtype get dup dup /Type1 eq exch /TrueType eq or exch /MMType1 eq or { - % s rn fr - exch pop % s fr - dup /BaseFont get % s fr n - //RemoveFontNamePrefix exec % s fr n - //PDFR_DEBUG { - (Font ) print dup = - } if % s fr n - 1 index /FontDescriptor known { % s fr n - //PDFR_DEBUG { - (Font from a font descriptor.) = - } if - 1 index % s fr n fr - /FontDescriptor //DoNothing //ResolveD exec % s fr n fd - /Font //knownget exec { - exch pop % s fr fd - } { - //PDFR_DEBUG { - (Font descriptor has no Font resolved.) = - } if - //GetInstalledFont exec % s fr f - } ifelse - } { - //GetInstalledFont exec % s fr f - } ifelse - exch % s f fr - dup /Encoding known not { - 1 index /Encoding get 1 index exch /Encoding exch put - } if - //ObtainEncoding exec - //ObtainMetrics exec - exch - dup length dict copy % s fr f - dup 2 index /Encoding get % s fr f f e - /Encoding exch put % s fr f - 1 index /Metrics //knownget exec { % s fr f M - 2 index /Subtype get /TrueType ne { - 1 index /FontMatrix get 0 get - dup 0 eq { - % FontMatrix[0] == 0, so cannot downscale by it - % HACK: downscale by FontMatrix[1], and will get the target value of wx as wy - pop - 1 index /FontMatrix get 1 get - dup 0 eq { pop 1 } if % sorry, FontMatrix is singular so cannot enforce the PDF metrics - } if - 0.001 div - //ScaleMetrics exec - }{ - % Check if we got a /sfnts key in the dict - % If we did then we are probably OK (TT font from GS) - 1 index /sfnts known not { - % otherwise we need to check the FontMatrix - 1 index /FontMatrix get 0 get - dup 0 eq { - % FontMatrix[0] == 0, so cannot downscale by it - % HACK: downscale by FontMatrix[1], and will get the target value of wx as wy - pop - 1 index /FontMatrix get 1 get - dup 0 eq { pop 1 } if % sorry, FontMatrix is singular so cannot enforce the PDF metrics - } if - //ScaleMetrics exec - } if - } ifelse - 1 index exch /Metrics exch put % s fr f - } if - 1 index /BaseFont get % s fr f n - exch - dup /FID undef - dup /UniqueID undef - definefont % s fr f - dup 3 1 roll % s f fr f - /Font exch put % s f - exit - } if - dup /Subtype get /Type3 eq { % s rn fr - //ObtainEncoding exec - 2 copy exch /FontName exch put - dup /CharProcs get //ResolveDict exec - dup /FontType 3 put - dup /BuildChar //BuildChar put - dup dup /Font exch put - % Ignore Metrics because pdfwrite duplicates it - % from setcharwidth/setcachedevice. - dup 3 1 roll % s fr rn fr - definefont % s fr f - 2 copy ne { - % The interpreter copied the font dictionary while 'definefont' - % Need to update the font pointer in the resource. - 2 copy /Font exch put % s fr f - } if - exch pop % s f - exit - } if - dup /Subtype get /Type0 eq { % s rn fr - } if - dup /Subtype get /CIDFontType0 eq { % s rn fr - } if - dup /Subtype get /CIDFontType2 eq { % s rn fr - } if - mark (Unknown font type ) 2 index /Subtype get //error exec - } loop - } ifelse % s f - exch scalefont setfont % -} bind def - -/ResolveAndSetFont % ResolveAndSetFont - -{ - //ResolveAndSetFontAux exec -} bind def - -%%beg TrueType -% ================= Auxiliary procedures for True Type cmap Decoder ============= - -/.knownget -{ 2 copy known { - get true - } { - pop pop false - } ifelse -} bind def - -/.min -{ 2 copy lt { - exch - } if - pop -} bind def - -/.max -{ 2 copy gt { - exch - } if - pop -} bind def - -/.dicttomark -{ >> -} bind def - -% ===================== True Type cmap Decoder ============= -% The following procedures are copied from gs/lib/gs_ttf.ps with no change. - -% getu16 -/getu16 { - 2 copy get 8 bitshift 3 1 roll 1 add get add -} bind def - -% gets16 -/gets16 { - getu16 16#8000 xor 16#8000 sub -} bind def - -% getu32 -/getu32 { - 2 copy getu16 16 bitshift 3 1 roll 2 add getu16 add -} bind def - -% gets32 -/gets32 { - 2 copy gets16 16 bitshift 3 1 roll 2 add getu16 add -} bind def - -% Each procedure in this dictionary is called as follows: -% proc -/cmapformats mark - 0 { % Apple standard 1-to-1 mapping. - 6 256 getinterval { } forall 256 packedarray - } bind - 2 { % Apple 16bit CJK (ShiftJIS etc) - - % /sHK_sz subHeaderKey_size % 1 * uint16 - % /sH_sz subHeader_size % 4 * uint16 - % /sH_len subHeader_length - % /cmapf2_tblen total table length - % /cmapf2_lang language code (not used) - % /sHKs subHeaderKeys - - /sHK_sz 2 def - /sH_sz 8 def - dup 2 getu16 /cmapf2_tblen exch def - - dup 4 getu16 /cmapf2_lang exch def - - dup 6 256 sHK_sz mul getinterval /sHKs exch def - - 0 % initialization value for /sH_len - 0 1 255 { - sHKs exch - 2 mul getu16 - 1 index % get current max - 1 index % get current subHeaderKey - lt {exch} if pop - } for - /sH_len exch def - - dup 6 256 sHK_sz mul add - cmapf2_tblen 1 index sub getinterval - /sH_gIA exch def - - /cmapf2_glyph_array 65535 array def - - /.cmapf2_putGID { - /cmapf2_ch cmapf2_ch_hi 8 bitshift cmapf2_ch_lo add def - firstCode cmapf2_ch_lo le - cmapf2_ch_lo firstCode entryCount add lt - and { % true: j is inside - sH_offset idRangeOffset add % offset to gI - cmapf2_ch_lo firstCode sub 2 mul % rel. pos. in range - add 6 add % offset in sH_gIA - sH_gIA exch getu16 - dup 0 gt { % - idDelta add - cmapf2_glyph_array exch cmapf2_ch exch put - } { - pop - % cmapf2_glyph_array cmapf2_ch 0 put - } ifelse - } { % false: j is outside - % cmapf2_glyph_array cmapf2_ch 0 put - } ifelse - } def - - 16#00 1 16#ff { % hi_byte scan - /cmapf2_ch_hi exch def - sHKs cmapf2_ch_hi sHK_sz mul getu16 - /sH_offset exch def - sH_gIA sH_offset sH_sz getinterval - dup 0 getu16 /firstCode exch def - dup 2 getu16 /entryCount exch def - dup 4 gets16 /idDelta exch def - dup 6 getu16 /idRangeOffset exch def - pop - sH_offset 0 eq { - /cmapf2_ch_lo cmapf2_ch_hi def - /cmapf2_ch_hi 0 def - .cmapf2_putGID - } { - 16#00 1 16#ff { % lo_byte scan - /cmapf2_ch_lo exch def - .cmapf2_putGID - } for - } ifelse - } for - pop - 0 1 cmapf2_glyph_array length 1 sub { % rewrite null -> 0. - dup cmapf2_glyph_array exch get - null eq { cmapf2_glyph_array exch 0 put } {pop} ifelse - } for - cmapf2_glyph_array - } bind - 4 { % Microsoft/Adobe segmented mapping. - /etab exch def - /nseg2 etab 6 getu16 def - 14 /endc etab 2 index nseg2 getinterval def - % The Apple TrueType documentation omits the 2-byte - % 'reserved pad' that follows the endCount vector! - 2 add - nseg2 add /startc etab 2 index nseg2 getinterval def - nseg2 add /iddelta etab 2 index nseg2 getinterval def - nseg2 add /idroff etab 2 index nseg2 getinterval def - % The following hack allows us to properly handle - % idiosyncratic fonts that start at 0xf000: - pop - /firstcode startc 0 getu16 16#ff00 and dup 16#f000 ne { pop 0 } if def - /striptopbyte false def - /putglyph { - glyphs code 3 -1 roll put /code code 1 add def - } bind def - % Do a first pass to compute the size of the glyphs array. - /numcodes 0 def /glyphs 0 0 2 nseg2 3 sub { - % Stack: /glyphs numglyphs i2 - /i2 exch def - /scode startc i2 getu16 def - /ecode endc i2 getu16 def - ecode lastcode gt { - /lastcode ecode def - } if - } for pop - % If the glyph range is within 0x..00 to 0x..FF, make sure that we strip - % off any top bytes. - firstcode 16#f000 ge lastcode firstcode sub 255 le and { - lastcode 255 and - /striptopbyte true def - } { - lastcode - }ifelse - 1 add - array def - % prefill the array with 0's faster than a { 0 putglyph } repeat - glyphs length 1024 ge { - .array1024z 0 1024 glyphs length 1023 sub { glyphs exch 2 index putinterval } for - glyphs dup length 1024 sub 3 -1 roll - putinterval - } { - 0 1 glyphs length 1 sub { glyphs exch 0 put } for - } ifelse - % Now fill in the array. - /numcodes 0 def /code 0 def - 0 2 nseg2 3 sub { - /i2 exch def - /scode startc i2 getu16 def - /ecode endc i2 getu16 def - numcodes scode firstcode sub - % Hack for fonts that have only 0x0000 and 0xf000 ranges - %dup 16#e000 ge { 255 and } if - % the previous line is obstructive to CJK fonts, so it was removed - exch sub 0 .max dup /code exch code exch add def - ecode scode sub 1 add add numcodes add /numcodes exch def - /delta iddelta i2 gets16 def - TTFDEBUG { - (scode=) print scode =only - ( ecode=) print ecode =only - ( delta=) print delta =only - ( droff=) print idroff i2 getu16 = - } if - idroff i2 getu16 dup 0 eq { - pop scode delta add 65535 and 1 ecode delta add 65535 and - striptopbyte { - /code scode 255 and def - } { - /code scode def - } ifelse - { putglyph } for - } { % The +2 is for the 'reserved pad'. - /gloff exch 14 nseg2 3 mul add 2 add i2 add add def - striptopbyte { - /code scode 255 and def - } { - /code scode def - } ifelse - 0 1 ecode scode sub { - 2 mul gloff add etab exch getu16 - dup 0 ne { delta add 65535 and } if putglyph - } for - } ifelse - } for glyphs /glyphs null def % for GC - } bind - 6 { % Single interval lookup. - dup 6 getu16 /firstcode exch def dup 8 getu16 /ng exch def - firstcode ng add array - % Stack: tab array - % Fill elements 0 .. firstcode-1 with 0 - 0 1 firstcode 1 sub { 2 copy 0 put pop } for - dup firstcode ng getinterval - % Stack: tab array subarray - % Fill elements firstcode .. firstcode+nvalue-1 with glyph values - 0 1 ng 1 sub { - dup 2 mul 10 add 4 index exch getu16 3 copy put pop pop - } for pop exch pop - } bind -.dicttomark readonly def % cmapformats - -% cmaparray -/cmaparray { - dup 0 getu16 cmapformats exch .knownget { - TTFDEBUG { - (cmap: format ) print 1 index 0 getu16 = flush - } if exec - } { - (Can't handle format ) print 0 getu16 = flush - 0 1 255 { } for 256 packedarray - } ifelse - TTFDEBUG { - (cmap: length=) print dup length = dup == - } if -} bind def - -% Define remapping for misnamed glyphs in TrueType 'post' tables. -% There are probably a lot more than this! -/postremap mark - /Cdot /Cdotaccent - /Edot /Edotaccent - /Eoverdot /Edotaccent - /Gdot /Gdotaccent - /Ldot /Ldotaccent - /Zdot /Zdotaccent - /cdot /cdotaccent - /edot /edotaccent - /eoverdot /edotaccent - /gdot /gdotaccent - /ldot /ldotaccent - /zdot /zdotaccent -.dicttomark readonly def - -/get_from_stringarray % get_from_stringarray -{ 1 index type /stringtype eq { - get - } { - exch { % o () - 2 copy length ge { - length sub - } { - exch get exit - } ifelse - } forall - } ifelse -} bind def - -/getinterval_from_stringarray % getinterval_from_stringarray -{ % May allocate a string in VM. - 2 index type /stringtype eq { - getinterval - } { - string exch 0 % [] s o p - 4 3 roll { % s o p Si - dup length % s o p Si lSi - dup 4 index lt { - 3 index exch sub % s o p Si o' - exch pop 3 1 roll exch pop % s o' p - } { % s o p Si lSi - dup 3 1 roll % s o p lSi Si lSi - 4 index sub % s o p lSi Si lSi-o - 5 index length 4 index sub % s o p lSi Si lSi-o ls-p - 2 copy gt { exch } if pop % s o p lSi Si minl - dup 3 1 roll % s o p lSi minl Si minl - 5 index exch getinterval % s o p lSi minl from - 5 index 4 index 3 index % s o p lSi minl from s p minl - getinterval % s o p lSi minl from to - copy pop % s o p lSi minl - exch pop add exch pop 0 exch % s 0 p' - dup 3 index length ge { exit } if - } ifelse - } forall - pop pop % s - } ifelse -} bind def - -/string_array_size % string_array_size - { dup type /stringtype eq { - length - } { - 0 exch { length add } forall - } ifelse -} bind def - -% Each procedure in this dictionary is called as follows: -% posttable <> glyphencoding -/postformats mark - 16#00010000 { % 258 standard Macintosh glyphs. - pop MacGlyphEncoding - } - 16#00020000 { % Detailed map, required by Microsoft fonts. - dup dup type /arraytype eq { 0 get } if length 36 lt { - TTFDEBUG { (post format 2.0 invalid.) = flush } if - pop [ ] - } { - /postglyphs exch def - /post_first postglyphs dup type /arraytype eq { 0 get } if def - post_first 32 getu16 /numglyphs exch def - /glyphnames numglyphs 2 mul 34 add def - % Build names array in the order they occur in the 'post' table - /postpos glyphnames def - /total_length postglyphs //string_array_size exec def - numglyphs array 0 1 numglyphs 1 sub { - postpos total_length ge { - % Fill the rest with .notdef - 1 numglyphs 1 sub { 1 index exch /.notdef put } for - exit - } if - % No name available, /postnames will be defined as an empty - % array and the glyph won't get a name attached. - postglyphs postpos //get_from_stringarray exec - postglyphs postpos 1 add 2 index //getinterval_from_stringarray exec cvn - exch postpos add 1 add /postpos exch def - 2 index 3 1 roll - put - } for - /postnames exch def - numglyphs array 0 1 numglyphs 1 sub { - dup 2 mul 34 add postglyphs exch 2 //getinterval_from_stringarray exec - dup 0 get 8 bitshift exch 1 get add dup 258 lt { - MacGlyphEncoding exch get - } { - dup 32768 ge { - % According to the published TrueType spec, such values are - % "reserved for future use", but at least some PDF files - % produced by the Adobe PDF library contain entries with a - % value of 16#ffff. - pop /.notdef - } { - % Get the name for this glyph - 258 sub dup postnames length ge { - TTFDEBUG { ( *** warning: glyph index past end of 'post' table) = flush } if - pop - exit - } if - postnames exch get - % At least some of Microsoft's TrueType fonts use incorrect - % (Adobe-incompatible) names for some glyphs. - % Correct for this here. - postremap 1 index .knownget { exch pop } if - } ifelse - } ifelse - 2 index 3 1 roll put - } for - - } - ifelse - } bind - 16#00030000 { % No map. - pop [ ] - } bind -.dicttomark readonly def % postformats - -/first_post_string % - first_post_string -{ - post dup type /arraytype eq { 0 get } if -} bind def - -% - .getpost - -% Uses post, defines glyphencoding -/.getpost { - /glyphencoding post null eq { - TTFDEBUG { (post missing) = flush } if [ ] - } { - postformats first_post_string 0 getu32 .knownget { - TTFDEBUG { - (post: format ) print - first_post_string - dup 0 getu16 =only (,) print 2 getu16 = flush - } if - post exch exec - } { - TTFDEBUG { (post: unknown format ) print post 0 getu32 = flush } if [ ] - } ifelse - } ifelse def -} bind def - -% ===================== True Type Interpretation ============= - -/TTParser << - /Pos 0 - /post null ->> def - -/readu8 % readu8 -{ read not { - mark (Insufficient data in the stream.) //error exec - } if -} bind def - -/readu16 % readu16 -{ dup //readu8 exec 8 bitshift exch //readu8 exec or -} bind def - -/reads16 % reads16 -{ //readu16 exec 16#8000 xor 16#8000 sub -} bind def - -/readu32 % readu32 -{ dup //readu16 exec 16 bitshift exch //readu16 exec or -} bind def - -/reads32 % reads32 -{ dup //reads16 exec 16 bitshift exch //readu16 exec or -} bind def - -/SkipToPosition % SkipToPosition - -{ dup //TTParser /Pos get % f P P p - exch //TTParser exch /Pos exch put % f P p - sub % f P-p - //PDFR_DEBUG { - (Skipping ) print dup //=only exec ( bytes.) = - } if - dup 0 eq { - pop pop - } { - dup 3 1 roll % P-p f P-p - () /SubFileDecode filter % P-p f' - exch % f' P-p - { 1 index //BlockBuffer readstring pop length - dup 0 eq { pop exch pop exit } if - sub - } loop - 0 ne { - mark (Insufficient data in the stream for SkipToPosition.) //error exec - } if - } ifelse -} bind def - -/TagBuffer 4 string def - -/ParseTTTableDirectory % ParseTTTableDirectory -{ //PDFR_DEBUG { - (ParseTTTableDirectory beg) = - } if - 15 dict begin - dup //readu32 exec 16#00010000 ne { - mark (Unknown True Type version.) //error exec - } if - dup //readu16 exec /NumTables exch def - dup //readu16 exec /SearchRange exch def - dup //readu16 exec /EntrySelector exch def - dup //readu16 exec /RangeShift exch def - //PDFR_DEBUG { - (NumTables = ) print NumTables = - } if - NumTables { - dup //TagBuffer readstring not { - mark (Could not read TT tag.) //error exec - } if - cvn - [ 2 index //readu32 exec pop % CheckSum - 2 index //readu32 exec % Offset - 3 index //readu32 exec % Length - ] - //PDFR_DEBUG { - 2 copy exch //=only exec ( ) print == - } if - def - } repeat - pop % file - //TTParser /Pos 12 NumTables 16 mul add put - currentdict end - //PDFR_DEBUG { - (ParseTTTableDirectory end) = - } if -} bind def - -/ParseTTcmap % ParseTTcmap -{ //PDFR_DEBUG { - (ParseTTcmap beg) = - } if - /cmap get aload pop % f o L - 3 1 roll % L f o - 7 dict begin - //PDFR_DEBUG { - (Current position = ) print //TTParser /Pos get = - (cmap position = ) print dup = - } if - 1 index exch //SkipToPosition exec % L f - //TTParser /Pos get /TablePos exch def - dup //readu16 exec pop % version - dup //readu16 exec /NumEncodings exch def - //PDFR_DEBUG { - (NumEncodings = ) print NumEncodings = - } if - null % L f null - NumEncodings { - 1 index //readu32 exec % platformID, specificID % L f null id - 2 index //readu32 exec % offset % L f null id o - 3 array dup 3 2 roll 0 exch put % L f []|null id [] - 2 index null ne { - dup 0 get 3 index 0 get sub % L f []|null id [] l - 3 index exch 1 exch put % L f []|null id [] - } if - dup 4 3 roll pop 3 1 roll % L f [] id [] - def - } repeat % L f [] - dup 0 get % L f [] o - 4 3 roll exch sub % f [] L-o - 1 exch put % f - //PDFR_DEBUG { - currentdict { - exch dup type /integertype eq { - //PrintHex exec ( ) print == - } { - pop pop - } ifelse - } forall - } if - 4 NumEncodings 8 mul add /HeaderLength exch def - //TTParser /Pos //TTParser /Pos get HeaderLength add put - 0 % f o - NumEncodings { - 16#7FFFFFF null % f o om null|[] - % Choosing a table with minimal offset greater than 'o' : - currentdict { - 1 index type /integertype eq { % f o om null|[] id [] - exch pop dup 0 get % f o om null|[] [] oi - dup 5 index gt { - dup 4 index lt { - 4 1 roll % f o oi om null|[] [] - exch pop exch pop % f o oi [] - } { - pop pop - } ifelse - } { - pop pop - } ifelse % f o oi [] - } { - pop pop - } ifelse - } forall % f o om' [] - //PDFR_DEBUG { - (Obtaining subtable for ) print dup == - } if - 3 2 roll pop % f o' [] - 3 copy pop % f o' [] f o' - TablePos add //SkipToPosition exec % f o' [] - 3 copy exch pop 1 get % f o' [] l - //TTParser /Pos //TTParser /Pos get 3 index add put - string % f o' [] f () - readstring not { - mark (Can't read a cmap subtable.) //error exec - } if % f o' [] () - 2 exch put % f o' - } repeat - pop pop % - currentdict end - //PDFR_DEBUG { - (ParseTTcmap end) = - } if -} bind def - -/GetTTEncoding % GetTTEncoding -{ //PDFR_DEBUG { - (GetTTEncoding beg) = - } if - get % f [] - exch pop % [] - 2 get - 10 dict begin % For local variables. - /TTFDEBUG //PDFR_DEBUG def - //cmaparray exec - end - //PDFR_DEBUG { - (GetTTEncoding end) = - dup == - } if -} bind def - -/InverseEncoding % InverseEncoding -{ - 256 dict begin - dup length 1 sub -1 0 { % E i - 2 copy get % E i n - exch % E n i - 1 index currentdict exch //knownget exec { % E n i e - dup type /arraytype eq { - aload length 1 add array astore % E n e' - } { - 2 array astore % E n e' - } ifelse - } if - def - } for - pop - currentdict end -} bind def - -/GetMacRomanEncodingInverse -{ //PDFReader /MacRomanEncodingInverse get - dup null eq { - pop - MacRomanEncoding //InverseEncoding exec - dup //PDFReader exch /MacRomanEncodingInverse exch put - } if -} bind def - -/PutCharStringSingle % PutCharStringSingle -{ - dup 3 index length lt { % cmap name code - 2 index exch get % cmap name glyphindex - dup 0 ne { - def % cmap - } { - pop pop - } ifelse - } { - pop pop % cmap - } ifelse -} bind def - -/PutCharString % PutCharString -{ 1 index type /nametype ne { - mark (Bad charstring name) //error exec - } if - dup type /arraytype eq { - { % cmap name code - 3 copy //PutCharStringSingle exec % cmap name code cmap - pop pop % cmap name - } forall - pop % cmap - } { - //PutCharStringSingle exec - } ifelse -} bind def - -/ComposeCharStrings % ComposeCharStrings -{ - //PDFR_DEBUG { - (ComposeCharStrings beg) = - } if - 1 index length 1 add dict begin % cmap d - % fixme : the dict length estimation doesn't account 'post'. - /.notdef 0 def - exch % d cmap - //TTParser /post get % d cmap [post]|null - dup null ne { - exch % d [] cmap - 1 index length 1 sub -1 0 { % d [] cmap code - dup 3 index exch get exch % d [] cmap name code - dup 0 eq 2 index /.notdef eq or { % do not re-encode GID 0, or the - % /.notdef glyph name - pop pop - } { - def - } ifelse - } for - } if - exch pop exch % cmap d - { % cmap name code - //PutCharString exec - } forall % cmap - pop % - currentdict end - //PDFR_DEBUG { - (ComposeCharStrings end) = - } if -} bind def - -/ParseTTpost % ParseTTpost - -{ % Defines TTparser.post - an array, - % which maps glyph indices to glyph names. - //PDFR_DEBUG { - (ParseTTpost beg) = - } if - /post get aload pop % f o L - 3 1 roll % L f o - //PDFR_DEBUG { - (Current position = ) print //TTParser /Pos get = - (post position = ) print dup = - } if - 1 index exch //SkipToPosition exec % L f - //TTParser /Pos //TTParser /Pos get 4 index add put - exch dup 65535 le { - string % f s - readstring not { - mark (Insufficient data in the stream for ParseTTpost.) //error exec - } if % s - } { - % f s - [ 3 1 roll % [ f s - dup 16384 div floor cvi % [ f s numblocks - exch 1 index 16384 mul % [ f numblocks s bytesinblocks - sub exch % [ f remainder numblocks - 1 sub 0 1 3 -1 roll % [ f remainder 0 1 numblocks - { - 1 add index % [ f remainder () ()... f - 16384 string readstring not { - mark (Insufficient data in the stream for ParseTTpost.) //error exec - } if - } for - % [ f remainder () ()... - counttomark -2 roll % [ () ()... f remainder - string readstring not{ - mark (Insufficient data in the stream for ParseTTpost.) //error exec - } if - ] - } ifelse - 1 dict begin % A bridge to the code from /gs/lib/gs_ttf.ps . - /post exch def - //.getpost exec - //TTParser /post glyphencoding put - //PDFR_DEBUG { - (ParseTTpost end) = - glyphencoding == - } if - end -} bind def - -/MakeTTCharStrings % MakeTTCharStrings -{ //MakeStreamReader exec % f - dup dup //ParseTTTableDirectory exec % f f d - % Since the file isn't positionable, - % we must pick up either 'post' or 'cmap' first. - % Deside which one we do first : - //TTParser /post null put - dup /post //knownget exec { - 0 get - 1 index /cmap get 0 get - lt { - 2 copy //ParseTTpost exec % f f d - //ParseTTcmap exec % f ch - } { - 2 copy //ParseTTcmap exec % f f d ch - 3 1 roll % f ch f d - //ParseTTpost exec % f ch - } ifelse - } { - //ParseTTcmap exec % f ch - } ifelse - { - dup 16#00030001 known { - //PDFR_DEBUG { - (Using the TT cmap encoding for Windows Unicode.) = - } if - 16#00030001 //GetTTEncoding exec - AdobeGlyphList //ComposeCharStrings exec - exit - } if - dup 16#00010000 known { - //PDFR_DEBUG { - (Using the TT cmap encoding for Macintosh Roman.) = - } if - 16#00010000 //GetTTEncoding exec - PDFEncoding dup null eq { - pop //GetMacRomanEncodingInverse exec - } { - //InverseEncoding exec - } ifelse - //ComposeCharStrings exec - exit - } if - dup 16#00030000 known { - //PDFR_DEBUG { - (Using the TT cmap encoding 3.0 - not sure why Ghostscript writes it since old versions.) = - } if - % Same algorithm as for 16#00010000. - 16#00030000 //GetTTEncoding exec - PDFEncoding dup null eq { - pop //GetMacRomanEncodingInverse exec - } { - //InverseEncoding exec - } ifelse - //ComposeCharStrings exec - exit - } if - mark (True Type cmap has no useful encodings.) //error exec - } loop - //PDFR_DEBUG { - (CharStrings <<) = - dup { - exch - dup type /nametype eq { - //=only exec - } { - == - } ifelse - ( ) print == - } forall - (>>) = - } if -} bind def - -%%end TrueType - -% ===================== Functions ============================ - -/ScaleVal % ScaleVal -{ - aload pop % v r0 r1 - 1 index sub % v r0 r1-r0 - 3 2 roll mul add -} bind def - -/ScaleArg % ScaleArg -{ - aload pop % a d0 d1 - 1 index sub % a d0 d1-d0 - 3 1 roll % d1-d0 a d0 - sub exch div % (a-d0)/(d1-d0) -} bind def - -/ScaleArgN % ... ScaleArg ... -{ - dup length 2 sub -2 0 { % a1 ... an [] 2i - 2 % a1 ... an [] 2i 2 - 2 index 3 1 roll getinterval % a1 ... an [] [] - 3 2 roll % a1 ... [] [] an - exch //ScaleArg exec % a1 ... [] an' - 1 index length 2 idiv 1 add 1 roll % an' a1 ... [] - } for % a1' ... an' [] - pop % a1' ... an' -} bind def - - -/ComputeFunction_10 % ComputeFunction_10 -{ % Assuming a 1-argument 1-result function type 0. - //PDFR_DEBUG { - (ComputeFunction_10 beg ) print 1 index //=only exec ( stack=) print count = - } if - exch % [] x - dup 1 eq { - pop dup length 1 sub get % y - } { - 1 index length 1 sub mul % [] x*(l-1) - dup dup floor sub % [] x*(l-1) f - dup 0 eq { - pop cvi get % y - } { - 3 1 roll floor cvi % f [] i - 2 getinterval % f [] - aload pop % f y0 y1 - 2 index mul 3 2 roll 1 exch sub 3 2 roll mul add % y1*f+(1-f)*y0 - } ifelse - } ifelse - //PDFR_DEBUG { - (ComputeFunction_10 end ) print dup //=only exec ( stack=) print count = - } if -} bind def - -/ComputeFunction_n0 % .... ComputeFunction_n0 -{ % Assuming a n-argument 1-result function type 0. - //PDFR_DEBUG { - (ComputeFunction_n0 beg N=) print dup //=only exec ( stack=) print count = - } if - dup 0 eq { % v 0 - pop % v - } { - dup 2 add -1 roll % a2 .... an [] n a1 - dup 3 index length 1 sub ge { - pop 1 sub % a2 .... an [] n-1 - exch dup length 1 sub get exch - //PDFReader /ComputeFunction_n0 get exec - } { - dup floor cvi dup % a2 .... an [] n a1 i i - 4 index exch get % a2 .... an [] n a1 i [i] - 3 index dup % a2 .... an [] n a1 i [i] n n - 5 add copy % a2 .... an [] n a1 i [i] n a2 .... an [] n a1 i [i] n - 6 2 roll % a2 .... an [] n a1 i [i] n a2 .... an [i] n [] n a1 i - pop pop pop pop % a2 .... an [] n a1 i [i] n a2 .... an [i] n - 1 sub % a2 .... an [] n a1 i [i] n a2 .... an [i] n-1 - //PDFReader /ComputeFunction_n0 get exec % a2 .... an [] n a1 i [i] n v0 - 3 2 roll pop % a2 .... an [] n a1 i n v0 - exch % a2 .... an [] n a1 i v0 n - 4 3 roll exch % a2 .... an [] n i v0 a1 n - 4 add 2 roll 1 add % v0 a1 a2 .... an [] n i+1 - 3 2 roll exch get % v0 a1 a2 .... an n [i+1] - exch 1 sub % v0 a1 a2 .... an [i+1] n-1 - //PDFReader /ComputeFunction_n0 get exec % v0 a1 v1 - 1 index mul % v0 a1 v1*a1 - 3 1 roll % v1*a1 v0 a1 - 1 exch sub mul add % v1*a1+v0*(1-a1) - } ifelse - } ifelse - //PDFR_DEBUG { - (ComputeFunction_n0 end ) print dup //=only exec ( stack=) print count = - } if -} bind def - -/FunctionToProc_x01 % FunctionToProc_x01 -{ % Assuming a n-argument 1-result function type 0. - % The stream is already converted to the array /Data. - dup /Domain get exch - dup /Data get 0 get exch - /Size get length - [ 4 1 roll - //PDFR_DEBUG { - { (function beg, stack =) print count //=only exec (\n) print } /exec load - 5 2 roll - } if - dup 1 gt { % a1 ... an Domain Data n - { mark exch % a1 ... an Domain Data [ n - 3 add 2 roll % Data [ a1 ... an Domain - //ScaleArgN exec % Data [ a1 ... an - counttomark dup % Data [ a1 ... an n n - 3 add -2 roll % a1 ... an n Data [ - pop exch % a1 ... an Data n - //ComputeFunction_n0 exec - } /exec load - } { - pop % a1 Domain Data - 3 1 /roll load //ScaleArg /exec load % Data a1s - /exch load - //ComputeFunction_10 /exec load - } ifelse - //PDFR_DEBUG { - (function end, stack =) /print load /count load //=only /exec load (\n) /print load - } if - ] cvx - //PDFR_DEBUG { - (Made a procedure for the 1-result function :) = - dup == - } if -} bind def - -/FunctionProcDebugBeg % - FunctionProcDebugBeg - -{ (FunctionProcDebugBeg ) print count = -} bind def - -/FunctionProcDebugEnd % - FunctionProcDebugEnd - -{ (FunctionProcDebugEnd ) print count = -} bind def - -/FunctionToProc_x0n % FunctionToProc_x0n -{ % Assuming a n-argument m-result function type 0. - % The stream is already converted to the array /Data. - % - % Making the procedure : { Domain //ScaleArg exec ... n copy {} exec n+1 1 roll ... } - % except "n copy" for the last chunk. - % - PDFR_DEBUG { - (FunctionToProc_x0n beg m=) print dup = - } if - 1 index /Size get length exch % f n m - dup 7 mul 2 add array % f n m [] - PDFR_DEBUG { - dup 0 //FunctionProcDebugBeg put - } { - dup 0 //DoNothing put - } ifelse - dup 1 /exec load put - dup 2 5 index /Domain get put - 2 index 1 eq { - dup 3 //ScaleArg put - } { - dup 3 //ScaleArgN put - } ifelse - dup 4 /exec load put - 1 index 1 sub 0 exch 1 exch { % f n m [] i - dup 7 mul 5 add % f n m [] i i1 - 1 index 4 index 1 sub ne { - dup 3 index exch 6 index put 1 add - dup 3 index exch /copy load put 1 add - } if - [ % f n m [] i i1 [ - 6 index /Data get 3 index get % f n m [] i i1 [ di - 6 index 1 eq { - //ComputeFunction_10 /exec load - } { - 6 index - //ComputeFunction_n0 /exec load - } ifelse - ] cvx % f n m [] i i1 {} - 3 index exch 2 index exch put 1 add % f n m [] i i1 - 2 index 1 index /exec load put 1 add - 1 index 4 index 1 sub ne { - 2 index 1 index 6 index 1 add put 1 add - 2 index 1 index 1 put 1 add - 2 index 1 index /roll load put % f n m [] i i1 - } if - pop pop % f n m [] - } for - PDFR_DEBUG { - dup dup length 2 sub //FunctionProcDebugEnd put - } { - dup dup length 2 sub //DoNothing put - } ifelse - dup dup length 1 sub /exec load put - cvx exch pop exch pop exch pop - //PDFR_DEBUG { - (Made a procedure for the n-argument function :) = - dup == - } if - PDFR_DEBUG { - (FunctionToProc_x0n end) = - } if -} bind def - -/MakeTableRec % MakeTableRec -{ - 0 % to be bound below - exec -} bind def - -/MakeTable % MakeTable -{ //PDFR_DEBUG { - (MakeTable beg ) print count = - } if - 1 index /Size get exch % f S N - 1 sub dup % f S n n - 3 1 roll % f n S n - get % f n s - array % f n [] - 1 index 0 eq { - exch pop exch pop % [] - } { - dup length 1 sub -1 0 { % f n [] i - 3 index 3 index //MakeTableRec exec % f n [] i [] - 2 index 3 1 roll put % f n [] - } for - exch pop exch pop - } ifelse - //PDFR_DEBUG { - (MakeTable end ) print count = - } if -} bind def - -//MakeTableRec 0 //MakeTable put - -/StoreSample % StoreSample - -{ % The reader is on the dictionary stack. - 1 sub - dup 0 eq { - pop % v [] - } { - -1 1 { % v T i - I exch get get % v T[I[i]] - } for % v [] - } ifelse - I 0 get 3 2 roll put -} bind def - -/ReadSample32 % - ReadSample32 -{ - 4 { - File read not { - mark (Insufficient data for function.) //error exec - } if - } repeat - pop % Ignore the last byte because it can't fit into 'real'. - 3 1 roll exch - 256 mul add 256 mul add - //1_24_bitshift_1_sub div -} bind def - -/ReadSample % - ReadSample -{ % The reader in on the dictionary stack. - Buffer BitsLeft BitsPerSample - { 2 copy ge { - exit - } if - 3 1 roll - 8 add 3 1 roll - 256 mul File read not { - mark (Insufficient data for function.) //error exec - } if - add - 3 1 roll - } loop % b bl pbs - sub dup % b bl-bps bl-bps - 2 index exch % b bl-bps b bl-bps - neg bitshift % b bl-bps v - 2 copy exch bitshift % b bl-bps v v<<(bl-bps) - 4 3 roll exch sub % bl-bps v b-(v<<(bl-bps)) - /Buffer exch def % bl-bps v - exch /BitsLeft exch def % v - Div div % v/(1< ReadSamplesRec - -{ 0 % Will be bound below - exec -} bind def - -/ReadSamples % ReadSamples - -{ % The reader in on the dictionary stack. - //PDFR_DEBUG { - (ReadSamples beg ) print count = - } if - dup 1 eq { - pop - 0 1 Size 0 get 1 sub { - I exch 0 exch put - 0 1 M 1 sub { - dup Range exch 2 mul 2 getinterval % m r - //PDFR_DEBUG { - (Will read a sample ... ) print - } if - BitsPerSample 32 eq { //ReadSample32 } { //ReadSample } ifelse - exec exch //ScaleVal exec % m v - //PDFR_DEBUG { - (value=) print dup = - } if - exch Table exch get % v [] - Size length //StoreSample exec % - } for - } for - } { - 1 sub - dup Size exch get 0 exch 1 exch 1 sub { % d-1 i - I exch 2 index exch put % d-1 - dup //ReadSamplesRec exec % d-1 - } for - pop - } ifelse - //PDFR_DEBUG { - (ReadSamples end ) print count = - } if -} bind def - -//ReadSamplesRec 0 //ReadSamples put - -/StreamToArray % StreamToArray - -{ //PDFR_DEBUG { - (StreamToArray beg ) print count = - } if - userdict /FuncDataReader get begin % f - dup /BitsPerSample get /BitsPerSample exch def - dup /Size get length /N exch def - dup /Range get length 2 idiv /M exch def - 1 BitsPerSample bitshift 1 sub /Div exch def - /BitsLeft 0 def - /Buffer 0 def - dup /Size get /Size exch def % f - dup /Range get /Range exch def % f - /File 1 index //MakeStreamReader exec def % f - /I [ N { 0 } repeat ] def % f - M array % f [] - dup length 1 sub -1 0 { % f [] m - 2 index N //MakeTable exec % f [] m T - 2 index 3 1 roll put % f [] - } for - /Table exch def % f - N //ReadSamples exec % f - PDFR_DEBUG { - (Table = ) print Table == - } if - /Data Table put % - end - //PDFR_DEBUG { - (StreamToArray end ) print count = - } if -} bind def - -/FunctionToProc10 % FunctionToProc10 -{ % Assuming a 1-argument function type 0. - PDFR_DEBUG { - (FunctionToProc10 beg, Range = ) print dup /Range get == - } if - dup /Order //knownget exec { - 1 ne { - (Underimplemented function Type 0 Order 3.) = - } if - } if - dup //StreamToArray exec % f - dup /Range get length dup 2 eq { - pop //FunctionToProc_x01 exec % proc - } { - 2 idiv //FunctionToProc_x0n exec % proc - } ifelse - PDFR_DEBUG { - (FunctionToProc10 end) = - } if -} bind def - -/FunctionToProc12 % FunctionToProc12 -{ begin - currentdict /C0 //knownget exec { length 1 eq } { true } ifelse { - N - currentdict /C0 //knownget exec { - 0 get - } { - 0 - } ifelse - currentdict /C1 //knownget exec { - 0 get - } { - 1 - } ifelse - 1 index sub - [ 4 1 roll - { % x n c0 c1-c0 - 4 2 roll % c0 c1-c0 x n - excp mul add % y - } aload pop - ] cvx - } { - [ - 0 1 C0 length 1 sub { - N % [ ... i n - C0 2 index get % [ ... i n c0 - C1 3 index get % [ ... i n c0 c1 - 4 3 roll pop % [ ... n c0 c1 - 1 index sub % [ ... n c0 c1-c0 - [ /dup load % [ ... n c0 c1-c0 [ dup - 5 2 roll % [ ... [ dup n c0 c1-c0 - { % x x n c0 c1-c0 - 4 2 roll % x c0 c1-c0 x n - exp mul add % x y - exch % y x - } aload pop - ] cvx - /exec load - } for - /pop load - ] cvx - } ifelse - end - //PDFR_DEBUG { - (FunctionType2Proc : ) print dup == - } if -} bind def - - -/FunctionToProc14 % FunctionToProc14 -{ //MakeStreamReader exec cvx exec - //PDFR_DEBUG { - (FunctionType4Proc : ) print dup == - } if -} bind def - -/FunctionToProc1 % FunctionToProc -{ % Assuming a 1-argument function. - dup /FunctionType get - { dup 0 eq { - pop //FunctionToProc10 exec exit - } if - dup 2 eq { - pop //FunctionToProc12 exec exit - } if - dup 4 eq { - pop //FunctionToProc14 exec exit - } if - mark exch (Function type ) exch ( isn't implemented yet.) //error exec - } loop -} bind def - -/FunctionToProc20 % FunctionToProc20 -{ % Assuming a 2-argument function type 0. - PDFR_DEBUG { - (FunctionToProc20, Range = ) print dup /Range get == - } if - dup /Order //knownget exec { - 1 ne { - (Underimplemented function Type 0 Order 3.) = - } if - } if - dup //StreamToArray exec % f - dup /Range get length dup 2 eq { - pop //FunctionToProc_x01 exec % proc - } { - 2 idiv //FunctionToProc_x0n exec % proc - } ifelse -} bind def - -/FunctionToProc % FunctionToProc -{ //PDFR_DEBUG { - (FunctionToProc beg ) print count = - } if - dup type /dicttype eq { - dup /Domain get length 2 idiv - { - dup 1 eq { - pop //FunctionToProc1 exec exit - } if - dup 2 eq { - pop //FunctionToProc20 exec exit - } if - mark (Functions with many arguments aren't implemented yet.) //error exec - } loop - } { - //PDFR_DEBUG {(Not a function dict, assume already a procedure.) print } if - } ifelse - //PDFR_DEBUG { - (FunctionToProc end ) print count = - } if -} bind def - -/spotfunctions mark % Copied from pdf_draw.ps - /Round { - abs exch abs 2 copy add 1 le { - dup mul exch dup mul add 1 exch sub - } { - 1 sub dup mul exch 1 sub dup mul add 1 sub - } ifelse - } - /Diamond { - abs exch abs 2 copy add .75 le { - dup mul exch dup mul add 1 exch sub - } { - 2 copy add 1.23 le { - .85 mul add 1 exch sub - } { - 1 sub dup mul exch 1 sub dup mul add 1 sub - } ifelse - } ifelse - } - /Ellipse { - abs exch abs 2 copy 3 mul exch 4 mul add 3 sub dup 0 lt { - pop dup mul exch .75 div dup mul add 4 div 1 exch sub - } { - dup 1 gt { - pop 1 exch sub dup mul exch 1 exch sub - .75 div dup mul add 4 div 1 sub - } { - .5 exch sub exch pop exch pop - } ifelse - } ifelse - } - /EllipseA { dup mul .9 mul exch dup mul add 1 exch sub } - /InvertedEllipseA { dup mul .9 mul exch dup mul add 1 sub } - /EllipseB { dup 5 mul 8 div mul exch dup mul exch add sqrt 1 exch sub } - /EllipseC { dup mul .9 mul exch dup mul add 1 exch sub } - /InvertedEllipseC { dup mul .9 mul exch dup mul add 1 sub } - /Line { exch pop abs neg } - /LineX { pop } - /LineY { exch pop } - /Square { abs exch abs 2 copy lt { exch } if pop neg } - /Cross { abs exch abs 2 copy gt { exch } if pop neg } - /Rhomboid { abs exch abs 0.9 mul add 2 div } - /DoubleDot { 2 {360 mul sin 2 div exch } repeat add } - /InvertedDoubleDot { 2 {360 mul sin 2 div exch } repeat add neg } - /SimpleDot { dup mul exch dup mul add 1 exch sub } - /InvertedSimpleDot { dup mul exch dup mul add 1 sub } - /CosineDot { 180 mul cos exch 180 mul cos add 2 div } - /Double { exch 2 div exch 2 { 360 mul sin 2 div exch } repeat add } - /InvertedDouble { - exch 2 div exch 2 { 360 mul sin 2 div exch } repeat add neg - } -.dicttomark readonly def - -% ===================== Color Spaces and Colors ============== - -/CheckColorSpace % CheckColorSpace -{ - dup type /arraytype ne { - mark (Resource ) 3 index ( must be an array.) //error exec - } if -} bind def - -/SubstitutePDFColorSpaceRec % SubstitutePDFColorSpace -{ 0 % Will be bound below - exec -} bind def - -/SubstitutePDFColorSpace % SubstitutePDFColorSpace -{ - { - dup 0 get /Pattern eq { - dup length 1 gt { - dup dup 1 //CheckColorSpace //ResolveA exec - dup type /nametype ne { - //SubstitutePDFColorSpaceRec exec - } if - 1 exch put - } if - exit - } if - dup 0 get /Indexed eq { - exit - } if - dup 0 get /Separation eq { - dup dup 2 //CheckColorSpace //ResolveA exec - dup type /nametype ne { - //SubstitutePDFColorSpaceRec exec - } if - 2 exch put - exit - } if - dup 0 get /CalGray eq { - 1 get % dict - dup /Gamma //knownget exec { - [ exch [ exch /exp load ] cvx dup dup ] - 1 index exch /DecodeLMN exch put - } if - [ exch /CIEBasedA exch ] % [] - exit - } if - dup 0 get /CalRGB eq { - 1 get % dict - dup /Matrix //knownget exec { - 1 index exch /MatrixLMN exch put - } if - dup /Gamma //knownget exec { - aload pop - [ exch /exp load ] cvx - 3 1 roll - [ exch /exp load ] cvx - 3 1 roll - [ exch /exp load ] cvx - 3 1 roll - 3 array astore - 1 index exch /DecodeLMN exch put - } if - [ exch /CIEBasedABC exch ] % [] - exit - } if - dup 0 get /Lab eq { - 1 get % dict - begin - currentdict /Range //knownget exec { aload pop } { -100 100 -100 100 } ifelse - 0 100 6 2 roll 6 array astore - /RangeABC exch def - /DecodeABC [{16 add 116 div} bind {500 div} bind {200 div} bind] def - /MatrixABC [1 1 1 1 0 0 0 0 -1] def - { dup 6 29 div ge {dup dup mul mul} {4 29 div sub 108 841 div mul} ifelse } - /DecodeLMN [ - % Store white point implicitly inside procedures. - [ 3 index aload pop WhitePoint 0 get /mul load ] cvx - [ 4 index aload pop WhitePoint 1 get /mul load ] cvx - [ 5 index aload pop WhitePoint 2 get /mul load ] cvx - ] def pop - //PDFR_DEBUG { - (Constructed from Lab <<) = - currentdict { exch = == } forall - (>>) = - } if - [ /CIEBasedABC currentdict ] % [] - end - exit - pop - } if - % Check if this is an already substituted space - dup 0 get /CIEBasedA eq {exit} if - dup 0 get /CIEBasedABC eq {exit} if - mark exch (Unimplemented color space ) exch //error exec - } loop -} bind def - -//SubstitutePDFColorSpaceRec 0 //SubstitutePDFColorSpace put - -/ResolveArrayElement % ResolveArrayElement -{ 2 copy get - dup type dup /arraytype eq exch - /packedarraytype eq or { % make sure its a procedure/executable array - xcheck { - 2 copy get % Get executable array - dup 0 get type /integertype eq % ensure first element is an integer - 1 index 1 get type dup /arraytype - eq exch - /packedarraytype eq or % ensure second element is executable array - and { - exec - 2 index 4 1 roll put - } { - pop pop - } ifelse - } { - pop - } ifelse - } { - pop pop - } ifelse -} bind def - -/ResolveColorSpaceArrayRec % ResolveColorSpaceArrayRec -{ 0 % Will be bond below. - exec -} bind def - -/SetColorSpaceSafe % SetColorSpaceSafe - -{ - % This works against applying a pattern over a pattern space, - % which may happen due to duplication of stroking and non-stroking colors. - % gs3.70 fails when setting a pattern space and - % the (old) current color space is a pattern space. - % - % If the new color space is an array and it appears equal to the old one, - % do nothing. Otherwise set the new color space. - PDFR_DEBUG { - (SetColorSpaceSafe beg) = - } if - currentcolorspace dup type /arraytype eq { % cs cs' - 1 index type /arraytype eq { - dup length 2 index length eq { - false exch % cs b cs' - dup length 0 exch 1 exch 1 sub { % cs b cs' i - dup % cs b cs' i i - 4 index exch get exch % cs b cs' csi i - 2 index exch get % cs b cs' csi cs'i - ne { % cs b cs' - exch pop true exch exit - } if - } for % cs b cs' - pop % cs b - { - setcolorspace - } { - pop - } ifelse % - } { - pop setcolorspace - } ifelse - } { - pop setcolorspace - } ifelse - } { % cs cs' - pop setcolorspace - } ifelse - PDFR_DEBUG { - (SetColorSpaceSafe end) = - } if -} bind def - -/ResolveColorSpaceArray % ResolveColorSpaceArray -{ - //PDFR_DEBUG { - (ResolveColorSpaceArray beg ) print dup == - } if - dup 0 get /Indexed eq { - 1 //ResolveArrayElement exec - dup dup 1 get - dup type /arraytype eq { - //SubstitutePDFColorSpace exec - //ResolveColorSpaceArrayRec exec - 1 exch put - } { - pop pop - } ifelse - } if - dup 0 get /Separation eq { - 3 //ResolveArrayElement exec - dup 3 get //FunctionToProc exec - 2 copy 3 exch put - pop - } if - dup 0 get/Pattern eq{ - dup length 1 gt { - dup dup 1 get dup type /arraytype eq { - ResolveColorSpaceArray - 1 index 1 3 -1 roll put - }{ - pop - }ifelse - }if - }if - PDFR_DEBUG { - (Construcrted color space :) = - dup == - } if - //PDFR_DEBUG { - (ResolveColorSpaceArray end ) print dup == - } if -} bind def - -//ResolveColorSpaceArrayRec 0 //ResolveColorSpaceArray put - -/ResolveColorSpace % ResolveColorSpace -{ - //PDFR_DEBUG { - (ResolveColorSpace beg ) print dup = - } if - dup //SimpleColorSpaceNames exch known not { - dup //PDFColorSpaces exch //knownget exec { - exch pop - //PDFR_DEBUG { - (ResolveColorSpace known ) = - } if - } { - dup % n n - //PDFReader /CurrentObject get /Context get /Resources get - /ColorSpace //DoNothing //ResolveD exec - exch //CheckColorSpace //ResolveD exec % n cs - dup type /arraytype eq { - //SubstitutePDFColorSpace exec - //ResolveColorSpaceArray exec - dup //PDFColorSpaces 4 2 roll put % [] - } if - } ifelse - } if - //PDFR_DEBUG { - (ResolveColorSpace end ) print dup == - } if -} bind def - -/CheckPattern % CheckPattern -{ - dup /PatternType //knownget exec { - dup 1 ne { - mark (Resource ) 4 index ( is a shading, which can't be handled at level 2. ) //error exec - } if - pop - } if - dup /Type knownget { % /Type is optional for type 1 pattern dictionaries - /Pattern ne { - mark (Resource ) 4 index ( must have /Type/Pattern .) //error exec - } if - } if -} bind def - -/PaintProc % -{ /Context get % pattern_object - //RunDelayedStream exec -} bind def - -/ResolvePattern % ResolvePattern -{ - dup % n n - % Since makepattern makes a local dictionary, - % we cahche them in userdict, which is in local VM. - % Assuming unique resource name through the document - userdict /PDFR_Patterns get % n n d - exch //knownget exec { % n p - exch pop % p - } { % n - dup % n n - //PDFReader /CurrentObject get /Context get /Resources get - /Pattern //DoNothing //ResolveD exec - exch //CheckPattern //ResolveD exec % n o - dup dup /Context exch put - dup /Resources //DoNothing //ResolveD exec pop - dup /PaintProc //PaintProc put - gsave userdict /PDFR_InitialGS get setgstate - currentglobal exch false setglobal % gs3_70 compatibility - dup /Matrix get - makepattern % n p - exch setglobal % gs3_70 compatibility - grestore - dup userdict /PDFR_Patterns get % n p p d - 4 2 roll % p d n p - put % p - } ifelse -} bind def - -/SetColor % Same arguments and result as for scn -{ //PDFR_DEBUG { - (SetColor beg) = - } if - currentcolorspace dup type /nametype eq { - pop setcolor - } { - 0 get /Pattern eq { - //ResolvePattern exec setpattern - } { - setcolor - } ifelse - } ifelse - //PDFR_DEBUG { - (SetColor end) = - } if -} bind def - -% ===================== Images =============================== - -/ImageKeys 15 dict begin - /BPC /BitsPerComponent def - /CS /ColorSpace def - /D /Decode def - /DP /DecodeParms def - /F /Filter def - /H /Height def - /IM /ImageMask def - % /Intent is undefined - pdfwrite must take care of. - /I /Interpolate def - /W /Width def -currentdict end readonly def - -/ImageValues 15 dict begin - /G /DeviceGray def - /RGB /DeviceRGB def - /CMYK /DeviceCMYK def - /I /Indexed def - /AHx /ASCIIHexDecode def - /A85 /ASCII85Decode def - /LZW /LZWDecode def - /Fl /FlateDecode def - /RL /RunLengthDecode def - /CCF /CCITTFaxDecode def - /DCT /DCTDecode def -currentdict end readonly def - -/GetColorSpaceRange -{ 2 index /ColorSpace get - dup type /arraytype eq { - 1 get - } if - exch //knownget exec { - exch pop - } if -} bind def - -/DecodeArrays 15 dict begin - /DeviceGray { [0 1] } def - /DeviceRGB { [0 1 0 1 0 1] } def - /DeviceCMYK { [0 1 0 1 0 1 0 1] } def - /Indexed { - dup /BitsPerComponent get 1 exch bitshift 1 sub [exch 0 exch] - } def - /Separation { [0 1] } def - /CIEBasedA { [0 1] /RangeA //GetColorSpaceRange exec } def - /CIEBasedABC { [0 1 0 1 0 1] /RangeABC //GetColorSpaceRange exec } def -currentdict end readonly def - -/Substitute % Substitute -{ 1 index //knownget exec { - exch pop - } if -} bind def - -/DebugImagePrinting % DebugImagePrinting -{ - //PDFR_DEBUG { - (Image :) = - dup { exch //=only exec ( ) print == - } forall - } if -} bind def - -/CompleteImage % CompleteImage -{ - dup /ColorSpace known { - dup /ColorSpace //CheckColorSpace //ResolveD exec pop - } if - dup /Decode known not { - dup /ColorSpace //knownget exec { - dup type /arraytype eq { - 0 get - } if - //DecodeArrays exch get exec - } { - [0 1] - } ifelse - 1 index exch /Decode exch put - } if - dup /ImageMatrix [2 index /Width get 0 0 5 index /Height get neg - 0 7 index /Height get] put % Not sure why upside down ? - //DebugImagePrinting exec -} bind def - -/CompleteInlineImage % CompleteInlineImage -{ - //PDFR_DEBUG { - (CompleteInlineImage beg) = - } if - dup /ImageType known not { - dup /ImageType 1 put - } if - dup length dict exch { % d key val - exch //ImageKeys //Substitute exec - dup /Filter eq { - exch //ImageValues //Substitute exec exch - } if - dup /ColorSpace eq { - exch - dup //ImageValues exch //knownget exec { - exch pop - } { - //ResolveColorSpace exec - } ifelse - exch - } if - exch - 2 index 3 1 roll put - } forall - //CompleteImage exec - dup /DataSource 2 copy get % d d /n f - 2 index //AppendFilters exec put - //PDFR_DEBUG { - (CompleteInlineImage end) = - } if -} bind def - -/CompleteOutlineImage % CompleteOutlineImage -{ - currentglobal exch dup gcheck setglobal - //PDFR_DEBUG { - (CompleteOutlineImage beg) = - } if - % todo: ResetStreamReader if DataSource already exists. - dup dup //MakeStreamReader exec /DataSource exch put - dup /ImageType known not { - //CompleteImage exec - dup /ImageType 1 put - dup /ColorSpace known { - dup /ColorSpace //CheckColorSpace //ResolveD exec - dup type /arraytype eq { - //ResolveColorSpaceArray exec - //SubstitutePDFColorSpace exec - 1 index exch /ColorSpace exch put - } { - pop - } ifelse - } if - } if - //PDFR_DEBUG { - (CompleteOutlineImage end) = - } if - exch setglobal -} bind def - -/DoImage % DoImage - -{ - //PDFR_DEBUG { - (DoImage beg) = - } if - gsave - dup /ColorSpace //knownget exec { setcolorspace } if - dup /ImageMask //knownget exec not { false } if - { imagemask } { image } ifelse - grestore - //PDFR_DEBUG { - (DoImage end) = - } if -} bind def - -% ===================== Viewer State =============== - -/GSave % - GSave - -{ - gsave - //PDFReader /GraphicStateStackPointer get - dup //GraphicStateStack exch get null eq { - dup //GraphicStateStack exch //InitialGraphicState length dict put - } if - dup //GraphicStateStack exch get - //GraphicState exch copy pop - 1 add //PDFReader exch /GraphicStateStackPointer exch put -} bind def - -/GRestore % - GRestore - -{ - grestore - //PDFReader /GraphicStateStackPointer get - 1 sub dup - //PDFReader exch /GraphicStateStackPointer exch put - //GraphicStateStack exch get - //GraphicState copy pop -} bind def - - -% ===================== Interpret Data Streams =============== - -/SetFont % SetFont - -{ dup //GraphicState exch /FontSize exch put - //ResolveAndSetFont exec - //GraphicState /FontMatrixNonHV currentfont /FontMatrix get 1 get 0 ne put -} bind def - -/ShowText % ShowText - -{ //GraphicState /TextRenderingMode get 0 eq { - //GraphicState /WordSpacing get 0 - 32 - //GraphicState /CharacterSpacing get 0 - 6 5 roll - //GraphicState /FontMatrixNonHV get { - % Use xshow to force wy in text space to be 0 (PDF1.7 5.3.3 "Text Space Details") - %stack: wordspacing_wx wordspacing_wy space_char charspacing_wx charspacing_wy string - [ % wwx wwy sp cwx cwy str [ - 7 -2 roll pop % sp cwx cwy str [ ww - 5 -2 roll pop % sp str [ ww cw - 5 -1 roll % str [ ww cw sp - { % str [ ... ww cw sp c wx wy - exch % will be removed, unless FontMatrix.xx == 0 (FontMatrixNonHV already true) - pop % str [ ... ww cw sp c w - 3 index add % str [ ... ww cw sp c w+cw - exch 2 index eq { 3 index add } if % str [ ... ww cw sp w+cw[+ww] - 4 1 roll % str [ ... w+cw[+ww] ww cw sp - } - currentfont /FontMatrix get 0 get 0 ne { - 1 1 index length 1 sub getinterval cvx % drop the "exch" - } if - 5 index % str [ ww cw sp {cshowproc} str - cshow % str [ widths... ww cw sp - pop pop pop ] % str [widths...] - xshow - } { - awidthshow - } ifelse - } { - //GraphicState /CharacterSpacing get 0 eq - //GraphicState /FontMatrixNonHV get not and - //GraphicState /WordSpacing get 0 eq and { - true charpath - } { - % Emulate with "{ charpath } cshow". - % Not sure how it works with CID fonts. - { % c wx wy - exch % will be removed, unless FontMatrixNonHV && FontMatrix.xx == 0 - pop 0 % (PDF1.7 5.3.3 "Text Space Details") - currentpoint 5 4 roll % wx wy x y c - ( ) dup 0 3 index put true charpath % wx wy x y c - 5 1 roll % c wx wy x y - moveto rmoveto % c - //GraphicState /CharacterSpacing get 0 rmoveto % c - 32 eq { % - //GraphicState /WordSpacing get 0 rmoveto - } if - } - //GraphicState /FontMatrixNonHV get dup not exch { - pop currentfont /FontMatrix get 0 get 0 ne - } if { - 1 1 index length 1 sub getinterval cvx - } if - exch cshow - } ifelse - } ifelse -} bind def - -/ShowTextBeg % - ShowTextBeg - -{ //GraphicState /TextRenderingMode get 0 ne { - currentpoint newpath moveto - } if -} bind def - -/ShowTextEnd % - ShowTextEnd - -{ //GraphicState /TextRenderingMode get - { dup 1 eq { - stroke exit - } if - dup 2 eq { - gsave fill grestore stroke exit - } if - dup 3 eq { - currentpoint newpath moveto - } if - dup 4 eq { - gsave fill grestore clip exit - } if - dup 5 eq { - gsave stroke grestore clip exit - } if - dup 6 eq { - gsave fill grestore gsave stroke grestore fill exit - } if - dup 7 eq { - clip exit - } if - exit - } loop - pop -} bind def - -/ShowTextWithGlyphPositioning % ShowTextWithGlyphPositioning - -{ //ShowTextBeg exec - { dup type /stringtype eq { - //ShowText exec - } { - neg 1000 div //GraphicState /FontSize get mul 0 rmoveto - } ifelse - } forall - //ShowTextEnd exec -} bind def - -/CheckFont % key val CheckFont key val -{ dup /Type get /ExtGState ne { - mark (Resource ) 3 index ( must have /Type/ExtGState.) //error exec - } if -} bind def - -/SetTransfer % SetTransfer - -{ - //PDFR_DEBUG { (SetTransfer beg ) print count = } if - dup type /arraytype eq 1 index xcheck not and { - 0 4 getinterval aload pop - setcolortransfer - } { - settransfer - } ifelse - //PDFR_DEBUG { (SetTransfer end ) print count = } if -} bind def - -/CheckExtGState % CheckExtGState -{ dup /Type get /ExtGState ne { - mark (Resource ) 3 index ( must have /Type/ExtGState.) //error exec - } if -} bind def - -/CheckHalftone % CheckHalftone -{ dup /HalftoneType known not { - mark (Resource ) 3 index ( must have /HalftoneType.) //error exec - } if -} bind def - -/ResolveFunction % ResolveFunction -{ - //PDFR_DEBUG { (ResolveFunction beg ) print dup = count = } if - 2 copy get //IsObjRef exec { - 2 copy //DoNothing //ResolveD exec - 3 copy put pop - } if - 2 copy get dup type /arraytype eq exch xcheck and not { - 2 copy get - dup type /arraytype eq 1 index xcheck not and { - dup length 1 sub -1 0 { - 2 copy //DoNothing ResolveA - dup /Identity eq { - pop 2 copy {} put - } { - //FunctionToProc exec - 3 copy put pop - } ifelse - pop - } for - } { - dup /Default eq { - % Leave it. ExtGState methods will resolve. - } { - dup /Identity eq { - pop {} - } { dup type /nametype eq { - //spotfunctions exch get - } { - //FunctionToProc exec - } ifelse - } ifelse - } ifelse - } ifelse - 3 copy put - exch pop - } { - 1 index exch get - } ifelse - //PDFR_DEBUG { (ResolveFunction end ) print dup == count = } if -} bind def - -/ResolveFunctionSafe % ResolveFunctionSafe -{ 2 copy known { - //ResolveFunction exec - } if - pop -} bind def - -/CreateHalftoneThresholds % CreateHalftoneThresholds -{ - dup /Thresholds known not { - dup /HalftoneType get 10 eq { - dup dup //MakeStreamReader exec - /Thresholds exch put - } if - dup /HalftoneType get dup 3 eq exch 6 eq or { - dup dup //MakeStreamReader exec - //BlockBuffer readstring pop - dup length - dup 0 eq { - mark (Could not read Thresholds) //error exec - } if - string copy /Thresholds exch put - dup /HalftoneType 3 put % replace Type 6 with Type 3. - } if - } if -} bind def - - -/SetExtGState % SetExtGState - -{ - //PDFReader /CurrentObject get /Context get /Resources get - /ExtGState //DoNothing //ResolveD exec - exch //CheckExtGState //ResolveD exec % s gs - dup /LW //knownget exec { - setlinewidth - } if - dup /LC //knownget exec { - setlinecap - } if - dup /LJ //knownget exec { - setlinejoin - } if - dup /ML //knownget exec { - setmeterlimit - } if - dup /D //knownget exec { - setdash - } if - dup /RI //knownget exec { - % Ghostscript never writes it. - mark (Unimplemented ExtGState.RI) //error exec - } if - dup /OP //knownget exec { - % pdfwrite must take care of stroking/filling - setoverprint - } if - dup /op //knownget exec { - setoverprint - } if - dup /OPM //knownget exec { - % pdfwrite must take care of. - mark (Unimplemented ExtGState.OPM) //error exec - } if - dup /Font //knownget exec { - % Ghostscript never writes it. - mark (Unimplemented ExtGState.Font) //error exec - } if - dup /BG known { - /BG //ResolveFunction exec - setblackgeneration - } if - dup /BG2 known { - /BG2 //ResolveFunction exec - dup /Default eq { - //InitialExtGState /BG2 get - } if - setblackgeneration - } if - dup /UCR known { - /UCR //ResolveFunction exec - setundercolorremoval - } if - dup /UCR2 known { - /UCR2 //ResolveFunction exec - dup /Default eq { - //InitialExtGState /UCR2 get - } if - setundercolorremoval - } if - dup /TR known { - /TR //ResolveFunction exec - //SetTransfer exec - } if - dup /TR2 known { - /TR2 //ResolveFunction exec - dup /Default eq { - pop //InitialExtGState /TR2 get - aload pop setcolortransfer - } { - //SetTransfer exec - } ifelse - } if - dup /HT //knownget exec { - dup /Default eq { - pop //InitialExtGState /HT get - sethalftone - } { - //PDFR_DEBUG { (Ht beg) = } if - pop dup /HT //CheckHalftone //ResolveD exec - /SpotFunction //ResolveFunctionSafe exec - /TransferFunction //ResolveFunctionSafe exec - null exch - dup /HalftoneType get dup 5 eq exch dup 4 eq exch 2 eq or or { - dup { % null h n v - dup //IsObjRef exec { - pop - 1 index exch //CheckHalftone ResolveD - } if - dup type /dicttype eq { - dup /SpotFunction //ResolveFunctionSafe exec - /TransferFunction //ResolveFunctionSafe exec - //CreateHalftoneThresholds exec - dup /HalftoneType get 5 gt { % null h n v - 4 3 roll pop - dup 4 1 roll - } if - } if - pop pop - } forall - } if - //CreateHalftoneThresholds exec - //PDFR_DEBUG { - (HT:)= - dup { - 1 index /Default eq { - (Default <<)= - exch pop - { exch = == } forall - (>>)= - } { - exch = == - } ifelse - } forall - (HT end)= flush - } if - exch dup null ne { - (Warning: Ignoring a halftone with a Level 3 component halftone Type ) print dup /HalftoneType get = - pop pop - } { - pop - dup /HalftoneType get 5 gt { - (Warning: Ignoring a Level 3 halftone Type ) print dup /HalftoneType get = - pop - } { - sethalftone - } ifelse - } ifelse - //PDFR_DEBUG { (HT set)= flush } if - } ifelse - } if - dup /FL //knownget exec { - setflattness - } if - dup /SM //knownget exec { - setsmoothness - } if - dup /SA //knownget exec { - setstrokeadjust - } if - dup /BM //knownget exec { - % pdfwrite must take care of. - mark (Unimplemented ExtGState.BM) //error exec - } if - dup /SMask //knownget exec { - % pdfwrite must take care of. - mark (Unimplemented ExtGState.SMask) //error exec - } if - dup /CA //knownget exec { - % pdfwrite must take care of. - mark (Unimplemented ExtGState.CA) //error exec - } if - dup /ca //knownget exec { - % pdfwrite must take care of. - mark (Unimplemented ExtGState.ca) //error exec - } if - dup /AIS //knownget exec { - % pdfwrite must take care of. - mark (Unimplemented ExtGState.AIS) //error exec - } if - dup /TK //knownget exec { - % pdfwrite must take care of. - mark (Unimplemented ExtGState.TK) //error exec - } if - pop -} bind def - -/CheckXObject % CheckHalftone -{ dup /Subtype get dup /Image ne exch dup /Form ne exch /PS ne and and { - mark (Resource ) 3 index ( must have /Subtype /Image or /Form or /PS.) //error exec - } if -} bind def - -/DoXObject % DoXObject - -{ - //PDFReader /CurrentObject get /Context get /Resources get - /XObject //DoNothing //ResolveD exec - exch //CheckXObject //ResolveD exec - dup /Subtype get - dup /Image eq { - pop - //CompleteOutlineImage exec - //DoImage exec - } { - dup /PS eq { - PDFR_DEBUG { - (Executing a PS Xobject) = - } if - pop - //RunDelayedStream exec - } { - dup /Form eq { - pop - PDFR_DEBUG { - (Executing a Form XObject) = - } if - //PDFReader /CurrentObject get exch - dup //PDFReader exch << exch /Context exch >> /CurrentObject exch put - dup /Matrix get concat - dup /BBox get aload pop exch 3 index sub exch 2 index sub rectclip - //RunDelayedStream exec - //PDFReader exch /CurrentObject exch put - } { - mark exch (unimplemented XObject type ) exch //error exec - } ifelse - } ifelse - } ifelse -} bind def - -/Operators 50 dict begin - /q { //GSave exec } bind def - /Q { //GRestore exec } bind def - /cm { //TempMatrix astore concat } bind def - /i { 1 .min setflat } bind def - /J /setlinecap load def - /d /setdash load def - /j /setlinejoin load def - /w /setlinewidth load def - /M /setmiterlimit load def - /gs { SetExtGState } bind def - - /g /setgray load def - /rg /setrgbcolor load def - /k /setcmykcolor load def - /cs { //ResolveColorSpace exec //SetColorSpaceSafe exec - } bind def - /sc /setcolor load def - /scn { //SetColor exec } bind def - /G /setgray load def - /RG /setrgbcolor load def - /K /setcmykcolor load def - /CS //cs def - /ri { SetColorRenderingIntent } bind def - /SC /setcolor load def - /SCN { //SetColor exec } bind def - - /m /moveto load def - /l /lineto load def - /c /curveto load def - /v { currentpoint 6 2 roll curveto } bind def - /y { 2 copy curveto } bind def - /re { - 4 2 roll moveto exch dup 0 rlineto 0 3 -1 roll rlineto neg 0 rlineto - closepath - } def - /h /closepath load def - /n /newpath load def - /S /stroke load def - /s { closepath stroke } bind def - /f /fill load def - /f* /eofill load def - /B { gsave fill grestore stroke } bind def - /b { closepath gsave fill grestore stroke } bind def - /B* { gsave eofill grestore stroke } bind def - /b* { closepath gsave eofill grestore stroke } bind def - /W /clip load def - /W* /eoclip load def - /sh { % Reserved for ps3write. - ResolveShading - dup /Background known { - gsave - dup /ColorSpace get setcolorspace - dup /Background get aload pop setcolor - pathbbox % x0 y0 x1 y1 - 2 index sub exch 3 index sub exch - rectfill - grestore - } if - shfill - } bind def - - /Do { //DoXObject exec } bind def - - /BI { currentglobal false setglobal << } bind def - /ID { >> - dup /DataSource currentfile - % HACK BEG - % This hack provides a compatibility to HP LaserJet 1320, - % which sometimes closes the underlying stream when EOD - % is reached in the ASCII85Decode filter. - % This portion is not required by the Postscript language definition. - 2 index /F //knownget exec { - /A85 eq { - 0 (~>) /SubFileDecode filter - } if - } if - % HACK END - put - //CompleteInlineImage exec - exch setglobal - //DoImage exec - } bind def - /EI {} bind def - - /BT { gsave //GraphicState /InitialTextMatrix get currentmatrix pop } bind def - /ET { grestore } bind def - /Tc { //GraphicState exch /CharacterSpacing exch put } bind def - /TL { //GraphicState exch /TextLeading exch put } bind def - /Tr { //GraphicState exch /TextRenderingMode exch put } bind def - /Ts { % Ghostscript never generates it. - mark (Unimplemented SetTextRise) //error exec - } bind def - /Tw { //GraphicState exch /WordSpacing exch put } bind def - /Tz { % Ghostscript never generates it. - mark (Unimplemented SetHorizontalTextScaling) //error exec - } bind def - /Td { translate 0 0 moveto } bind def - /TD { dup neg //TL exec //Td exec } bind def - /Tm { //GraphicState /InitialTextMatrix get setmatrix - //TempMatrix astore concat - 0 0 moveto } bind def - /T* { 0 //GraphicState /TextLeading get neg //Td exec } bind def - /Tj { //ShowTextBeg exec //ShowText exec //ShowTextEnd exec } bind def - /' { //T* exec //ShowText exec //ShowTextEnd exec } bind def - /" { 3 2 roll //Tw exec exch //Tc exec //' exec} bind def - /TJ //ShowTextWithGlyphPositioning def - /Tf //SetFont def - - /d0 /setcharwidth load def - /d1 /setcachedevice load def - - /BDC { pop pop } bind def - /BMC { pop } bind def - /EMC { } bind def - /BX { BeginCompatibilitySection } bind def - /EX { EndCompatibilitySection } bind def - /DP { DefineMarkedContentPointWithPropertyList } bind def - /MP { DefineMarkedContentPoint } bind def - /PS { cvx exec } bind def -currentdict end def - -//PDFR_STREAM { - % Rebind operators with a debug tracing. - //Operators length dict begin - //Operators { % n p - exch dup % p n n - [ exch //=only /exec load % p n [ n =only exec - ( ) /print load % p n [ n =only exec () print - 8 7 roll % n [ n =only exec () print p - dup type /arraytype eq { - /exec load % n [ n =only exec () print p exec - } if - ( ) /print load - ] cvx % n {} - def - } forall - currentdict end /Operators exch def -} if - -% Functions for handling Ghostscript library files that define encodings. - -/.registerencoding -{ pop pop -} bind def - -/.defineencoding -{ def -} bind def - -/.findencoding -{ load -} bind def - - -% Leaving the procset on the dictionary stack to provide -% definitions of obj, endobj, stream, endstream, R, xref. -%%EndPrologue diff --git a/Master/tlpkg/tlgs/lib/pdfopt.ps b/Master/tlpkg/tlgs/lib/pdfopt.ps index 74cb91994db..88a8943f278 100644 --- a/Master/tlpkg/tlgs/lib/pdfopt.ps +++ b/Master/tlpkg/tlgs/lib/pdfopt.ps @@ -1,4 +1,5 @@ -% Copyright (C) 2000, 2001 Aladdin Enterprises. All rights reserved. +% Copyright (C) 2001-2012 Artifex Software, Inc. +% All Rights Reserved. % % This software is provided AS-IS with no warranty, either express or % implied. @@ -7,13 +8,11 @@ % modified or distributed except as expressly authorized under the terms % of the license contained in the file LICENSE in this distribution. % -% For more information about licensing, please refer to -% http://www.ghostscript.com/licensing/. For information on -% commercial licensing, go to http://www.artifex.com/licensing/ or -% contact Artifex Software, Inc., 101 Lucas Valley Road #110, -% San Rafael, CA 94903, U.S.A., +1(415)492-9861. +% Refer to licensing information at http://www.artifex.com or contact +% Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael, +% CA 94903, U.S.A., +1(415)492-9861, for further information. +% -% $Id$ % PDF linearizer ("optimizer"). .currentglobal true .setglobal @@ -1010,6 +1009,8 @@ userdict /clostreams 20 dict put % stream -> [data endproc] 40 dict begin /IDict exch def /OFile exch def + % Disable check for the max object number because pdfopt adds new objects. + /NumObjects 16#7fffffff store /starttime exch def /ToWrite 100 dict def /now { diff --git a/Master/tlpkg/tlgs/lib/stcinfo.ps b/Master/tlpkg/tlgs/lib/stcinfo.ps deleted file mode 100644 index d39b182d4fe..00000000000 --- a/Master/tlpkg/tlgs/lib/stcinfo.ps +++ /dev/null @@ -1,794 +0,0 @@ -% Copyright (C) 2001-2012 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., 7 Mt. Lassen Drive - Suite A-134, San Rafael, -% CA 94903, U.S.A., +1(415)492-9861, for further information. -% - -% stcinfo.ps -% Epson Stylus-Color Printer-Driver - -% The purpose of this file is to print & show Parameters of the -% stcolor-driver. If not run on ghostscript/stcolor, it prints -% something like a color-chart. - -% use either existing STCinfo-dictionary, retrieve new one or create dummy - -statusdict begin product end -dup (Ghostscript) eq 1 index (Artifex Ghostscript) eq or -exch (AFPL Ghostscript) eq or{ - - currentdevice getdeviceprops .dicttomark - dup /Name get (stcolor) eq /STCi_onstc exch def - /STCinfo where {/STCinfo get exch pop} if - /STCinfo exch def - -}{ - - /STCinfo 10 dict def - STCinfo begin /Name (unknown) def end - /STCi_onstc false def - -}ifelse - -% Next Block are procedures to generate the color-triangles. -% you may wish to separate them, just look ahead for the name -% given in the next line to achieve that. -% Begin: colortri_procedures - -% Plot the CIE-XY-triangle (or something like that) - -% /colortri_mat Conversion matrix RGB -> XYZ -% /colortri_bg procedure, that takes X/Y-Values and delivers the -% "background color" as RGB-Values, default is: -% {pop pop 0.85 dup dup} - -% The default matrix was taken from: -% Color spaces FAQ - David Bourgin -% Date: 15/6/94 (items 5.3 and 6 updated) -% Last update: 29/6/94 - - /colortri_mat [ % RGB -> CIE XYZitu601-1 (D65) - 0.4306 0.3415 0.1784 - 0.2220 0.7067 0.0713 - 0.0202 0.1295 0.9394 - ] def - - /colortri_bg {pop pop 0.85 dup dup} bind def - -% +---------------------------------------------------------------------+ -% | Besides from fixing bugs, nothing should be changed below this line | -% +---------------------------------------------------------------------+ - -% Arbitrary operation on a pair of vectors, *CHANGES* 1st. -% invoke: Vaccu Vop op vop - /vop { - bind 0 1 3 index length 1 sub { - 3 index 1 index get 3 index 2 index get 3 index exec 4 index 3 1 roll put - } for pop pop - } bind def - - /vsub { {sub} vop } bind def % subtract two vectors - /vmul { {mul} vop } bind def % multiply two vectors - -% Compute sum of vectors elements - /vsum {0.0 exch{add}forall} bind def - -% Sum up products of elements - /veqn { [ 3 -1 roll {} forall ] exch vmul vsum } bind def - -% Find index of |maximum| in array - /imax { - dup 0 get abs 0 exch % array i v[i] - 1 1 4 index length 1 sub { - 3 index 1 index get abs dup 3 index gt {4 2 roll}if pop pop - } for - 3 -1 roll pop - } bind def - -% Procedure to *CHANGE* RGB-Values into XYZ-Values - /rgb2xyz { - 0 3 6 { colortri_mat exch 3 getinterval 1 index veqn exch } for astore - } bind def - -% Procedure to *CHANGE* transform rgb->xy - /rgb2xy { - rgb2xyz - dup 0 get 1 index 1 get 2 index vsum % XYZ X Y sum - dup 0 ne { - exch 1 index div 3 1 roll div % XYZ y x - 2 index exch 0 exch put % xYZ y - 1 index exch 1 exch put % xyZ - }{ - pop pop pop dup 0 0 put dup 0 1 put - } ifelse - 0 2 getinterval - } bind def - -% So here we go with our procedure - -/colortri { %Usage: box #pixels - save - 1 index type /arraytype eq {exch 8}{3 1 roll} ifelse % Default scale - /colortri_scale exch def - /colortri_box exch def - -% Prepare some useful constants for xy -> RGB conversion - - /colsum [ % Array with column-sums - 0 1 2{0 exch 3 1 index 6 add{colortri_mat exch get add}for}for - ] def - - /Xrow colortri_mat 0 3 getinterval def % two rows from colortri_mat - /Yrow colortri_mat 3 3 getinterval def - -% Avoid allocating new arrays - /xcoeff 3 array def - /ycoeff 3 array def - -% Procedure to derive RGB-Values form X,Y - /xy2rgb{ aload pop - dup dup dup ycoeff astore colsum vmul Yrow vsub imax - 3 index dup dup xcoeff astore colsum vmul Xrow vsub imax - 3 -1 roll 1 index 1 index gt{ - xcoeff ycoeff /xcoeff exch def /ycoeff exch def pop 3 -1 roll pop - }{ - 3 1 roll pop pop - } ifelse - 1e-6 lt { % No Pivot ? - pop colortri_bg xcoeff astore pop - }{ % Have a Pivot - dup ycoeff exch get neg - 0 1 2 { dup ycoeff exch get 2 index div ycoeff 3 1 roll put} for - pop ycoeff 1 index 0 put - - xcoeff 1 index get - 0 1 2 { - ycoeff 1 index get 2 index mul xcoeff 2 index get add - xcoeff 3 1 roll put - } for - pop xcoeff 1 index 0 put - xcoeff imax 1e-6 lt { % no Pivot ? - pop pop colortri_bg xcoeff astore pop - }{ - dup 2 index or 3 exch sub - xcoeff 1 index get xcoeff 3 index get div neg - xcoeff exch 3 index exch put - xcoeff 1 index 1 put - ycoeff exch get ycoeff 2 index get xcoeff 4 -1 roll get mul add - xcoeff 3 1 roll put - 0 1 2 { - xcoeff exch get dup -0.0015 lt exch 1.0015 gt or { - colortri_bg xcoeff astore dup exit - } if - } for - pop pop xcoeff - } ifelse - } ifelse - } bind def - -% Compute the displayed range - [ 1 1 1 ] rgb2xy - dup 0 get /colortri_x0 exch def /colortri_dx colortri_x0 def - 1 get /colortri_y0 exch def /colortri_dy colortri_y0 def - [[0 0 1][0 1 0][0 1 1][1 0 0][1 0 1][1 1 0]] { - rgb2xy - dup 0 get - dup colortri_x0 lt {/colortri_x0 1 index def}if - dup colortri_dx gt {/colortri_dx 1 index def}if - pop 1 get - dup colortri_y0 lt {/colortri_y0 1 index def}if - dup colortri_dy gt {/colortri_dy 1 index def}if - pop - } forall - colortri_dx colortri_x0 sub /colortri_dx exch def - colortri_dy colortri_y0 sub /colortri_dy exch def -% - -% determine the scale - colortri_box 2 get colortri_box 0 get sub colortri_dx div % fx - colortri_box 3 get colortri_box 1 get sub colortri_dy div % fx fy - gt { % fy limits - colortri_box 3 get colortri_box 1 get sub - dup colortri_dx mul colortri_dy div exch - }{ % fx limits - colortri_box 2 get colortri_box 0 get sub - dup colortri_dy mul colortri_dx div - } ifelse - dtransform abs colortri_scale div cvi /colortri_ny exch def - abs colortri_scale div cvi /colortri_nx exch def - colortri_nx colortri_scale mul colortri_ny colortri_scale mul - idtransform abs exch abs exch - colortri_box 0 get colortri_box 2 get 1 index sub 3 index sub 2 div add - colortri_box 1 get colortri_box 3 get 1 index sub 3 index sub 2 div add - transform .5 add cvi exch .5 add cvi exch itransform - translate scale - -% String & indices - /colortri_tmp colortri_nx 3 mul string def - /colortri_dx colortri_dx colortri_nx 1 sub div def - /colortri_dy colortri_dy colortri_ny 1 sub div def - /colortri_xy [ colortri_x0 colortri_y0 ] def - /colortri_ie colortri_tmp length 3 sub def - - colortri_nx colortri_ny 8 [ colortri_nx 0 0 colortri_ny 0 0 ] - { - colortri_xy 0 colortri_x0 put - 0 3 colortri_ie { - colortri_tmp exch % buf ir - colortri_xy xy2rgb % buf ir rgb buf ib - 2 index 2 index 2 add 2 index 2 get 255 mul cvi put - 2 index 2 index 1 add 2 index 1 get 255 mul cvi put - 0 get 255 mul cvi put - colortri_xy dup 0 exch 0 get colortri_dx add put - }for - colortri_xy dup 1 exch 1 get colortri_dy add put - colortri_tmp - } bind - false 3 colorimage - restore -} bind def - -% [ newpath clippath pathbbox ] colortri showpage % standalone usage - -% End: colortri_procedures - -% The next section is a group of procedures, that I for myself -% do no more fully understand, but they do the Job. - -% Begin: stcinfo_procedures_1 - -% fetch a parameter from the dictionary -/STCiget { STCinfo exch get } bind def - -% action upon ProcessColorModel -/STCimode { - /ProcessColorModel STCiget dup - /DeviceCMYK eq{pop 2}{/DeviceRGB eq{1}{0}ifelse}ifelse get exec -} bind def - -% print given number of blanks -/STCipspace { - dup 0 gt{ 1 exch 1 exch { pop ( ) print}for }{ pop } ifelse -} bind def - -% print right or left-justified text -/STCiprint { - dup 0 gt { dup 2 index length sub STCipspace } if - 1 index print - dup 0 lt { neg dup 2 index length sub STCipspace } if - pop pop -} bind def - -% floating-point to fixed-length-string conversion - -/STCicvs { % number -> string - -% Prepare the result - 8 string dup 0 ( ) putinterval - exch - -% Make it unsigned - dup 0 lt {neg(-)}{( )}ifelse 0 get exch - - dup 1000 lt 1 index 0 eq 2 index 0.001 ge or and { % floating point - (e+) 0 - }{ % engineering - 0 { - 1 index 1000.0 ge - {3 add exch 1000 div exch} - {1 index 1 lt {3 sub exch 1000 mul exch}{exit}ifelse} - ifelse - }loop - dup 0 lt {neg(e-)}{(e+)}ifelse exch - }ifelse - -% string sign num esig e - -% always up to three Integer Digits plus sign - 2 index cvi 3 { % string sign num esig e int ind - 1 index 10 div cvi dup 10 mul 3 index exch sub cvi - (0123456789) exch get 8 index exch 3 index exch put - 3 -2 roll 1 sub exch pop dup 0 eq 2 index 0 eq or {exit} if - } loop exch pop % string sign num esig e ind - 5 index exch 6 -1 roll put % string num esig e - -% print either fraction or exponent - dup 0 eq { pop pop dup cvi sub % String fraction - - dup 0.0 ne { % Fraction present - 0.0005 add 1 index 4 (.) putinterval - 5 1 7 { % string frac ind - exch 10 mul dup cvi exch 1 index sub % string ind ic nfrac - exch (0123456789) exch get 3 -1 roll % string nfrac chr ind - exch 3 index 3 1 roll put - } for - } if - pop - - }{ 3 -1 roll pop % string esig e - - exch 2 index exch 4 exch putinterval - 7 -1 6 { % string n i - 1 index 10 div cvi dup 10 mul 3 index exch sub cvi % string n i n/10 - (0123456789) exch get 4 index exch 3 index exch put - exch pop exch pop - } for - pop - } ifelse - -} bind def - -% compute colorvalue-steps from transfer & coding -/STCisteps { % xfer, coding => X-values, Y-Values -% 2^nbits - 2 /BitsPerComponent STCiget dup 11 gt { pop 11 } if exp cvi - -% X & Y - Arrays (stack: xv:4 yv:3 xfer:2 coding:1 2^ni:0) - dup 1 add array 1 index array 5 2 roll - -% compute GS-Color-Value according to the coding-array - - 1 index null eq { % no coding present - - 0 1 2 index 1 sub { - dup 6 index exch dup 4 index div put - 4 index exch dup 3 index 1 sub div put - } for - - }{ % coding-array given - - 1.0 1 index 1 sub div % y step - 0 % current index - 0 1 4 index 1 sub { % over indices - dup 3 index mul - { - dup 3 index 1 add dup 8 index length ge {pop pop exit} if % i y - 7 index exch get le {exit} if - 2 index 1 add 3 1 roll 4 -1 roll pop - } loop - 5 index 3 index get sub - 5 index 3 index 1 add get 6 index 4 index get sub div - 2 index add 5 index length 1 sub div - 2 copy exch dup 0 eq { - 10 index exch 0.0 put pop - }{ - dup 10 index exch 1 sub get 3 -1 roll add 2 div - 10 index 3 1 roll put - }ifelse - 7 index 3 1 roll put - } for % over indices - pop pop - } ifelse - 4 index 1 index 1.0 put - -% Replace the raw y-values by those computed from the transfer-array - - 0 1 2 index 1 sub { % over indices, 2nd - dup 5 index exch get - dup 5 index length 1 sub mul cvi % -> iy - 5 index 1 index get - 1 index 1 add 7 index length lt { - dup 7 index 3 index 1 add get exch sub - 3 index 3 index 9 index length 1 sub div sub mul - 7 index length 1 sub mul add - } if - exch pop exch pop 5 index 3 1 roll put - } for % over indices, 2nd - - pop pop pop -} bind def - -/STCibar { % Window X-Values proc => Window - 0 1 3 index length 2 sub { - dup 3 index exch get exch - 1 add 3 index exch get - dup 2 index add 2 div 3 index exec % Color to average - 4 index 2 get 5 index 0 get sub exch 1 index mul 5 index 0 get add 3 1 roll - mul 4 index 0 get add 4 index 3 get 5 index 1 get - newpath - 2 index 1 index moveto - 3 index 1 index lineto - 3 index 2 index lineto - 2 index 2 index lineto - closepath fill - pop pop pop pop - } for - pop pop - 0 setgray - newpath - dup 0 get 1 index 1 get moveto - dup 2 get 1 index 1 get lineto - dup 2 get 1 index 3 get lineto - dup 0 get 1 index 3 get lineto - closepath stroke - pop -} bind def - -% End: stcinfo_procedures_1 - -% Begin: stcinfo_preparation - -% Compute used area from clippath - -/STCi_clip [ - newpath clippath pathbbox - 2 sub 4 1 roll 2 sub 4 1 roll 2 add 4 1 roll 2 add 4 1 roll -] def - -% -% Perpare the texual messages, assume no stcolor if this fails -% -{ - /STCi_stopped % A Special Mark - -% Textual Parameters (an array of pairs of strings) - /STCi_l1 0 def - /STCi_l2 0 def - /STCi_text [ -% Driver-Name & Version - (Parameters of) - /Name STCiget length /Version STCiget length add 1 add string - dup 0 /Name STCiget putinterval dup /Name STCiget length (-)putinterval - dup /Name STCiget length 1 add /Version STCiget putinterval -% Dithering-Algorithm - (Dithering) - /Dithering STCiget - [{( \(Monochrome\))}{( \(RGB\))}{( \(CMYK\))}] STCimode - dup length 2 index length add string exch 1 index exch - 3 index length exch putinterval dup 3 1 roll exch 0 exch putinterval -% Flags for the algorithm - (Flag4-0) 5 string - dup 0 /Flag4 STCiget {(T)}{(f)} ifelse putinterval - dup 1 /Flag3 STCiget {(T)}{(f)} ifelse putinterval - dup 2 /Flag2 STCiget {(T)}{(f)} ifelse putinterval - dup 3 /Flag1 STCiget {(T)}{(f)} ifelse putinterval - dup 4 /Flag0 STCiget {(T)}{(f)} ifelse putinterval - -% Bits Per Pixel & Bits Per Component - (BitsPerPixel) 10 string % (nn -> nxnn) - /BitsPerPixel STCiget 1 index cvs length % string used - dup 2 index exch ( -> ) putinterval 4 add dup 2 add exch 2 index exch - [{(1x)}{(3x)}{(4x)}] STCimode putinterval % String used - /BitsPerComponent STCiget 2 index 2 index 2 getinterval cvs length add - 0 exch getinterval - - () () -% ColorAdjustMatrix - (ColorAdjustMatrix) - /ColorAdjustMatrix STCiget dup null eq { - pop (default) - }{ - { STCicvs } forall - [{ % Monochrome - 26 string - dup 0 6 -1 roll putinterval dup 8 ( ) putinterval - dup 9 5 -1 roll putinterval dup 17 ( ) putinterval - dup 18 4 -1 roll putinterval - }{ % RGB - 26 string - dup 0 12 -1 roll putinterval dup 8 ( ) putinterval - dup 9 11 -1 roll putinterval dup 17 ( ) putinterval - dup 18 10 -1 roll putinterval - - () 26 string - dup 0 11 -1 roll putinterval dup 8 ( ) putinterval - dup 9 10 -1 roll putinterval dup 17 ( ) putinterval - dup 18 9 -1 roll putinterval - - () 26 string - dup 0 10 -1 roll putinterval dup 8 ( ) putinterval - dup 9 9 -1 roll putinterval dup 17 ( ) putinterval - dup 18 8 -1 roll putinterval - }{ - 35 string - dup 0 19 -1 roll putinterval dup 8 ( ) putinterval - dup 9 18 -1 roll putinterval dup 17 ( ) putinterval - dup 18 17 -1 roll putinterval dup 26 ( ) putinterval - dup 27 16 -1 roll putinterval - - () 35 string - dup 0 17 -1 roll putinterval dup 8 ( ) putinterval - dup 9 16 -1 roll putinterval dup 17 ( ) putinterval - dup 18 15 -1 roll putinterval dup 26 ( ) putinterval - dup 27 14 -1 roll putinterval - - () 35 string - dup 0 15 -1 roll putinterval dup 8 ( ) putinterval - dup 9 14 -1 roll putinterval dup 17 ( ) putinterval - dup 18 13 -1 roll putinterval dup 26 ( ) putinterval - dup 27 12 -1 roll putinterval - - () 35 string - dup 0 13 -1 roll putinterval dup 8 ( ) putinterval - dup 9 12 -1 roll putinterval dup 17 ( ) putinterval - dup 18 11 -1 roll putinterval dup 26 ( ) putinterval - dup 27 10 -1 roll putinterval - - } - ] STCimode - } ifelse - () () - -% Printer Model - (Printer-Model) /Model STCiget - -% Resolution - (Resolution) 15 string % (nnnnnxnnnnn DpI) - /HWResolution STCiget 0 get cvi 1 index cvs length - dup 2 index exch (x) putinterval 1 add dup 2 index exch 5 getinterval - /HWResolution STCiget 1 get cvi exch cvs length add dup 2 index - exch ( DpI) putinterval 4 add 0 exch getinterval - -% HWsize holds entire Page in Pixels, -% .HWMargins is [left,bottom,right,top] in Points - (Printed Area) 18 string % (nnnnnxnnnnn Pixel) - /HWSize STCiget 0 get /.HWMargins STCiget dup 0 get exch 2 get add - /HWResolution STCiget 0 get mul 72.0 div sub cvi 1 index cvs length - dup 2 index exch (x) putinterval 1 add dup 2 index exch 5 getinterval - /HWSize STCiget 1 get /.HWMargins STCiget dup 1 get exch 3 get add - /HWResolution STCiget 1 get mul 72.0 div sub cvi exch cvs length add - dup 2 index exch ( Pixel) putinterval 6 add 0 exch getinterval - - () () -% WeaveMode - (Weave-Mode) - /noWeave STCiget { - (noWeave) - }{ - /Microweave STCiget {(Microweave)}{(Softweave)}ifelse - }ifelse -% Unidirectional - (Unidirectional) /Unidirectional STCiget {(ON)}{(off)} ifelse -% Output coding - (OutputCode) /OutputCode STCiget -% number of heads - (escp_Band) /escp_Band STCiget 3 string cvs - (escp_Width) /escp_Width STCiget 5 string cvs - (escp_Height) /escp_Height STCiget 5 string cvs - (escp_Top) /escp_Top STCiget 5 string cvs - (escp_Bottom) /escp_Bottom STCiget 5 string cvs - ] def - -% -% compute the Proper X & Y-Arrays -% - [{ % Monochrome - /Ktransfer STCiget /Kcoding STCiget STCisteps - /STCi_yv [ 3 -1 roll ] def - /STCi_xv [ 3 -1 roll ] def - /STCi_col [[0 0 0]] def - /STCi_set [{1.0 exch sub setgray}] def - }{ % RGB - /Rtransfer STCiget /Rcoding STCiget STCisteps - /Gtransfer STCiget /Gcoding STCiget STCisteps - /Btransfer STCiget /Bcoding STCiget STCisteps - exch 4 -1 roll 6 -1 roll exch 3 -1 roll - /STCi_xv [ 5 2 roll ] def - /STCi_yv [ 5 2 roll ] def - /STCi_col [[1 0 0] [0 1 0] [0 0 1]] def - /STCi_set [ - {1.0 exch sub 1 exch dup setrgbcolor} - {1.0 exch sub dup 1 exch setrgbcolor} - {1.0 exch sub dup 1 setrgbcolor} - ] def - }{ % CMYK - /Ctransfer STCiget /Ccoding STCiget STCisteps - /Mtransfer STCiget /Mcoding STCiget STCisteps exch 3 1 roll - /Ytransfer STCiget /Ycoding STCiget STCisteps exch 4 1 roll - /Ktransfer STCiget /Kcoding STCiget STCisteps exch 5 1 roll - /STCi_yv [ 6 2 roll ] def - /STCi_xv [ 6 2 roll ] def - /STCi_col [[0 1 1] [1 0 1] [1.0 0.5 0.0] [0 0 0]] def - /STCi_set [ - { 0 0 0 setcmykcolor } - { 0 exch 0 0 setcmykcolor } - { 0 exch 0 exch 0 setcmykcolor } - { 0 exch 0 exch 0 exch setcmykcolor } - ] def - } - ]STCimode - -} stopped - -{ {/STCi_stopped eq {exit}if}loop true} -{ {/STCi_stopped eq {exit}if}loop false} ifelse - -% End: stcinfo_preparation - -% The Next section does the real job - -% Begin: stcinfo_execution -{ - (%%[ stcinfo.ps: currentdevice is not supported -> colortri ]%%\n) print - STCi_clip colortri % The default action - -}{ -% -% Print the text -% - 0 2 STCi_text length 2 sub { dup 1 add exch - STCi_text exch get length dup STCi_l1 gt{/STCi_l1 exch def}{pop}ifelse - STCi_text exch get length dup STCi_l2 gt{/STCi_l2 exch def}{pop}ifelse - } for - /STCi_l2 STCi_l2 neg def - 0 2 STCi_text length 2 sub { - dup 1 add STCi_text exch get exch STCi_text exch get - 1 index length 0 gt { - dup STCi_l1 STCiprint length 0 gt {(: )}{( )}ifelse print print - }{ - pop pop - } ifelse - (\n) print - } for -% -% Deactivate a present ColorAdjust Matrix, if any -% - /ColorAdjustMatrix STCiget null ne STCi_onstc and { - mark - /ColorAdjustMatrix null - currentdevice putdeviceprops pop - } if -% -% "Show" the text -% - /Times-Roman findfont 10 scalefont setfont - /STCi_l1 0 def - 0 2 STCi_text length 2 sub { - STCi_text exch get stringwidth pop dup STCi_l1 gt { - /STCi_l1 exch def - }{ - pop - } ifelse - } for - STCi_l1 STCi_clip 0 get add /STCi_l1 exch def - - STCi_clip 3 get 12 sub - 0 2 STCi_text length 2 sub { - STCi_text exch get dup length 0 gt { - dup stringwidth pop STCi_l1 exch sub 2 index moveto show - }{ - pop - } ifelse - 12 sub - } for - pop - - /Courier findfont 10 scalefont setfont - /STCi_l2 0 def - 1 2 STCi_text length 1 sub { - STCi_text exch get stringwidth pop dup STCi_l2 gt { - /STCi_l2 exch def - }{ - pop - } ifelse - } for - - STCi_clip 3 get 12 sub - 1 2 STCi_text length 1 sub { - STCi_text exch get dup length 0 gt { - STCi_l1 12 add 2 index moveto show - }{ - pop - } ifelse - 12 sub - } for - pop - -% -% compute the space for the graph-window -% - STCi_l1 12 add STCi_l2 add 12 add dup STCi_clip 2 get exch sub % Extend - [ 3 -1 roll dup 3 index add STCi_clip 3 get dup 5 index sub 3 1 roll ] - /STCi_win exch def /STCi_l1 exch def - -% The "Axis" - newpath - STCi_win 0 get STCi_win 1 get 14 add moveto - STCi_win 2 get STCi_win 1 get 14 add lineto stroke - - STCi_win 0 get 14 add STCi_win 1 get moveto - STCi_win 0 get 14 add STCi_win 3 get lineto stroke - -% The Labels - /Times-Roman findfont 10 scalefont setfont - (Postscript-color) dup stringwidth pop - STCi_win 2 get STCi_win 0 get sub 14 sub 1 index sub 2 div exch pop - STCi_win 0 get add 14 add STCi_win 1 get 4 add moveto show - - gsave - STCi_win 0 get 10 add STCi_win 1 get 14 add translate 90 rotate - (Device-color) dup stringwidth pop - STCi_win 3 get STCi_win 1 get sub 14 sub 1 index sub 2 div exch pop - 0 moveto show - grestore - -% The Graphs - gsave - STCi_win 0 get 14 add STCi_win 1 get 14 add - STCi_win 2 get 2 index sub STCi_win 3 get 2 index sub - 4 2 roll translate - STCi_col 0 1 2 index length 1 sub { - 1 index 1 index get aload pop setrgbcolor - STCi_xv 1 index get STCi_yv 3 -1 roll get - newpath - 1 index 0 get 5 index mul 1 index 0 get 5 index mul moveto - 1 index 1 get 5 index mul 1 index 0 get 5 index mul lineto - 1 1 2 index length 1 sub { - 2 index 1 index get 6 index mul - 2 index 2 index get 6 index mul lineto - 2 index 1 index 1 add get 6 index mul - 2 index 2 index get 6 index mul lineto - pop - } for - stroke pop pop - } for - pop pop pop - grestore - -% -% Find lowest Y from Text or graph -% - STCi_win 1 get STCi_clip 3 get STCi_text length 2 div 12 mul sub - dup 2 index gt { pop } { exch pop } ifelse 12 sub - -% -% compute the upper bar-window -% - /STCi_win [ - STCi_clip 0 get 4 -1 roll 36 sub STCi_clip 2 get 1 index 36 add - ] def - -% -% Draw the required number of graphs -% - [{ % Monochrome - STCi_win STCi_xv 0 get {setgray} STCibar - }{ % RGB - STCi_win STCi_xv 0 get {0 0 setrgbcolor} STCibar - STCi_win dup 1 exch 1 get 47 sub put - STCi_win dup 3 exch 3 get 47 sub put - STCi_win STCi_xv 1 get {0 0 3 1 roll setrgbcolor} STCibar - STCi_win dup 1 exch 1 get 47 sub put - STCi_win dup 3 exch 3 get 47 sub put - STCi_win STCi_xv 2 get {0 0 3 2 roll setrgbcolor} STCibar - }{ % CMYK - STCi_win STCi_xv 0 get {0 0 0 setcmykcolor} STCibar - STCi_win dup 1 exch 1 get 47 sub put - STCi_win dup 3 exch 3 get 47 sub put - STCi_win STCi_xv 1 get {0 0 0 4 1 roll setcmykcolor} STCibar - STCi_win dup 1 exch 1 get 47 sub put - STCi_win dup 3 exch 3 get 47 sub put - STCi_win STCi_xv 2 get {0 0 0 4 2 roll setcmykcolor} STCibar - STCi_win dup 1 exch 1 get 47 sub put - STCi_win dup 3 exch 3 get 47 sub put - STCi_win STCi_xv 3 get {0 0 0 4 3 roll setcmykcolor} STCibar - } - ] STCimode - - STCi_win 1 STCi_clip 1 get put - STCi_win dup 3 exch 3 get 47 sub put - -% -% Plot either one or two Color-Triangles -% - /ColorAdjustMatrix STCiget null ne STCi_onstc and { - STCi_win 0 get STCi_win 2 get add 2 div - [STCi_win 0 get STCi_win 1 get 3 index STCi_win 3 get ] colortri - mark /ColorAdjustMatrix dup STCiget currentdevice putdeviceprops pop - [1 index STCi_win 1 get STCi_win 2 get STCi_win 3 get ] colortri - pop - }{ - STCi_win colortri - } ifelse - newpath clippath stroke -} ifelse -showpage diff --git a/Master/tlpkg/tlgs/lib/stcolor.ps b/Master/tlpkg/tlgs/lib/stcolor.ps deleted file mode 100644 index 105a6ec3949..00000000000 --- a/Master/tlpkg/tlgs/lib/stcolor.ps +++ /dev/null @@ -1,169 +0,0 @@ -% Copyright (C) 2001-2012 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., 7 Mt. Lassen Drive - Suite A-134, San Rafael, -% CA 94903, U.S.A., +1(415)492-9861, for further information. -% - -% stcolor.ps -% Epson Stylus-Color Printer-Driver - -% The purpose of this file is to configure the stcolor-printer driver - -% -% It is useless and dangerous to interpret the following code with anything -% else than Ghostscript, so this condition is verified first. If this fails -% a message is send to the output. If this message bothers you, remove it, -% but I prefer to know why the device-setup failed. - -statusdict begin product end -dup (Ghostscript) eq 1 index (Artifex Ghostscript) eq or -exch (AFPL Ghostscript) eq or{ - -% fetch the current device-parameters this is specific for Ghostscript. - - /STCold currentdevice getdeviceprops .dicttomark def - -% Any Ghostscript-Driver has a Name, verify that the selected device is -% stcolor, otherwise nothing than another message will be produced. - - STCold /Name get (stcolor) eq { - -% -% The main thing this file does, is to establish transfer-functions. -% Here are two predefined arrays for 360x360Dpi and for 720x720DpI. -% If resolution is 360x720 or 720x360 the average is used. You may -% want to define other arrays here. -% - - /STCdeftransfer [ 0.0 1.0 ] def - - /STCKtransfer360 [ - 0.0000 0.0034 0.0185 0.0377 0.0574 0.0769 0.0952 0.1147 - 0.1337 0.1540 0.1759 0.1985 0.2209 0.2457 0.2706 0.2949 - 0.3209 0.3496 0.3820 0.4145 0.4505 0.4907 0.5344 0.5840 - 0.6445 0.7093 0.8154 0.9816 0.9983 0.9988 0.9994 1.0000 - ] def - - /STCKtransfer720 [ - 0.0000 0.0011 0.0079 0.0151 0.0217 0.0287 0.0354 0.0425 - 0.0492 0.0562 0.0633 0.0700 0.0766 0.0835 0.0900 0.0975 - 0.1054 0.1147 0.1243 0.1364 0.1489 0.1641 0.1833 0.2012 - 0.2217 0.2492 0.2814 0.3139 0.3487 0.3996 0.4527 0.5195 - ] def - -% compute the resolution - - STCold /HWResolution get dup - 0 get exch 1 get mul sqrt /STCdpi exch def - -% pick the colormodel - STCold /ProcessColorModel get /STCcolor exch def - - mark % prepare stack for "putdeviceprops" - -% warn for BitsPerPixel=30 with fsrgb - STCcolor /DeviceRGB eq STCold /BitsPerPixel get 32 eq and - { - (%%[ stcolor.ps: inefficient RGB-setup, recommend BitsPerPixel=24 ]%%\n) - print - } if - -% if the Dithering-Method is default (gscmyk), change it to fscmyk -% this is achieved by pushing a name/value-pair onto the stack -% if the selected algorithm uses another ProcessColorModel, it is necessary -% to change the Value of STCcolor according to the new algorithm. - - STCold /Dithering get (gscmyk) eq - { - /Dithering (hscmyk) % preferred dithering-method - } if % might be necessary to change STCcolor too - -% -% select the array according to the resolution -% - STCdpi 359.0 lt - { STCdeftransfer } - { STCdpi 361.0 lt - { STCKtransfer360 } - { STCdpi 719.0 gt - { STCKtransfer720 } - { - STCKtransfer360 length STCKtransfer720 length eq - { - 0 1 STCKtransfer360 length 1 sub - { - dup dup - STCKtransfer360 exch get - exch STCKtransfer720 exch get - add 2.0 div - STCKtransfer360 3 1 roll put - } for - }if - STCKtransfer360 - } ifelse - }ifelse - } ifelse - /STCtransfer exch def - -% -% Add the arrays. With Version 1.17 and above, it seems to be -% a good idea, to use the transfer-arrays as coding-arrays too. -% - -% -% RGB-Model requires inversion of the transfer-arrays -% - STCcolor /DeviceRGB eq - { - /RGBtransfer STCtransfer length array def - 0 1 STCtransfer length 1 sub - { - dup RGBtransfer length 1 sub exch sub exch - STCtransfer exch get 1.0 exch sub - RGBtransfer 3 1 roll put - } for - - /Rtransfer RGBtransfer - /Gtransfer RGBtransfer - /Btransfer RGBtransfer - - /Rcoding RGBtransfer - /Gcoding RGBtransfer - /Bcoding RGBtransfer - - }{ - - /Ctransfer STCtransfer - /Mtransfer STCtransfer - /Ytransfer STCtransfer - /Ktransfer STCtransfer - - /Ccoding STCtransfer - /Mcoding STCtransfer - /Ycoding STCtransfer - /Kcoding STCtransfer - - } ifelse - - counttomark 0 ne - {currentdevice putdeviceprops pop}{cleartomark}ifelse - -% decativate predefined correction - - {} dup dup currenttransfer setcolortransfer - - }{ - (%%[ stcolor.ps: currentdevice is not stcolor - ignored ]%%\n) print - } ifelse -}{ - (%%[ stcolor.ps: not interpreted by AFPL Ghostscript - ignored ]%%\n) print -} ifelse diff --git a/Master/tlpkg/tlgs/lib/viewraw.ps b/Master/tlpkg/tlgs/lib/viewraw.ps index c456afe5d1c..80e019ecad9 100644 --- a/Master/tlpkg/tlgs/lib/viewraw.ps +++ b/Master/tlpkg/tlgs/lib/viewraw.ps @@ -18,25 +18,125 @@ % Requires the colorimage operator. % If SCALE is defined, maps input pixels to output pixels with that scale; % if SCALE is undefined, scales the image to fit the page. -% If BITS is defined, it is the number of bits per sample (1,2,4,8,12); +% If BITS is defined, it is the number of bits per sample (1,2,4,8); % if BITS is undefined, its default value is 1. % Colorspace defaults to cmyk, but -dGray or -dRGB can change it -/viewraw { % viewraw - +/viewraw { % viewraw - 20 dict begin % Default ncomp is 4 == CMYK /w exch def /fname exch def - /ncomp + /F fname (r) file def % the raw file + /f /F load def % the usual DataSource + /bpc /BITS where { pop BITS } { 1 } ifelse def + /ncomp /Gray where - { pop 1 } % DeviceGray is 1 component - { /RGB where { pop 3 } { 4 } ifelse % DeviceRGB is 3 component, DeviceCMYK is 4 component - } ifelse + { pop 1 /CS /DeviceGray def } % DeviceGray is 1 component + { /RGB where + { pop 3 BITS 8 ge % DeviceRGB is 3 component, use Indexed for 1, 2, 4 BITS + { /CS /DeviceRGB def } + { + BITS 4 eq { + /P 4096 3 mul string def % the palette + 0 1 15 { /r exch def + 0 1 15 { /g exch def + 0 1 15 { /b exch def + r 256 mul g 16 mul add b add 3 mul % base of the triplet + P 1 index r 17 mul put + P 1 index 1 add g 17 mul put + P exch 2 add b 17 mul put + } for + } for + } for + /CS + [ /Indexed /DeviceRGB 4095 P ] def + /BITS 12 def % change to 4 bit indexed + % redefine the DataSource to pack the 16-bit values into 12-bit + % The 'proc' returns 2 12-bit pixels in 3 bytes + % This proc is needed for the output from -sDEVICE=bitrgb -dGrayValues=16 + /S3 3 string def + /f { + F read + { + 256 mul F read + pop add 16 mul S3 0 2 index 256 div cvi put + 240 and F read + { add S3 exch 1 exch put S3 2 F read pop put } + { S3 exch 1 exch put S3 2 0 put } + ifelse + S3 + } + { () } + ifelse + } bind def + } if + BITS 2 eq { + /CS + [ /Indexed /DeviceRGB 255 < + 000000 000055 0000AA 0000FF + 005500 005555 0055AA 0055FF + 00AA00 00AA55 00AAAA 00AAFF + 00FF00 00FF55 00FFAA 00FFFF + 550000 550055 5500AA 5500FF + 555500 555555 5555AA 5555FF + 55AA00 55AA55 55AAAA 55AAFF + 55FF00 55FF55 55FFAA 55FFFF + AA0000 AA0055 AA00AA AA00FF + AA5500 AA5555 AA55AA AA55FF + AAAA00 AAAA55 AAAAAA AAAAFF + AAFF00 AAFF55 AAFFAA AAFFFF + FF0000 FF0055 FF00AA FF00FF + FF5500 FF5555 FF55AA FF55FF + FFAA00 FFAA55 FFAAAA FFAAFF + FFFF00 FFFF55 FFFFAA FFFFFF + + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 000000 + > + ] def + /BITS 8 def % change to 4 bit indexed + } if + BITS 1 eq { + /CS + [ /Indexed /DeviceRGB 15 < + 000000 0000FF 00FF00 00FFFF FF0000 FF00FF FFFF00 FFFFFF + 000000 0000FF 00FF00 00FFFF FF0000 FF00FF FFFF00 FFFFFF + > + ] def + /BITS 4 def % change to 4 bit indexed + } if + } + ifelse + } + { 4 /CS /DeviceCMYK def } % DeviceCMYK is 4 component + ifelse + } + ifelse def - /bpc /BITS where { pop BITS } { 1 } ifelse def - /f fname (r) file def + + % Calculate Height from file length and width mark fname status pop pop pop /flen exch def cleartomark - /h flen w bpc ncomp mul mul 7 add 8 idiv idiv def + % NB: bitrgb writes 4 bits when BITS=1, 8 bits when BITS=2, 16 bits when BITS=4 + % presumably to keep values on nice boundaries this takes some fudging + /h flen w bpc ncomp dup 3 eq bpc 8 lt and { 1 add } if mul mul 7 add 8 idiv idiv def %% (Dimensions: ) print [w h] == flush % Set up scaling. /SCALE where { @@ -51,15 +151,25 @@ 3 1 roll exch sub w div .min dup } ifelse scale %% w h bpc [1 0 0 -1 0 h] f false ncomp colorimage - << /ImageType 1 /Width w /Height h /ImageMatrix [1 0 0 -1 0 h] - /MultipleDataSources false /DataSource f /BitsPerComponent BITS - /Decode BITS 1 gt % inverted sense for 1 bit per component - { [ [ 0 1 ] [0] [ 0 1 0 1 0 1 ] [ 0 1 0 1 0 1 0 1 ] ] ncomp 1 sub get } - { [ [ 1 0 ] [0] [ 1 0 1 0 1 0 ] [ 1 0 1 0 1 0 1 0 ] ] ncomp 1 sub get } - ifelse + CS setcolorspace + << /ImageType 1 /Width w /Height h /ImageMatrix [1 0 0 -1 0 h] + /MultipleDataSources false /DataSource /f load /BitsPerComponent BITS + /Decode + bpc 1 eq { % inverted sense for 1 bit per component + [ [0] [ 1 0 ] [0] [ 0 15 ] [ 0 1 0 1 0 1 0 1 ] ] ncomp get + } if + bpc 2 eq { + [ [0] [ 0 1 ] [0] [ 0 255 ] [ 0 1 0 1 0 1 0 1 ] ] ncomp get + } if + bpc 4 eq { + [ [0] [ 0 1 ] [0] [ 0 4095 ] [ 1 0 1 0 1 0 1 0 ] ] ncomp get + } if + bpc 8 ge { + [ [0] [ 0 1 ] [0] [ 0 1 0 1 0 1 ] [ 1 0 1 0 1 0 1 0 ] ] ncomp get + } if >> image showpage - f closefile + F closefile end } bind def -- cgit v1.2.3