summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs')
-rw-r--r--Master/tlpkg/tlgs/README.TEXLIVE4
-rw-r--r--Master/tlpkg/tlgs/Resource/IdiomSet/Pscript5Idiom4
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_cet.ps2
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps7
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_img.ps115
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps2
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_statd.ps2
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps78
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_type1.ps4
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_base.ps27
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps644
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_font.ps148
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_main.ps403
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps574
-rwxr-xr-xMaster/tlpkg/tlgs/bin/gsdll32.dllbin7750144 -> 7838208 bytes
-rw-r--r--Master/tlpkg/tlgs/bin/gsdll32.libbin8470 -> 8470 bytes
-rwxr-xr-xMaster/tlpkg/tlgs/bin/gswin32.exebin140800 -> 140800 bytes
-rwxr-xr-xMaster/tlpkg/tlgs/bin/gswin32c.exebin132096 -> 132096 bytes
-rw-r--r--Master/tlpkg/tlgs/iccprofiles/default_cmyk.iccbin187484 -> 187484 bytes
-rw-r--r--Master/tlpkg/tlgs/iccprofiles/default_rgb.iccbin2576 -> 2576 bytes
-rw-r--r--Master/tlpkg/tlgs/iccprofiles/gray_to_k.iccbin5340 -> 5340 bytes
-rw-r--r--Master/tlpkg/tlgs/iccprofiles/lab.iccbin1972 -> 1972 bytes
-rw-r--r--Master/tlpkg/tlgs/iccprofiles/ps_cmyk.iccbin5340 -> 5340 bytes
-rw-r--r--Master/tlpkg/tlgs/iccprofiles/ps_gray.iccbin416 -> 416 bytes
-rw-r--r--Master/tlpkg/tlgs/iccprofiles/ps_rgb.iccbin564 -> 564 bytes
-rw-r--r--Master/tlpkg/tlgs/iccprofiles/srgb.iccbin2576 -> 2576 bytes
-rw-r--r--Master/tlpkg/tlgs/lib/addxchar.ps356
-rw-r--r--Master/tlpkg/tlgs/lib/decrypt.ps14
-rw-r--r--Master/tlpkg/tlgs/lib/font2c.ps674
-rw-r--r--Master/tlpkg/tlgs/lib/font2pcl.ps600
-rw-r--r--Master/tlpkg/tlgs/lib/gs_pfile.ps126
-rw-r--r--Master/tlpkg/tlgs/lib/gs_rdlin.ps19
-rw-r--r--Master/tlpkg/tlgs/lib/impath.ps178
-rw-r--r--Master/tlpkg/tlgs/lib/level1.ps2
-rw-r--r--Master/tlpkg/tlgs/lib/markhint.ps129
-rw-r--r--Master/tlpkg/tlgs/lib/markpath.ps58
-rw-r--r--Master/tlpkg/tlgs/lib/packfile.ps332
-rw-r--r--Master/tlpkg/tlgs/lib/pcharstr.ps125
-rw-r--r--Master/tlpkg/tlgs/lib/pdfwrite.ps396
-rw-r--r--Master/tlpkg/tlgs/lib/ps2ascii.ps1523
-rw-r--r--Master/tlpkg/tlgs/lib/ps2epsi.ps4
-rw-r--r--Master/tlpkg/tlgs/lib/quit.ps1
-rw-r--r--Master/tlpkg/tlgs/lib/showchar.ps92
-rw-r--r--Master/tlpkg/tlgs/lib/showpage.ps1
-rw-r--r--Master/tlpkg/tlgs/lib/traceop.ps10
-rw-r--r--Master/tlpkg/tlgs/lib/type1enc.ps64
-rw-r--r--Master/tlpkg/tlgs/lib/type1ops.ps236
-rw-r--r--Master/tlpkg/tlgs/lib/unprot.ps66
-rw-r--r--Master/tlpkg/tlgs/lib/viewmiff.ps2
-rw-r--r--Master/tlpkg/tlgs/lib/viewpbm.ps8
-rw-r--r--Master/tlpkg/tlgs/lib/wftopfa.ps302
-rw-r--r--Master/tlpkg/tlgs/lib/wrfont.ps664
53 files changed, 1369 insertions, 6633 deletions
diff --git a/Master/tlpkg/tlgs/README.TEXLIVE b/Master/tlpkg/tlgs/README.TEXLIVE
index 7c40a93296a..8358312554a 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.21 distribution
+This directory contains a subset of the Ghostscript 9.22 distribution
for Windows. The only purpose of this package is to support programs
shipped with TeX Live. It's not intended for general use.
@@ -24,6 +24,8 @@ Changes:
* kanji directory copied from w23tex.
+ * Binaries compiled by Akira Kakuto with --disable-compile-inits.
+
This version of Ghostscript will not be installed on your system and
will not interfere with other versions of Ghostscript which might be
installed already.
diff --git a/Master/tlpkg/tlgs/Resource/IdiomSet/Pscript5Idiom b/Master/tlpkg/tlgs/Resource/IdiomSet/Pscript5Idiom
index e22a946e593..021603f3341 100644
--- a/Master/tlpkg/tlgs/Resource/IdiomSet/Pscript5Idiom
+++ b/Master/tlpkg/tlgs/Resource/IdiomSet/Pscript5Idiom
@@ -137,8 +137,8 @@ currentuserparams /IdiomRecognition get
/Decode[0 1]def}{/Decode[0 1 0 1 0 1 0 1]def}ifelse}ifelse/DataSource{PaintData}def end/ImageDict
exch def/PaintProc{begin ImageDict image end}b currentdict mx makepattern setpattern end fEOFill{eofill}{fill}
ifelse grestore
- }
- }
+ } ifelse
+ }bind
]
/mask_pbf [
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cet.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cet.ps
index 8eb79bb06e0..d3e1686409b 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_cet.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_cet.ps
@@ -21,7 +21,7 @@ currentglobal //true setglobal
/serialnumber dup {233640} readonly .makeoperator put % match CPSI 3017.102 Tek shows serialnumber 1401788461
systemdict /deviceinfo undef % for CET 20-23-1
% /UNROLLFORMS true put % CET files do unreasonable things inside forms
-} superexec
+} 1183615869 internaldict /superexec get exec
/UNROLLFORMS true def
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps b/Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps
index a57bb94ed3b..a4d6dda2a5c 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps
@@ -55,8 +55,7 @@ level2dict begin
{ //SharedFontDirectory }
{ /LocalFontDirectory .systemvar } % can't embed ref to local VM
ifelse .forceput pop % LocalFontDirectory is local, systemdict is global
- } .bind odef % must bind .forceput and .setglobal
- % even if NOBIND in effect
+ } .bind odef
% Don't just copy (load) the definition of .setglobal:
% it gets redefined for LL3.
/setshared { /.setglobal .systemvar exec } odef
@@ -86,7 +85,7 @@ level2dict begin
% definition, copy it into the local directory.
//systemdict /SharedFontDirectory .knownget
{ 1 index .knownget
- { .FontDirectory 2 index 3 -1 roll { put } //superexec } % readonly
+ { .FontDirectory 2 index 3 -1 roll { put } systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse } % readonly
if
}
if
@@ -102,7 +101,7 @@ level2dict begin
% Furthermore, if FAKEFONTS is in effect, we want global real fonts to
% override fake local ones. We handle this by brute force.
/restore % <save> restore -
- { dup //restore % bind even if NOBIND
+ { dup //restore
/LocalFontDirectory .systemvar
FAKEFONTS
{ mark
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps b/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps
index a3da615cb3f..1f4c9eda288 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps
@@ -519,11 +519,11 @@ buildfontdict 3 /.buildfont3 cvx put
% the font in LocalFontDirectory.
.currentglobal
{ //systemdict /LocalFontDirectory .knownget
- { 2 index 2 index { .growput } //superexec } % readonly
+ { 2 index 2 index { .growput } systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse } % readonly
if
}
if
- dup .FontDirectory 4 -2 roll { .growput } //superexec % readonly
+ dup .FontDirectory 4 -2 roll { .growput } systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse % readonly
% If the font originated as a resource, register it.
currentfile .currentresourcefile eq { dup .registerfont } if
readonly
@@ -1193,7 +1193,7 @@ currentdict /.putgstringcopy .undef
.FontDirectory 1 index known not {
2 dict dup /FontName 3 index put
dup /FontType 1 put
- .FontDirectory 3 1 roll { put } //superexec % readonly
+ .FontDirectory 3 1 roll { put } systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse % readonly
} {
pop
} ifelse
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_img.ps b/Master/tlpkg/tlgs/Resource/Init/gs_img.ps
index f2b0f6287da..e1cd6279323 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_img.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_img.ps
@@ -746,119 +746,4 @@ if
end % img_utils_dict
-% Conditionally turn image interpolation on or off.
-% INTERPOLATE is not yet set, handle all cases
-currentdict /INTERPOLATE known
-currentdict /DOTERPOLATE known or
-currentdict /NOTERPOLATE known or not {
- currentfile 1 (%END INTERPOLATE) .subfiledecode flushfile
-} if
-
-/.interpolate {
- dup /Interpolate .knownget not { //false } if
- /INTERPOLATE .systemvar ne {
- dup gcheck .currentglobal exch .setglobal
- exch dup length dict copy
- dup /Interpolate /INTERPOLATE .systemvar put
- exch .setglobal
- } if
-} .bind odef
-
-/colorimage
- { /INTERPOLATE .systemvar
- { .currentglobal % w h bit [] {}...{} multi ncomp glob
- //false .setglobal
- 9 dict begin % w h bit [] {}...{} multi ncomp glob
- 2 .argindex { 1 index 7 add } { 8 } ifelse
- dup .argindex pop % check # of arguments
- copy gsave pop % preserve the arguments
- { 0 /DeviceGray 0 /DeviceRGB /DeviceCMYK }
- 1 index get setcolorspace % ... glob w h bit [] {}...{} multi ncomp
- {0 1 0 1 0 1 0 1}
- 1 index 2 mul 0 exch % ... glob w h bit [] {}...{} multi ncomp {0 1 ...} 0 2*ncomp
- getinterval /Decode exch def % ... glob w h bit [] {}...{} multi ncomp
- exch dup % ... glob w h bit [] {}...{} ncomp multi multi
- /MultipleDataSources exch def % ... glob w h bit [] {}...{} ncomp multi
- { array astore} { pop } ifelse % ... glob w h bit [] [{}...{}]
- /DataSource exch def % ... glob w h bit []
- /ImageMatrix exch def % ... glob w h bit
- /BitsPerComponent exch def % ... glob w h
- /Height exch def % ... glob w
- /Width exch def % ... glob
- /ImageType 1 def
- /Interpolate //true def
- .setglobal currentdict end % ... <<>>
- image grestore
- exch { 4 add } { 6 } ifelse
- { pop } repeat % -
- }
- { colorimage
- }
- ifelse
- } .bind odef
-
-/image
- { dup type /dicttype eq
- { dup /ImageType get 3 eq
- { .currentglobal //false .setglobal exch
- dup length dict copy begin .setglobal
- /DataDict DataDict .interpolate def
- /MaskDict MaskDict .interpolate def
- currentdict end
- }
- { .interpolate
- }
- ifelse
- image
- }
- { /INTERPOLATE .systemvar
- { 4 .argindex pop % check # of args
- .currentglobal //false .setglobal
- 8 dict begin .setglobal
- /ImageType 1 def
- /DataSource 1 index def
- /ImageMatrix 2 index def
- /BitsPerComponent 3 index def
- /Decode {0 1} def
- /Height 4 index def
- /Width 5 index def
- /Interpolate //true def
- currentdict end
- gsave /DeviceGray setcolorspace image grestore
- 5 { pop } repeat
- }
- { image
- }
- ifelse
- }
- ifelse
- } .bind odef
-
-/imagemask {
- dup type /dicttype eq {
- .interpolate imagemask
- } {
- /INTERPOLATE .systemvar {
- 4 .argindex pop % check # of args
- .currentglobal //false .setglobal
- 8 dict begin .setglobal
- /ImageType 1 def
- /DataSource 1 index def
- /ImageMatrix 2 index def
- /BitsPerComponent 1 def
- 2 index { {1 0} } { {0 1} } ifelse /Decode exch def
- /Height 4 index def
- /Width 5 index def
- /Interpolate //true def
- currentdict end imagemask 5 { pop } repeat
- } {
- imagemask
- } ifelse
- } ifelse
-} .bind odef
-
-currentdict /.interpolate .undef
-
-%END INTERPOLATE
-
.setglobal % restore VM mode
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps b/Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps
index a1deb5891a4..e2bffba377e 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps
@@ -58,7 +58,7 @@ languagelevel dup 2 .max .setlanguagelevel
/.bind /.bind_ load odef % note that .bind_ will get bound
currentdict /.bindscratch .undef
-DELAYBIND NOBIND or not {
+DELAYBIND not {
% We can't just do
% /bind /.bind load def
% because then /bind load == prints --.bind-- .
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_statd.ps b/Master/tlpkg/tlgs/Resource/Init/gs_statd.ps
index 18dfced1499..dbcf05199c9 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_statd.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_statd.ps
@@ -59,7 +59,7 @@ statusdict begin
% shrunk by 25 units on all 4 sides.
/note /letter load def
% End of Adobe-defined page sizes
-STRICT { (%END SIZES) .skipeof } if
+
% Other page sizes
% ISO standard paper sizes
/a0 {2384 3370 //.setpagesize exec} bind def
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps b/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps
index ebacc6bbd0d..8cb5b390c57 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps
@@ -435,7 +435,7 @@ currentdict /woff_tag_dict .undef
} bind def
% Each procedure in this dictionary is called as follows:
-% <encodingtable> proc <glypharray>
+% <encodingtable> proc <glyph dictionary>
/cmapformats mark
0 { % Apple standard 1-to-1 mapping.
6 256 getinterval_from_stringarray
@@ -538,35 +538,20 @@ currentdict /woff_tag_dict .undef
/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 dict def
- 0 0 2 nseg2 3 sub {
- % Stack: /glyphs numglyphs i2
- /i2 exch def
- /scode startc i2 getu16a def
- /ecode endc i2 getu16a def
-
- % Bug 693538: More undocumented nonsense: in cases where scode == ecode,
- % see Bug 691326 below *except*, it seems when both are zero
- scode 0 eq ecode 0 eq and not {
- scode ecode 1 add gt { % Bug 691326.
- /ecode scode 1 add def % Acrobat does this contrary to TTF spec that
- } if % requires such intervals to be ignored.
- 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 ecode scode sub 1 add add
- exch 1 index add exch
- numcodes add /numcodes exch def
- } if
- } for pop
-
- % Now fill in the array.
/numcodes 0 def /code 0 def
- 0 2 nseg2 3 sub {
+ % neg2 is number of segments x 2. A format 4 cmap, with usable
+ % mappings cannot (according to the spec) have only 1 segment,
+ % since format 4 requires a closing segment with start and end
+ % codes being 0xffff. Unfortunately, we have found badly subsetted
+ % TTF fonts which have one segment with valid mappings, and no
+ % closing segment.
+ % In such a case, force the loop to work as though as we have two
+ % segments - this works as we don't rely on the terminating segment
+ % but use the loop counter to spot completion - effrectively, we
+ % ignore the closing segment when it's present, anyway.
+ 0 2 nseg2 dup 4 lt {pop 4}if 3 sub {
/i2 exch def
/scode startc i2 getu16a def
/ecode endc i2 getu16a def
@@ -633,8 +618,8 @@ currentdict /woff_tag_dict .undef
} bind
.dicttomark readonly def % cmapformats
-% <cmaptab> cmaparray <glypharray>
-/cmaparray {
+% <cmaptab> cmapdict <glyph dictionary>
+/cmapdict {
dup 0 getu16a cmapformats exch .knownget {
TTFDEBUG {
(cmap: format ) print 1 index 0 getu16a = flush
@@ -1389,7 +1374,7 @@ mark
def
} if
- /cmapa cmaptab cmaparray def
+ /cmapa cmaptab cmapdict def
% Some badly designed Chinese fonts have a post table
% in which all glyphs other than 0 are named .null.
% Use CharStrings to keep track of the reverse map from
@@ -1436,7 +1421,7 @@ mark
TTFDEBUG { (\n1 setting alias: ) print dup ==only
( to be the same as ) print 2 index //== exec } if
- 7 index 2 index 3 -1 roll exch //.growput superexec
+ 7 index 2 index 3 -1 roll exch //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse
} forall
pop pop pop
}
@@ -1454,7 +1439,7 @@ mark
exch pop
TTFDEBUG { (\n2 setting alias: ) print 1 index ==only
( to use glyph index: ) print dup //== exec } if
- 5 index 3 1 roll //.growput superexec
+ 5 index 3 1 roll //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse
//false
}
{
@@ -1471,7 +1456,7 @@ mark
{ % CharStrings(dict) isunicode(boolean) cmap(dict) RAGL(dict) gname(name) codep(integer) gindex(integer)
TTFDEBUG { (\3 nsetting alias: ) print 1 index ==only
( to be index: ) print dup //== exec } if
- exch pop 5 index 3 1 roll //.growput superexec
+ exch pop 5 index 3 1 roll //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse
}
{
pop pop
@@ -1626,7 +1611,7 @@ currentdict /postalias undef
mark
.ttkeys
/NumGlyphs numloca
- /TT_cmap cmaptab cmaparray
+ /TT_cmap cmaptab cmapdict
/file_table_pos file_table_pos
/Decoding Decoding
.dicttomark
@@ -1645,7 +1630,7 @@ currentdict /postalias undef
mark
.ttkeys
/NumGlyphs numloca
- /TT_cmap cmaptab cmaparray
+ /TT_cmap cmaptab cmapdict
% /file_table_pos file_table_pos
/Decoding Decoding
.dicttomark
@@ -1767,9 +1752,8 @@ currentdict /postalias undef
% <chartoglyphmap> <subcmap> <AGL> .pdfmapchars /CharStrings <charstrings>
/.pdfmapchars {
- exch cmaparray /cmapencoding exch def % c2g
+ exch cmapdict /cmapencoding exch def % c2g
/CharStrings 0 dict % c2g /CS <<>>
-
% Add glyphs of <AGL>*<subcmap> :
3 2 roll { % /CS <<>> v
dup type /arraytype eq { % /CS <<>> /name []
@@ -1806,13 +1790,12 @@ currentdict /postalias undef
} forall
dup /.notdef 0 put
-
} bind def
% <subtable> .pdfmapsymbolic /Encoding [] /CharStrings <<>>
/.pdfmapsymbolic {
//true /.render_notdef gput
- cmaparray
+ cmapdict
dup length 1 add dict begin
[ 64 { /.notdef /.notdef /.notdef /.notdef } repeat ]
exch { % [] char glyph
@@ -1845,7 +1828,7 @@ currentdict /postalias undef
% The following algorithms are per the PDF 1.7 Reference.
TTFDEBUG { (.pdfcharkeys beg) = } if
- % if the flags say symbolic, *and* the font contains a symbol
+ % if the flags say symbolic, *and* the font contains a symbol or UCS-2
% cmap table, ignore Encoding if there is one, treat as symbolic.
% If the flags say symbolic, and the font doesn't have a symbol cmap
% and we have an Encoding, treat it as non-symbolic
@@ -1853,7 +1836,20 @@ currentdict /postalias undef
% Finally, if none of that works, remove the Encoding, and treat it
% as non-symbolic.
is_symbolic {
- <00030000> .findcmap { //true } { prebuilt_encoding //null eq { <00010000> .findcmap}{//false}ifelse } ifelse {
+ <00030000> .findcmap
+ { //true }
+ {
+ prebuilt_encoding //null eq {
+ <00030001> .findcmap
+ {//true}
+ {<00010000> .findcmap}
+ ifelse
+ }
+ {//false}
+ ifelse
+ } ifelse
+
+ {
.pdfmapsymbolic
/prebuilt_encoding //null def
//false
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_type1.ps b/Master/tlpkg/tlgs/Resource/Init/gs_type1.ps
index 772bb7163ff..dbd9bf38a44 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_type1.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_type1.ps
@@ -116,7 +116,7 @@
{ % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) cstring gname aglname
CFFDEBUG { (\nsetting alias: ) print dup ==only
( to be the same as glyph: ) print 1 index //== exec } if
- 3 index exch 3 index //.growput superexec
+ 3 index exch 3 index //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse
% scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) cstring gname
}
{pop} ifelse
@@ -135,7 +135,7 @@
3 1 roll pop pop
} if
pop
- dup /.AGLprocessed~GS //true //.growput superexec
+ dup /.AGLprocessed~GS //true //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse
} if
%% We need to excute the C .buildfont1 in a stopped context so that, if there
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps
index bdfe9ee8feb..f2ae2dec3ef 100644
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps
@@ -774,6 +774,11 @@ currentdict /no_debug_dict undef
% When resolving an object reference, we stop at the endobj or endstream.
/resolveopdict mark
valueopdict { } forall
+ /xref { % Bug 697761
+ ( **** Error: Encountered 'xref' while expecting 'endobj'.\n) pdfformaterror
+ ( Treating this as a missing 'endobj', output may be incorrect.\n) pdfformaterror
+ endobj exit
+ } bind
/endstream { endobj exit } bind
/endobj { endobj exit } bind
/endjobj { % Bug 689876.
@@ -786,9 +791,13 @@ currentdict /no_debug_dict undef
( Output may be incorrect.\n) pdfformaterror
endobj exit
} bind
+ /obj {
% OmniForm generates PDF file with endobj missing in some
% objects. AR ignores this. So we have to do it too.
- /obj { pop pop endobj exit } bind
+ ( **** Error: Encountered 'obj' while expecting 'endobj'.\n) pdfformaterror
+ ( Treating this as a missing 'endobj', output may be incorrect.\n) pdfformaterror
+ pop pop endobj exit
+ } bind
.dicttomark readonly def
/resolveR { % <object#> <generation#> resolveR <object>
@@ -849,12 +858,13 @@ currentdict /no_debug_dict undef
dup type /dicttype eq % For dictionaries only
{
- dup /Type .knownget % make sure the dictionary has a type
+ dup /Type known % make sure the dictionary has a type
{
- dup /Font eq exch /FontDescriptor eq or % and ensure its a Font or FontDescriptor
- {dup 3 -1 roll /.gs.pdfobj# exch put}
- {exch pop}
- ifelse
+ %% We must not add to *all* dictionaries, because some of them are handled by
+ %% executing all the key/value pairs, and adding a integer causes problems
+ %% Since we only use this number for font identification, or checking self-references,
+ %% we only need it for dictionaries with a Type, and these are always handled more carefully.
+ dup 3 -1 roll /.gs.pdfobj# exch put
}
{exch pop}
ifelse
@@ -889,11 +899,6 @@ currentdict /no_debug_dict undef
% may have preceded the EOL, such as spaces or tabs. Thus we back up one
% character and scan until we find the \n terminator.
/stream { % <dict> stream <modified_dict>
- dup /Length knownoget {
- 0 eq {
- dup /Filter undef % don't confuse any filters that require data
- } if
- } if
dup /F known dup PDFsource PDFfile eq or {
not {
dup /File PDFfile put
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps
index 88da2de7485..68a56a3674b 100644
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps
@@ -26,34 +26,6 @@ pdfdict begin
% PDF graphics operations, even though this is too liberal.
/drawopdict 100 dict def
-/SetGroupExtGStateDict
-<<
- /AlphaIsShape //AIS
- /FillConstantAlpha //ca
- % We don't have to worry about the enumeration order, even
- % with the color/space settings, since we only store, not
- % not set them.
- /FillColor //sc1
- /FillColorSpace { /FillColorSpace gput } bind
- /FillOverprint //op
- /SoftMask //SMask
- /StrokeConstantAlpha //CA
- /StrokeColor //SC1
- /StrokeColorSpace { /StrokeColorSpace gput } bind
- /StrokeOverprint //OP
- /TextSpacing //Tc
- % We can't use //Tz as we've stored the value we actually use,
- % not value * 100 (see /Tz in pdf_ops.ps)
- /TextHScaling { /TextHScaling gput } bind
- /Leading //TD
- /TextFont { /TextFont gput} bind
- /TextLineMatrix { /TextLineMatrix gput } bind
- /TextMatrix { /TextMatrix gput } bind
- /TextRise { /TextRise gput } bind
- /TextRenderingMode { /TextRenderingMode gput } bind
- /WordSpacing //Tw
->> def
-
% ================================ Graphics ================================ %
% ---------------- Functions ---------------- %
@@ -156,6 +128,20 @@ pdfdict begin
1 index /Default eq { exch pop } { pop resolveidfnproc } ifelse
} bdef
+%% A BBox where width or height (or both) is 0 should still paint one pixel
+%% See the ISO 32000-2:2017 spec, section 8.7.4.3, p228 'BBox' and 8.7.3.1
+/FixPatternBBox
+{
+ dup aload pop
+ 3 index 2 index sub 0 eq {
+ 3 index 0.000001 add 3 -1 roll pop exch
+ } if
+ 2 index 1 index sub 0 eq {
+ 2 index 0.000001 add exch pop
+ }if
+ 5 -1 roll astore
+}bind def
+
% ---------------- Shadings ---------------- %
/shrdict mark
@@ -177,6 +163,7 @@ pdfdict begin
/BBox {
dup dup dup aload pop normrect_elems
5 -1 roll astore
+ FixPatternBBox
} bind
/ColorSpace {
resolvecolorspace
@@ -472,6 +459,13 @@ end
/AIS { AIS }
/BM { BM }
/TK { TK }
+ /UseBlackPtComp { UseBlackPtComp }
+ /HTO {
+ % PDF 2.0, supposed to be 'similar' to halftone phase but using a different
+ % co-ordiate system. Treat the same for now and fix if anyone ever complains.
+ aload pop transform cvi exch cvi exch 2 array astore
+ dup sethalftonephases .swapcolors sethalftonephases .swapcolors
+ }
.dicttomark readonly def
/gs { % <gsres> gs -
Page /ExtGState rget {
@@ -502,7 +496,8 @@ end
dup /None eq 1 index //null eq or PDFusingtransparency not or {
pop //null
- SoftMask //null ne {
+
+ .currentSMask //null ne {
% get rid of the current SMask (Bug 695471)
false % colorspace not set
<< /Subtype /None >> % Special type for this purpose
@@ -558,18 +553,9 @@ end
/GroupGState gstate currentgstate 6 2 roll
grestore
/GroupMat matrix currentmatrix 8 2 roll
- /GroupExtGState 1 dict
- //SetGroupExtGStateDict
- {
- exch dup where
- {
- exch get 2 index 3 1 roll put
- }
- {
- pop pop
- } ifelse
- } forall
- 10 2 roll
+% /GroupExtGState 1 dict
+% 10 2 roll
+
/.execmaskgroup cvx 2 packedarray cvx /Draw exch 3 2 roll
pop
.dicttomark
@@ -634,48 +620,62 @@ def
3 -1 roll dup
dup 4 1 roll /BBox get aload pop .begintransparencymaskgroup
exch dup /Resources knownoget { oforce } { 2 dict } ifelse
- 3 -1 roll dup /GroupGState .knownget { 2 index /GroupGState 3 -1 roll put} if
- /GroupExtGState .knownget { 1 index /GroupExtGState 3 -1 roll put} if
+ 3 -1 roll /GroupGState .knownget { 1 index /GroupGState 3 -1 roll put} if
exch //false resolvestream
- 1 index exch .execgroup
+ 1 index exch
+
+ %% Get the current colour space and colour values (as an array), we need to pass these to .execgroup
+ %% as well, so that it can restore them, in case the colour space gets changed by transparency
+ %% graphics state stuff.
+ mark currentcolor counttomark array astore exch pop
+ currentcolorspace 4 2 roll
+
+ .execgroup
% We have to remove these in case the Form XObject is subsequently used as
% a form rather than a group - they remain in the paramdict for the SMask
% so this will all still work if the SMask is re-evaluated.
- dup /GroupGState undef
- /GroupExtGState undef
+ /GroupGState undef
+
.endtransparencymask
PDFfile exch setfileposition
mark exch /OverrideICC exch .dicttomark setuserparams
.setuseciecolor setcolorspace setcolor
setmatrix
end % restore colorspace, color and ExtGState (end)
- /SoftMask where pop /SoftMask //true put % special setting to tell us it has been rendered
+ .currentSMask /Processed //true put % special setting to tell us it has been rendered
} bdef
% Paint a Form+Group XObject, either for a transparency mask or for a Do.
-/.execgroup { % <resdict> <stream> .execgroup -
+/.execgroup { % [colour values] <colour space> <resdict> <stream> .execgroup -
pdfemptycount 3 1 roll
- /pdfemptycount count 3 sub store
+ /pdfemptycount count 5 sub store
gsave //nodict begin
% We have to set the gstate correctly for lazy evaluation of a softmask group.
- % we also must preserve the color(space) as setup in .execmaskgroup.
+ % we also must restore the color(space) as setup in .execmaskgroup or paintformgroup.
% This stuff must be done here, as .execmaskgroup can't use gsave/grestore to
% manipulate the gstates, due to the requirements of .begintransparencymaskgroup.
% We also must set the ExtGState values.
% It may seem redundant to do the color(space) twice (once here and once in
% .execmaskgroup) but we have to set it in .execmaskgroup for the background
% color and set it here once in the correct gstate.
- mark currentcolor currentcolorspace counttomark 2 add index dup
+ 1 index
/GroupGState .knownget { setgstate } if
- /GroupExtGState .knownget { { exch exec } forall } if
- setcolorspace setcolor pop
+
newpath //null SMask
1 .setopacityalpha 1 .setshapealpha
1 CA 1 ca
/Compatible .setblendmode
% Execute the body of the Form, similar to DoForm.
- pdfopdict .pdfruncontext
+ pdfopdict
+
+ %% Restore the colour space (passed in on the stack) and current colour
+ %%
+ 6 -2 roll
+ setcolorspace
+ aload pop setcolor
+
+ .pdfruncontext
end grestore
/pdfemptycount exch store
} bdef
@@ -694,6 +694,11 @@ def
% .paintgroupform implements the Form PaintProc in the case where the
% Form XObject dictionary includes a Group key. See .paintform below.
/.paintgroupform { % <resdict> <stream> <formdict> .paintgroupform -
+ %% Pass the current color space, and an array with the current color vales
+ %% as arguments to .execgroup
+ mark currentcolor counttomark array astore exch pop
+ currentcolorspace 5 2 roll
+
dup /Group oget exch /BBox oget
% Stack: resdict stream groupdict bbox
.beginformgroup
@@ -730,7 +735,8 @@ def
DataDict /Matte knownoget {
/Matte exch def
} if
- AlphaIsShape { /ShapeMaskDict } { /OpacityMaskDict } ifelse exch def
+ .currentalphaisshape
+ { /ShapeMaskDict } { /OpacityMaskDict } ifelse exch def
/ColorSpace DataDict /ColorSpace get def
} bdef
@@ -1055,13 +1061,16 @@ currentdict end readonly def
} {
% For uncolored patterns, we have to unbind the current
% color and color space before running the PaintProc.
- //null sc1 //null SC1
+ % Not true since moving the ExtGState parameters into the gstate.
+ % //null sc1 //null SC1
} ifelse
% Save old values on opstack, set pdfemptycount to new value.
pdfemptycount countdictstack mark
- /pdfemptycount count 3 sub def 5 3 roll
+ %% We can't simply 'def' into the dictionary saved by 'q' above, we need to
+ %% call gput to copy it and store inside it. Stupid or what....
+ /pdfemptycount count 3 sub gput 5 3 roll
%
% Stack: ... <old emptycount> <dictcount> mark <patdict> <resdict>
% |
@@ -1074,11 +1083,51 @@ currentdict end readonly def
{ countdictstack
2 index le { exit } if
currentdict /n known not or
- Q
- } loop {
- ( **** Error: Pattern stream has unbalanced q/Q operators \(too many q's\)\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
+ currentdict /n known currentdict /self known or{
+ Q
+ }{
+ (\n **** Error: File has unbalanced q/Q operators \(too many Q's\)\n Output may be incorrect.\n)
+ pdfdict /.Qqwarning_issued .knownget
+ {
+ {
+ pop
+ }
+ {
+ currentglobal pdfdict gcheck .setglobal
+ pdfdict /.Qqwarning_issued //true .forceput
+ .setglobal
+ pdfformaterror
+ } ifelse
+ }
+ {
+ currentglobal pdfdict gcheck .setglobal
+ pdfdict /.Qqwarning_issued //true .forceput
+ .setglobal
+ pdfformaterror
+ } ifelse
+ end
+ } ifelse
+ } loop
+ {
+ (\n **** Error: File has unbalanced q/Q operators \(too many q's\)\n Output may be incorrect.\n)
+ pdfdict /.Qqwarning_issued .knownget
+ {
+ {
+ pop
+ }
+ {
+ currentglobal pdfdict gcheck .setglobal
+ pdfdict /.Qqwarning_issued //true .forceput
+ .setglobal
+ pdfformaterror
+ } ifelse
+ }
+ {
+ currentglobal pdfdict gcheck .setglobal
+ pdfdict /.Qqwarning_issued //true .forceput
+ .setglobal
+ pdfformaterror
+ } ifelse
} if
pop
@@ -1150,7 +1199,7 @@ currentdict end readonly def
2 index /Resources knownoget { oforce } { 0 dict } ifelse
/.pdfpaintproc cvx
] cvx put
- dup /BBox 2 copy knownoget { normrect put } { pop pop } ifelse
+ dup /BBox 2 copy knownoget { normrect FixPatternBBox put } { pop pop } ifelse
dup /.pattern_uses_transparency 1 index patternusestransparency put
PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Pattern: ) print dup === flush } if } if
} bdef
@@ -1189,7 +1238,12 @@ drawopdict begin
/sc { .incachedevice {
.pdfcount { pop } repeat //ignore_color_op pdfformaterror
} {
- scresolve { sc*_and_set } { sc1_and_set } ifelse
+ scresolve 1 index //null eq {
+ pop pop
+ //ignore_color_op pdfformaterror
+ } {
+ { sc*_and_set } { sc1_and_set } ifelse
+ } ifelse
} ifelse
} bdef
@@ -1233,7 +1287,12 @@ drawopdict begin
/SC { .incachedevice {
.pdfcount { pop } repeat //ignore_color_op pdfformaterror
} {
- scresolve { SC*_and_set } { SC1_and_set } ifelse
+ scresolve 1 index //null eq {
+ pop pop
+ //ignore_color_op pdfformaterror
+ }{
+ { SC*_and_set } { SC1_and_set } ifelse
+ }ifelse
} ifelse
} bdef
@@ -1300,7 +1359,7 @@ drawopdict begin
setfillstate resolvesh
//sh_save 0 save put
PDFusingtransparency {
- SoftMask //null ne {
+ .currentSMask //null ne {
//sh_group
1 index /BBox knownoget {
{ oforce } forall
@@ -1327,7 +1386,7 @@ drawopdict begin
{
.endtransparencygroup .setopacityalpha .setblendmode % end the CompatibleOverprint group
} if
- SoftMask //null ne {
+ .currentSMask //null ne {
.endtransparencygroup
} if
} {
@@ -1359,7 +1418,7 @@ end
/CIEBasedABC { 1 get /RangeABC knownoget not { //01_3 } if } bind
/CalGray { pop //01_1 } bind
/CalRGB { pop //01_3 } bind
- /Lab { 1 get /Range knownoget not { [-100 100 -100 100] } if } bind
+ /Lab { 1 get /Range knownoget not { [-100 100 -100 100] } {aload pop 0 100 6 2 roll 6 array astore}ifelse } bind
/ICCBased {
1 oget dup /Range knownoget {
exch pop
@@ -2024,7 +2083,7 @@ currentdict /last-ditch-bpc-csp undef
ColorSpace dup type /arraytype eq { 0 oget } if /Indexed eq
BitsPerComponent 1 eq and {
- % AR9 treats Indexed 1 bpc images specially. Bug 692852.
+ % AR9 treats Indexed 1 bpc images specially. Bug 692852 see also 697919 and 689717.
dup 0 oget
dup 0 lt exch 1 BitsPerComponent bitshift ge or {
% First component is invalid - AR9 ignores the mask
@@ -2037,7 +2096,33 @@ currentdict /last-ditch-bpc-csp undef
% AR5, AR9 do this for most cases. Bug 690786.
[ exch { 1 BitsPerComponent bitshift 1 sub and } forall ]
} ifelse
- } if
+ } {
+ ColorSpace dup type /arraytype eq { 0 oget } if /DeviceGray eq
+ BitsPerComponent 1 eq and {
+ %% For DeviceGray, try clamping the values to 0 and 1 respectively
+ dup 0 oget
+ dup 0 lt exch 1 gt or {
+ dup 0 oget
+ dup 0 lt {
+ pop dup 0 0 put
+ }{
+ dup 0 1 put
+ } ifelse
+ } if
+ dup 1 oget
+ dup 0 lt exch 1 gt or {
+ dup 1 oget
+ dup 0 lt {
+ pop dup 0 0 put
+ }{
+ dup 0 1 put
+ } ifelse
+ } if
+ }{
+ % AR5, AR9 do this for most cases. Bug 690786.
+ [ exch { 1 BitsPerComponent bitshift 1 sub and } forall ]
+ } ifelse
+ } ifelse
dup //null ne {
/MaskColor exch def
} {
@@ -2089,7 +2174,7 @@ currentdict /last-ditch-bpc-csp undef
.begintransparencymaskimage
PDFfile fileposition exch
gsave //nodict begin
- //null /SoftMask gput
+ //null .setSMask
1 .setopacityalpha 1 .setshapealpha
1 CA 1 ca
/Compatible .setblendmode
@@ -2109,7 +2194,7 @@ currentdict /last-ditch-bpc-csp undef
% on our lazy evaulation of SMask groups
false << /Subtype /None >> 0 0 0 0 .begintransparencymaskgroup
} {
- SoftMask //null ne {
+ .currentSMask //null ne {
% the image doesn't have an SMask, but the ExtGState does, force a group.
<< /Subtype /Group /Isolated //true >> 0 0 1 1 .begintransparencygroup
doimage
@@ -2128,6 +2213,44 @@ currentdict /last-ditch-bpc-csp undef
} bdef
} if
+/ValidateDecode { % <<image dict>> -imagemask- ValidateDecode <<image dict>>
+ exch
+ dup /Decode .knownget {
+ dup length % -imagemask- <<image dict>> [Decode] length
+ 4 -1 roll % <<image dict>> [Decode] length -imagemask-
+ {
+ 1 % ImageMask Decode arrays must be [0 1] or [1 0]
+ }
+ {
+ mark currentcolor counttomark % <<image dict>> [Decode] length [ ... component_count
+ dup 2 add 1 roll % <<image dict>> [Decode] length component_count [ ....
+ cleartomark % <<image dict>> [Decode] length component_count
+ } ifelse
+ 2 mul dup % <<image dict>> [Decode] length comp_count*2 comp_count*2
+ 3 1 roll % <<image dict>> [Decode] comp_count*2 length comp_count*2
+ eq { % <<image dict>> length of Decode matches colour space requirement
+ pop pop % <<image dict>> remove [Decode] and comp_count*2
+ }{ % <<image dict>> Decode array incorrect
+ dup 2 index length % <<image dict>> [Decode] comp_count*2 comp_count*2 length
+ exch sub 0 gt { % Decode is too long
+ (\n **** Warning: Decode array for an image is too long\n) pdfformatwarning
+ ( Output may be incorrect.\n) pdfformatwarning
+ 0 exch % <<image dict>> [Decode] 0 comp_count*2
+ getinterval % <<image dict>> [subarray of Decode]
+ 1 index exch /Decode exch % <<image dict>> <<image dict>> /Decode [subarray]
+ put % <<image dict>>
+ }{
+ % Decode is too short, Acrobat throws errors on this
+ (\n **** ERROR: Decode array for an image is too short\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ pop pop % remove [Decode] and comp_count*2
+ } ifelse
+ } ifelse
+ } {
+ exch pop
+ }ifelse
+}bdef
+
/doimage { % <imagemask> doimage -
% imagedict is currentdict, gets popped from dstack
//null checkOPtrans {
@@ -2160,8 +2283,8 @@ currentdict /last-ditch-bpc-csp undef
makemaskimage
} if
% Stack: datasource imagemask
- { currentdict end setfillstate { imagemask } }
- { ColorSpace setgcolorspace currentdict end setfillblend { image } }
+ { currentdict end setfillstate true ValidateDecode { imagemask } }
+ { ColorSpace setgcolorspace currentdict end setfillblend false ValidateDecode { image } }
ifelse
PDFSTOPONERROR { exec //false } { stopped } ifelse {
dup type /dicttype eq { pop } if % Sometimes image fails to restore the stack
@@ -2451,7 +2574,61 @@ currentdict end readonly def
//ocg_pocs exch get exec % bool
} ifelse
} {
- /OFF known not % OFF is inserted by process_trailer_attrs
+ dup /OFF known not % OFF is inserted by process_trailer_attrs
+ {
+ %% /OC is not in the OCProperties /OFF array, so we need to
+ %% test its usage. We may eventually have to add a /ON to the dictionary
+ %% if the OCProperties /ON array defines the /OC, I think that should override
+ % the Usage, but I don't have an example to test.
+ /Usage .knownget {
+ oforce
+ /Printed where {
+ /Printed get
+ } {
+ //false
+ }ifelse
+ {
+ %% We are behaving as a printer, check the Print state
+ /Print .knownget {
+ /PrintState .knownget {
+ oforce
+ /OFF eq {
+ //false
+ }{
+ //true
+ } ifelse
+ }{
+ //true
+ } ifelse
+ }{
+ %% If we don't know, assume its visible
+ //true
+ } ifelse
+ }{
+ %% We are behaving as a viewer, check the View state
+ /View .knownget {
+ oforce
+ /ViewState .knownget {
+ /OFF eq {
+ //false
+ }{
+ //true
+ } ifelse
+ }{
+ //true
+ } ifelse
+ }{
+ %% If we don't know, assume its visible
+ //true
+ } ifelse
+ } ifelse
+ }{
+ %% If we don't know, assume its visible
+ //true
+ } ifelse
+ }{
+ pop //false
+ }ifelse
} ifelse
} {
/OFF known not % OFF is inserted by process_trailer_attrs
@@ -2480,30 +2657,72 @@ drawopdict begin
} if
setfillblend
PDFfile fileposition exch % pos /Name
- dup Page /XObject rget {
- exch pop % pos obj
- OFFlevels length 0 eq {
- dup /OC knownoget { ocg-is-visible } { //true } ifelse
- } {
+
+ % Bug #698226, Acrobat signals an error for recursive XObjects in a PDF file
+ % but continues. This is true even if the XObject is not a simple self-reference
+ % (eg /Fm1 -> /Fm2 -> /Fm3 -> /Fm1).
+ % Normally when dealing with recursion we would put a dictionary on the stack, store the
+ % object numbers encoutnered in it, and check each new object number to see if we've
+ % already seen it. This doesn't work well for XObjects, because the operand stack can be
+ % in any state when we run a Do. So we make a new dictionary in pdfdict to hold the
+ % object numbers.
+ % We also don't usually know the object number of a Form, we just get given its name
+ % so we need a new routine to return the object number. This is because the parent XObject
+ % might reference teh object by one name, while the child references it by another, we
+ % can't permit clashes.
+ %
+ % Start by getting the object number for a Form XObject
+ dup Page /XObject obj_get dup 0 eq not {
+ % Now get the recording dictionary and see if that object number has been seen
+ pdfdict /Recursive_XObject_D get 1 index known {
+ ( **** Error: Recursive XObject detected, ignoring ") print 1 index 256 string cvs print (", object number ) print 256 string cvs print (\n) print
+ ( Output may be incorrect.\n) pdfformaterror
//false
- } ifelse {
- dup /Subtype oget //xobjectprocs exch get % pos obj {proc}
- % Don't leave extra objects on the stack while executing
- % the definition of the form.
- 3 -1 roll % obj {proc} pos
- 2 .execn % pos
+ }{
+ % We haven't seen it yet, so record it.
+ pdfdict /Recursive_XObject_D get 1 index null put
+ 3 1 roll
+ //true
+ }ifelse
+ }
+ {
+ % I don't think this should be possible, but just in case
+ ( **** Error: Unable to determine object number for ) print exch 256 string cvs print ( so ignoring it) print
+ ( Output may be incorrect.\n) pdfformaterror
+ //false
+ } ifelse
+
+ % If we could get the object number, and we haven't already seen it, then execute it.
+ {
+ dup Page /XObject rget {
+ exch pop % pos obj
+ OFFlevels length 0 eq {
+ dup /OC knownoget { ocg-is-visible } { //true } ifelse
+ } {
+ //false
+ } ifelse {
+ dup /Subtype oget //xobjectprocs exch get % pos obj {proc}
+ % Don't leave extra objects on the stack while executing
+ % the definition of the form.
+ 3 -1 roll % obj {proc} pos
+ 2 .execn % pos
+ } {
+ pop % pos
+ } ifelse
} {
- pop % pos
+ % This should cause an error, but Acrobat Reader can
+ % continue, so we do too.
+ ( **** Error: Undefined XObject resource: )
+ exch =string cvs concatstrings (\n) concatstrings
+ pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
} ifelse
- } {
- % This should cause an error, but Acrobat Reader can
- % continue, so we do too.
- ( **** Error: Undefined XObject resource: )
- exch =string cvs concatstrings (\n) concatstrings
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
+ PDFfile exch setfileposition
+ pdfdict /Recursive_XObject_D get exch undef
+ }{
+ % Otherwise ignore it and tidy up the stacks
+ pop pop
} ifelse
- PDFfile exch setfileposition
} bdef
end
@@ -2854,11 +3073,15 @@ end
dup (BT ) writestring
1 index /DA fget not {
1 index /V fget {
- <FEFF> anchorsearch{
- pop pop /FallBackFont /Identity-UTF16-H [/CIDFallBack] composefont 12 scalefont setfont
- }{
+ <EFBBBF> anchorsearch {
pop /Helvetica findfont 12 scalefont setfont
- } ifelse
+ } {
+ <FEFF> anchorsearch {
+ pop pop /FallBackFont /Identity-UTF16-H [/CIDFallBack] composefont 12 scalefont setfont
+ } {
+ pop /Helvetica findfont 12 scalefont setfont
+ }ifelse
+ }ifelse
} if
()
}if
@@ -2894,11 +3117,18 @@ end
//false exch
NeedAppearances {
dup /FT fget {
- /Tx eq {
- dup /V oknown {
- pop not 1
- } if
- } if
+ dup /Tx eq {
+ pop
+ dup /V oknown {
+ pop not 1
+ } if
+ } {
+ /Ch eq {
+ dup /V oknown {
+ pop not 1
+ } if
+ } if
+ } ifelse
} if
} if
pop
@@ -2920,6 +3150,7 @@ end
% dup /AP undef
% } if
% } if
+
dup /AP knownoget {
dup /N known not {
( **** Error: Appearance dictionary (AP) lacks the mandatory normal (N) appearance.\n)
@@ -3264,6 +3495,12 @@ currentdict /set_bc_color undef
/emptydict 0 dict readonly def
/Highlight {
+% technically we should apply an appearance stream if we have one, but if we do
+% some test files don't match Acrobat. PDF 2.0 says appearance streams are mandatory,
+% and take precedence over generatig new ones, so we may need to revisit this.
+% dup /AP oknown {
+% //true
+% }{
0 setlinecap
dup annotsetcolor {
/QuadPoints knownoget {
@@ -3287,6 +3524,7 @@ currentdict /set_bc_color undef
} if
} if
//false
+% } ifelse
} bdef
currentdict /emptydict undef
currentdict /highlight-arc undef
@@ -3402,7 +3640,7 @@ currentdict /set_bc_color undef
{
gsave
- dup annotrect (rectclip from freetext annotation) == flush rectclip
+ dup annotrect rectclip
dup /CA knownoget {
.setopacityalpha
@@ -3684,7 +3922,7 @@ currentdict /set_bc_color undef
2 index 2 div add exch
3 index 2 div add exch translate % dx dy
- 50 div exch 190 div .min dup scale
+ 50 div exch 190 div .min dup 0.0 eq {pop 1.0} if dup scale
/Name knownoget not { /Draft } if
//stamp_dict 1 index known not { exch pop /Draft exch } if
@@ -3700,24 +3938,124 @@ currentdict /set_bc_color undef
} ifelse
} bdef
- currentdict /quadpoints2basis undef
+ /Popup {
+ dup /Open oknown {
+ dup /Open get {
+ dup /AP oknown {
+ //true
+ }{
+ gsave
+ newpath
+ 0.05 setlinewidth
+ dup /Parent .knownget {
+ oforce
+ } {
+ dup /P .knownget {
+ oforce
+ } {
+ dup
+ } ifelse
+ } ifelse
+ /C .knownget {
+ aload pop
+ }{
+ 1 1 0
+ }ifelse
+ setrgbcolor
+ dup /Rect get
+ dup aload pop
+ 2 index sub
+ exch 3 index sub exch
+ 4 copy
+ gsave 1 setgray rectfill grestore
+ gsave 0 setgray rectstroke grestore
+ 1 index /Parent .knownget {
+ oforce
+ }{
+ 1 index /P .knownget {
+ oforce
+ }{
+ 1 index
+ } ifelse
+ }ifelse
+ dup
+ /Contents .knownget {
+ gsave
+ 0 setgray
+ /Helvetica findfont 9 scalefont setfont
+ 2 index aload pop 3 1 roll pop pop 30 sub exch 5 add exch
+ moveto show
+ grestore
+ } if
+ exch
+ dup aload pop 3 -1 roll pop exch 2 index sub -15
+ 4 copy rectfill
+ 0 setgray rectstroke
+ exch
+ /T .knownget {
+ gsave
+ 0 setgray
+ /Helvetica findfont 9 scalefont setfont
+ dup stringwidth pop
+ 2 index aload pop pop exch pop exch sub
+ exch sub 2 div 2 index aload pop 3 1 roll pop pop 11 sub 3 1 roll add exch moveto
+ show
+ grestore
+ } if
+ grestore
+ //false
+ } ifelse
+ } {
+ pop //false
+ }ifelse
+ } {
+ pop //false
+ }ifelse
+ } bdef
+
+currentdict /quadpoints2basis undef
currentdict end readonly def
+/.PDFDrawAnnotType?
+{
+ //false exch
+ /ShowAnnotTypes where
+ {
+ /ShowAnnotTypes get
+ {
+ dup /* eq exch 2 index eq or
+ {
+ pop //true exch
+ exit
+ } if
+ } forall
+ pop
+ }
+ {pop pop //true}
+ ifelse
+} bind def
+
/drawannot { % <annot> drawannot -
dup annotvisible {
gsave
dup dup /Subtype knownoget {
- //drawannottypes exch .knownget { exec } { //true } ifelse
+ dup //.PDFDrawAnnotType? exec
{
- dup calc_annot_scale 2 copy mul 0 ne
- {
- 3 -1 roll drawwidget
- }
+ //drawannottypes exch .knownget { exec } { //true } ifelse
{
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }ifelse % Draw rejected annots as widgets
- } if % type known
+ dup calc_annot_scale 2 copy mul 0 ne
+ {
+ 3 -1 roll drawwidget
+ }
+ {
+ ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ }ifelse % Draw rejected annots as widgets
+ } if % type known
+ }
+ {
+ pop
+ }ifelse
} {
pop
( **** Error: Ignoring /Annot dict without required /Subtype entry.\n)
@@ -3909,17 +4247,22 @@ currentdict end readonly def
dup annotvisible {
gsave
dup dup /Subtype knownoget {
- //preserveannottypes exch .knownget { exec } { //true } ifelse
+ dup //.PDFDrawAnnotType? exec
{
- dup calc_annot_scale 2 copy mul 0 ne
- {
- 3 -1 roll drawwidget
- }
+ //preserveannottypes exch .knownget { exec } { //true } ifelse
{
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }ifelse % Draw rejected annots as widgets
- } if % type known
+ dup calc_annot_scale 2 copy mul 0 ne
+ {
+ 3 -1 roll drawwidget
+ }
+ {
+ ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ }ifelse % Draw rejected annots as widgets
+ } if
+ }
+ {pop} ifelse
+ % type known
} {
pop
( **** Error: Ignoring /Annot dict without required /Subtype entry.\n)
@@ -3931,6 +4274,7 @@ currentdict end readonly def
} bdef
currentdict /preserveannottypes undef
+currentdict /.PDFDrawAnnotType? undef
% ============================ AcroForm fields ============================ %
@@ -4013,8 +4357,8 @@ currentdict /preserveannottypes undef
{ 1 index exch write== } forall
dup 3 index /MaxLen pget not { 0 } if write=
dup 3 index /V pget not {
- 3 index /DV pget not { () } if write==
- } if
+ 3 index /DV pget not { () } if
+ } if write==
dup 3 index /Ff pget not { 0 } if write=
dup 3 index /Q pget not { 0 } if write=
dup (Tform ET) write=
@@ -4026,7 +4370,51 @@ currentdict /preserveannottypes undef
} bdef
/Ch {
- (Ch is not yet implemened) //== exec
+ dup /AP known 3 index /NeedAppearances knownoget not { //true } if not and {
+ dup 1 1 3 -1 roll drawwidget
+ } {
+ %% If we don't have a NeedApperances, treat as true, because Acrobat
+ %% always regenerates Appearances anyway.
+ 2 index /NeedAppearances knownoget not { //true } if {
+ dup /AP << /N 10 dict dup cvx begin >> put
+ /Subtype /Form def
+ /BBox [ 0 0 4 index /Rect oget { oforce } forall 3 -1 roll sub abs 3 1 roll sub abs exch ] def
+ /Resources 3 index /DR pget not { 0 dict } if def
+ /File 1000 string dup 3 1 roll def
+ /Length 1000 def
+ % <acroform> <field> <annot> (string)
+ /NullEncode filter % <acroform> <field> <annot> file
+
+ dup (BT ) writestring
+ 2 index /DA pget not { () } if
+ [ exch
+ { token {
+ dup /Tf eq {
+ 2 index 0 eq {
+ /BBox load 3 get
+ 0.75 mul % empirical constant
+ 4 -1 roll pop 3 1 roll
+ } if
+ } if
+ exch
+ } {
+ exit
+ } ifelse
+ } loop
+ ]
+ { 1 index exch write== } forall
+ dup 3 index /MaxLen pget not { 0 } if write=
+ dup 3 index /V pget not {
+ 3 index /DV pget not { () } if
+ } if write==
+ dup 3 index /Ff pget not { 0 } if write=
+ dup 3 index /Q pget not { 0 } if write=
+ dup (Tform ET) write=
+ end
+ closefile % <acroform> <field> <annot>
+ dup 1 1 3 -1 roll drawwidget
+ } if
+ } ifelse
} bdef
/Sig {
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps
index 7060dbce6f0..02a3b0f6602 100644
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps
@@ -268,7 +268,6 @@ currentdict /known_symbolic_fonts undef
/getfontmetrics { % <font-resource> <font> <Encoding|null> getfontmetrics
% <font-resource> <font> <Encoding|null>
% <Metrics|null> <GlyphMap|null>
-
2 index /Widths oknown {
dup //null eq { pop dup /Encoding get } if
7 dict begin
@@ -871,7 +870,9 @@ setglobal
{
0 1 2 index length 1 sub
{
- dup 2 index exch get dup 0 gt % We ignore entries of zero in the widths array
+ dup 2 index exch get
+ dup type /packedarraytype eq {exec} if % Handle entries which are indirect references (seriously ? !!)
+ dup 0 gt % We ignore entries of zero in the widths array
{
exch 5 index add % add FirstChar to the idx to get a char code
dup 64 gt 1 index 91 lt and % we only want to consider A~Z and....
@@ -986,48 +987,62 @@ setglobal
.dicttomark readonly def
% When Type 1 font reading procedure is executing, a copy of this dictionary is current.
-% We have to do something special about embedded fonts that execute definefont
-% more than once -- that is the function of topFontDict.
+% topFontDict allows us to *attempt* to handle the case where a Type 1 font definition
+% does not start by creating it's own dictionary (i.e. a number of the keys end up in
+% the currentdict rather than the font dictionary).
% The whole type1 stream can be executed directly. There's no need to process
% Length1, 2, 3 keys.
/readtype1dict 10 dict dup begin
- /definefont {
- exch pop
+ /prev_definefont /definefont load def
- /topFontDict where {
- { /FontType % in PLRM order
- /FontMatrix
- /FontName
- /FontInfo
- /WMode
- /Encoding
- /FontBBox
- /UniqueID
- /XUID
- /PaintType
- /StrokeWidth
- /Metrics
- /Metrics2
- /CDevProc
- /CharStrings
- /Private
- /WeightVector
- } {
- 2 copy .knownget {
- % Stack: font topFontDict /key val
- 3 index 3 1 roll put
+ /definefont {
+ % if a font defines any keys outside it's own dictionary,
+ % this attempts to cope by copying them into the font dictionary
+ [
+ /FontType % in PLRM order
+ /FontMatrix
+ /FontName
+ /FontInfo
+ /WMode
+ /Encoding
+ /FontBBox
+ /UniqueID
+ /XUID
+ /PaintType
+ /StrokeWidth
+ /Metrics
+ /Metrics2
+ /CDevProc
+ /CharStrings
+ /Private
+ /WeightVector
+ ]
+ {
+ 2 copy known
+ {pop}
+ {
+ dup where
+ {
+ 1 index get
+ 2 index
+ 3 1 roll put
dup /MisplacedKey 0 put
- } {
- pop
- } ifelse
- } forall
- /MisplacedKey known {
- ( **** Warning: Type 1 font defines some of the keys in the external scope.\n)
- pdfformatwarning
- } if
+ }
+ {pop} ifelse
+ } ifelse
+ } forall
+ dup /MisplacedKey known {
+ ( **** Warning: Type 1 font defines some required keys outside the font dictionary.\n)
+ pdfformatwarning
} if
+ dup /CharStrings get /.notdef known not {
+ dup /CharStrings get
+ /.notdef <9E35CED7FFD3622F09> put
+ ( **** Warning: Type 1 font has no /.notdef entry in /CharString dictionary.\n)
+ pdfformatwarning
+ } if
dup /UniqueID .knownget {
dup dup 0 lt exch 16#ffffff gt or {
( **** Warning: Ignoring invalid /UniqueID = ) exch =string cvs
@@ -1037,17 +1052,11 @@ setglobal
pop
} ifelse
} if
- dup /CharStrings get /.notdef known not {
- dup /CharStrings get
- /.notdef <9E35CED7FFD3622F09> put
- ( **** Warning: Type 1 font has no /.notdef entry in /CharString dictionary.\n)
- pdfformatwarning
- } if
- .completefont
+ prev_definefont
} bdef
/undef_proc_warning {
- /Repaired //true store % flag that we have warnings
+ /Repaired //true store % flag that we have warnings
UndefProcList exch 2 copy .knownget { 1 add } { 1 } ifelse put
} bdef
@@ -1182,18 +1191,48 @@ currentdict /eexec_pdf_param_dict .undef
% the character code to access the Widths.
/BuildChar {
% Stack: font charcode
- 1 index begin 3 dict begin
+ 1 index begin 4 dict begin
/Font 3 -1 roll def /CharCode 1 index def
Encoding exch get CharProcs exch knownoget {
- { //false resolvestream
+ dup /Length get 0 eq {
+ pop
+ %% Detect a 0 length stream. If this occurs
+ %% then we won't execute d0 or d1, and so won't adjust the
+ %% character width. So, pretend we got a
+ %% null d1, just so that we can adjust using the /Widths
+ %% (Bug 697805)
+ 0 0 0 0 0 0
+ pdfopdict /d1 get exec
+ }{
+ { //false resolvestream
% Stack: filepos stream
% Don't let setgcolor set the color inside the BuildGlyph
% procedure, because this causes an /undefined error.
- q //null /FillColor gput //null /StrokeColor gput
- Font /Resources get exch pdfopdict .pdfruncontext
- Q
- } PDFfile fileposition 2 .execn % Keep pdfcount valid.
- PDFfile exch setfileposition
+ q
+ %% This is (currently) needed to make sure that the current dictionary, which is
+ %% 'nodict' because we did a gsave, is writeable. If we don't execute gput
+ %% to make a writeable copy then it is a no access dicitonary and the 'def'
+ %% below will fail. It would be nice to fix the cases of this someday, but
+ %% we use 'nodict'[ to store other PDF state stuff that isn't gstate, and we
+ %% probably always will, so it may well be more trouble than its worth.
+ /Dummy false gput
+ Font /Resources get exch pdfopdict
+ /BuildCharDictDepth countdictstack def
+ .pdfruncontext
+ countdictstack BuildCharDictDepth sub
+ {
+ pdfdict /.Qqwarning_issued .knownget {not}{//true} ifelse
+ {
+ (\n **** Warning: Type 3 glyph has unbalanced q/Q operators \(too many q's\)\n Output may be incorrect.\n)
+ pdfformatwarning
+ pdfdict /.Qqwarning_issued //true .forceput
+ } if
+ Q
+ } repeat
+ Q
+ } PDFfile fileposition 2 .execn % Keep pdfcount valid.
+ PDFfile exch setfileposition
+ } ifelse
} {
% PDF Type 3 fonts don't use .notdef
% d1 implementation adjusts the width as needed
@@ -2282,12 +2321,7 @@ currentdict /bndef undef
% in multipage documents.
/patch_font_XUID % <font dict> <patch> patch_font_XUID <font dict'>
{
- %% Allow users to specify that we should not care about font object numbers
- %% that is, don't patch the XUID with the object number and filename.
- /PDFDontUseFontObjectNum where {/PDFDontUseFontObjectNum get}{//false}ifelse
- %% Do not modify the XUID if we don't have an object number (see above)
- 1 index //null eq
- or
+ dup //null eq
{pop}
{
pdfdict /InputPDFFileName .knownget {.CRCHashFilenameAndObject} if
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps
index 85b5848e160..a16f5806734 100644
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps
@@ -85,6 +85,9 @@ pdfdict begin
pdfformaterror
( Output may be incorrect.\n) pdfformaterror
} bind
+
+ /Recursive_XObject_D 1 dict def
+
.dicttomark readonly def
% ======================== Main program ======================== %
@@ -948,9 +951,17 @@ currentdict /xref-char-dict undef
%% Bug #695883 the test file has an XRefStm which points beyond the end of the file.
%% We check that here and simply fall back to thje classic xref if this error occurs.
dup PDFfilelen lt{
- readpdf15xref pop
+ PDFSTOPONERROR not {
+ mark exch {readpdf15xref pop} stopped
+ {
+ ( **** Error: This hybrid file's XRefStm does not point to a valid stream.\n Ignoring error, output may be incorrect.\n) pdfformaterror
+ } if
+ cleartomark
+ } {
+ readpdf15xref pop
+ } ifelse
} {
- ( **** Error: This hybrid file's XRefStm points beyond the end of file.\n Ignoring error, output may be incorrect.\n) pdfformaterror
+ ( **** Error: This hybrid file's XRefStm points beyond the end of file.\n Ignoring error, output may be incorrect.\n) pdfformaterror
pop
}ifelse
} if
@@ -1129,7 +1140,37 @@ currentdict /xref-char-dict undef
( **** ) stderrprint stderrprint
} ifelse
} ifelse
- } if
+ } {
+ % If the user told us to use a named OutputIntent
+ systemdict /UseOutputIntent .knownget {
+ cvn
+ Trailer /Root oget /OutputIntents knownoget {
+ {
+ dup /OutputConditionIdentifier get cvn
+ dup /Custom eq {
+ pop
+ dup /Info get cvn
+ }if
+ 2 index eq {
+ %% Found the required OutputIntent
+ /DestOutputProfile knownoget {
+ [ /ICCBased 3 -1 roll ] ICCBased-resolve
+ 1 get .set_outputintent
+ ()
+ } if
+ pop
+ exit
+ }{
+ pop
+ } ifelse
+ }
+ forall
+ pop
+ }{
+ pop
+ }ifelse
+ } if
+ }ifelse
Trailer /Root knownoget { /PageLabels knownoget {
%% Currenlty only the pdfwrite device can handle PageLabels
%% because we deal with these using putparams, not pdfmarks
@@ -1283,6 +1324,8 @@ currentdict /xref-char-dict undef
% Read any previous cross-reference tables. When we are done,
% verify that the entries in the xref tables are valid if NoVerifyXref
% is not defined.
+ /PrevArray [] def % Empty array, we use this to detect circular /Prev entries in xref (see below)
+ % For some reqason, leaving this on the stack messes up seom files.
Trailer
{ /Prev knownoget not { % If no previous xref table then ...
Classic-xref {
@@ -1290,10 +1333,43 @@ currentdict /xref-char-dict undef
} if
exit
} if
+
+ %% This code is used to detect circular references in xref tables. Every time
+ %% we detect a /Prev in the xref, we check the given offset of the /Prev xref
+ %% against a list of all previously encountered /Prev offsets. If we find that
+ %% we have previously seen this one, we raise an error, stop processing the xref
+ %% but carry on with the PDF file (unless PDFSTOPONERROR is true).
+ //false exch PrevArray %% Used to determine if the looop found a circular ref
+ { %% //false offset 'array entry'
+ 1 index eq {
+ exch pop //true exch %% We've seen this offset before, pop the false and replace with true
+ exit %% //true offset
+ } if
+ } forall
+
+ exch %% [...] offset bool
+ {
+ (\n **** Error: Circular /Prev entry while reading xref.\n Aborting xref read, output may be incorrect.\n)
+ pdfformaterror
+ PDFSTOPONERROR {
+ /readxref /syntaxerror cvx signalerror
+ } if
+ pop exit %% [...] and then exit this loop
+ } if
+
+ PrevArray dup %% offset [...] [...]
+ length 1 add array %% offset [...] [ ]
+ dup 3 1 roll %% offset [ ] [...] [ ]
+ copy pop %% offset [... ]
+ dup dup length 1 sub %% offset [... ] [... ] index
+ 3 index %% offset [... ] [... ] index offset
+ put /PrevArray exch def
+
{ readxref }
PDFSTOPONERROR not {
.internalstopped {
recover_xref_data % Read failed. Attempt to recover xref data.
+ /PrevArray where {/PrevArray undef} if %% remove the array we were using to detect circular references
exit % Exit loop since recover gets all obj data.
} if % If readxref stopped
} {
@@ -1312,6 +1388,7 @@ currentdict /xref-char-dict undef
} ifelse
} forall
} loop % Loop to previous trailer
+ /PrevArray where {/PrevArray undef} if %% remove the array we were using to detect circular references
} if
/NumObjects Objects length def % To check that obj# < NumObjects
@@ -1584,10 +1661,32 @@ currentdict /xref-char-dict undef
{
2 copy knownoget
{ exch pop exch pop //true }
- { exch /Parent knownoget
- { exch pget }
+ {
+ %% Check to see if there's a Parent
+ 1 index
+ 3 1 roll
+ exch /Parent knownoget
+ {
+ %% If there is a Parent, check to see if this dictionary has a stored object number
+ 3 -1 roll /.gs.pdfobj# .knownget {
+ %% if it does, check the Parent as wwell
+ 1 index /.gs.pdfobj# .knownget {
+ %% Both have object numbers, are they the same (ie its self-referencing)
+ eq {
+ pop pop
+ //false
+ }{
+ exch pget
+ }ifelse
+ }{
+ pop exch pget
+ }ifelse
+ } {
+ exch pget
+ }ifelse
+ }
% finally see if the key is (misplaced) in the Root Catalog dict
- { dup Trailer /Root oget exch knownoget dup {
+ { exch pop dup Trailer /Root oget exch knownoget dup {
3 -1 roll ( **** Error: The /) pdfformaterror 50 string cvs pdfformaterror
( key is missing from the Page tree.\n) pdfformaterror
( Output may be incorrect.\n) pdfformaterror
@@ -1600,6 +1699,30 @@ currentdict /xref-char-dict undef
ifelse
} bind def
+/obj_get {
+ LocalResources 1 index knownoget {
+ dup 4 index known {
+ 3 index get
+ 0 get 4 1 roll pop pop pop
+ } if
+ } {
+ 1 index /Resources pget {
+ 1 index knownoget {
+ dup 4 index known {
+ 3 index get
+ 0 get 4 1 roll pop pop pop
+ }{
+ pop pop pop 0
+ }ifelse
+ }{
+ pop pop pop 0
+ } ifelse
+ } {
+ pop pop pop 0
+ }ifelse
+ }ifelse
+}bind def
+
% Get the value of a resource on a given page.
/rget { % <resname> <pagedict> <restype> rget <value> -true-
% <resname> <pagedict> <restype> rget -false-
@@ -2109,14 +2232,61 @@ end readonly def
/MediaBox exch get_media_box pop
} {
oforce_elems % <<pdict>> /SomeBox x0 y0 x1 y1
+ %% Complicated stuff. We need to use the 'Box' we identified (if any), but we
+ %% need to clamp the boundaries of the 'Box' to the MediaBox. This appears to
+ %% be what Acrobat does. The complication arises because the Box values don't
+ %% have to be sensibly positive, its permissible to have the MediaBox set up
+ %% so that it extends down and left instead of up and right. We take care of the
+ %% content when we st up the CTM, but we do need to make sure that we clamp
+ %% the BoundingBox, and that means we need to take direcitonality into account...
+
6 -1 roll get_media_box { % /SomeBox x0 y0 x1 y1 [MediaBox]
aload pop % /SomeBox x0 y0 x1 y1 X0 Y0 X1 Y1
- 5 -1 roll .min exch % /SomeBox x0 y0 x1 X0 Y0 mY1 X1
- 5 -1 roll .min exch % /SomeBox x0 y0 X0 Y0 mX1 mY1
- 4 2 roll % /SomeBox x0 y0 mX1 mY1 X0 Y0
- 5 -1 roll .max exch % /SomeBox x0 mX1 mY1 mY0 X0
- 5 -1 roll .max exch % /SomeBox mX1 mY1 mX0 mY0
- 4 2 roll % /SomeBox mX0 mY0 mX1 mY1
+
+ %% Start with the width, get the X0 and X1 values of the MediaBox
+ 3 index % /SomeBox x0 y0 x1 y1 X0 Y0 X1 Y1 X0
+ 2 index % /SomeBox x0 y0 x1 y1 X0 Y0 X1 Y1 X0 X1
+ gt {
+ %% Media extends to left
+ 4 -1 roll % /SomeBox x0 y0 x1 y1 Y0 X1 Y1 X0
+ 8 -1 roll % /SomeBox y0 x1 y1 Y0 X1 Y1 X0 x0
+ .min % /SomeBox y0 x1 y1 Y0 X1 Y1 mX0
+ 7 1 roll % /SomeBox mX0 y0 x1 y1 Y0 X1 Y1
+ exch % /SomeBox mX0 y0 x1 y1 Y0 Y1 X1
+ 5 -1 roll % /SomeBox mX0 y0 y1 Y0 Y1 X1 x1
+ .max % /SomeBox mX0 y0 y1 Y0 Y1 mX1
+ 5 1 roll % /SomeBox mX0 mX1 y0 y1 Y0 Y1
+ }{
+ %% Media extends to right
+ 4 -1 roll % /SomeBox x0 y0 x1 y1 Y0 X1 Y1 X0
+ 8 -1 roll % /SomeBox y0 x1 y1 Y0 X1 Y1 X0 x0
+ .max % /SomeBox y0 x1 y1 Y0 X1 Y1 mX0
+ 7 1 roll % /SomeBox mX0 y0 x1 y1 Y0 X1 Y1
+ exch % /SomeBox mX0 y0 x1 y1 Y0 Y1 X1
+ 5 -1 roll % /SomeBox mX0 y0 y1 Y0 Y1 X1 x1
+ .min % /SomeBox mX0 y0 y1 Y0 Y1 mX1
+ 5 1 roll % /SomeBox mX0 mX1 y0 y1 Y0 Y1
+ } ifelse
+
+ %% Now deal with the height
+ 2 copy % /SomeBox mX0 mX1 y0 y1 Y0 Y1 Y0 Y1
+ gt {
+ %% Media extends down
+ exch % /SomeBox mX0 mX1 y0 y1 Y1 Y0
+ 4 -1 roll % /SomeBox mX0 mX1 y1 Y1 Y0 y0
+ .min % /SomeBox mX0 mX1 y1 Y1 mY0
+ 3 1 roll % /SomeBox mX0 mX1 mY0 y1 Y1
+ .max % /SomeBox mX0 mX1 mY0 mY1
+ }{
+ %% Media extends up
+ exch % /SomeBox mX0 mX1 y0 y1 Y1 Y0
+ 4 -1 roll % /SomeBox mX0 mX1 y1 Y1 Y0 y0
+ .max % /SomeBox mX0 mX1 y1 Y1 mY0
+ 3 1 roll % /SomeBox mX0 mX1 mY0 y1 Y1
+ .min % /SomeBox mX0 mX1 mY0 mY1
+ } ifelse
+ exch % /SomeBox mX0 mX1 mY1 mY0
+ 3 1 roll % /SomeBox mX0 mY0 mX1 mY1
} {
pop
} ifelse
@@ -2268,6 +2438,37 @@ currentdict /PDF2PS_matrix_key undef
% is not actually used on the page.
currentpagedevice /PageSpotColors known { /PageSpotColors 2 index countspotcolors def } if
+ % If the user told us to use a named OutputIntent
+ systemdict /UseOutputIntent .knownget {
+ cvn
+ % Check to see if this page has such an OutputIntent
+ 2 index /OutputIntents knownoget {
+ {
+ dup /OutputConditionIdentifier get cvn
+ dup /Custom eq {
+ pop
+ dup /Info get cvn
+ }if
+ 2 index eq {
+ %% Found the required OutputIntent
+ /DestOutputProfile knownoget {
+ [ /ICCBased 3 -1 roll ] ICCBased-resolve
+ 1 get .set_outputintent
+ ()
+ } if
+ pop
+ exit
+ }{
+ pop
+ } ifelse
+ }
+ forall
+ pop
+ }{
+ pop
+ }ifelse
+ } if
+
% Let the device know if we will be using PDF 1.4 transparency.
% The clist logic may need to adjust the size of bands.
1 index pageusestransparency /PageUsesTransparency exch def
@@ -2541,7 +2742,22 @@ currentdict /PDF2PS_matrix_key undef
} {
dup //false exch {
4 dict 1 index resourceusestransparency { pop not exit } if
- /Parent knownoget not { exit } if
+ %% Check the current dictionary and its Parent (if any) to see
+ %% if they both have stored object numbers. If they do then
+ %% check the numbers, don't allow self-references.
+ dup /Parent knownoget not { pop exit }
+ {
+ exch /.gs.pdfobj# .knownget
+ {
+ 1 index /.gs.pdfobj# .knownget {
+ eq {
+ pop exit
+ }if
+ }{
+ pop
+ }ifelse
+ }if
+ } ifelse
} loop
% Also check for transparency in the annotation (if not in resources).
{ pop //true } { annotsusetransparency } ifelse
@@ -2884,74 +3100,87 @@ currentdict /PDF2PS_matrix_key undef
} if
} bind def
-%%<Objectdict> <calling obj_num> pdfform_detect_cspacesub <boolean>
+%% <loopdict> <Objectdict> <calling obj_num> pdfform_detect_cspacesub <boolean>
%%
/pdf_object_detect_cspacesub {
- exch %% <calling obj_num> <Objectdict>
- dup pdf_colorspace_detect_cspacesub {
- pop //true
- }{ %% <calling obj_num> <Objectdict>
- /Resources knownoget { %% <calling obj_num> <Resourcesdict>
- /XObject knownoget { %% <calling obj_num> <XObjectdict>
- //false exch %% <calling obj_num> <XObjectdict> false
- %% We have files where the XObject Resource is not a dictionary
- dup type /dicttype eq { %% <calling obj_num> <XObjectdict> false
-
- %% check each Xobject entry in the dictionary,
- %% forall purs a key/value pair on the stack for us.
- %%
- { %% <calling obj_num> <XObjectdict> false key value
- exch pop %% <calling obj_num> <XObjectdict> false value
-
- %% If this is an indirect reference, check if its the smae object
- %% as the current one. If its not indirect, make the object number 0
- %% for comparison purposes.
- dup type /packedarraytype eq {
- dup 0 get dup 4 index
- eq
- } {
- 0 false
- }ifelse
+ %% use loop operator for an exitable context
+ %% we need this to detect recursion/looping
+ {
+ exch %% <loopdict> <calling obj_num> <Objectdict>
+ dup pdf_colorspace_detect_cspacesub {
+ pop pop //true exit
+ }{ %% <loopdict> <calling obj_num> <Objectdict>
+ /Resources knownoget { %% <loopdict> <calling obj_num> <Resourcesdict>
+ 2 index 1 index known {
+ %% We've already seen this object, ignore it and exit
+ pop pop //false exit
+ }{
+ 2 index 1 index //null put
+ } ifelse
- %% <calling obj_num> <XObjectdict> false value <form object or 0 if not indirect> <boolean>
- not {
- %% swap object number and value, and dereference value
- exch oforce
- %% Apparently we have files where the content of the XObject Resource dictionary is null
- dup //null ne {
- %% and files where the indivudal XObjects are not dictionaries
- dup type /dicttype eq {
- dup /Subtype get /Form eq {
- exch
- pdf_object_detect_cspacesub {
- pop //true exit
- } if
- } {
+ /XObject knownoget { %% <loopdict> <calling obj_num> <XObjectdict>
+ //false exch %% <loopdict> <calling obj_num> <XObjectdict> false
+ %% We have files where the XObject Resource is not a dictionary
+ dup type /dicttype eq { %% <loopdict> <calling obj_num> <XObjectdict> false
+
+ %% check each Xobject entry in the dictionary,
+ %% forall purs a key/value pair on the stack for us.
+ %%
+ { %% <loopdict> <calling obj_num> <XObjectdict> false key value
+ exch pop %% <loopdict> <calling obj_num> <XObjectdict> false value
+
+ %% If this is an indirect reference, check if its the smae object
+ %% as the current one. If its not indirect, make the object number 0
+ %% for comparison purposes.
+ dup type /packedarraytype eq {
+ dup 0 get dup 4 index
+ eq
+ } {
+ 0 false
+ }ifelse
+
+ %% <calling obj_num> <XObjectdict> false value <form object or 0 if not indirect> <boolean>
+ not {
+ %% swap object number and value, and dereference value
+ exch oforce
+ %% Apparently we have files where the content of the XObject Resource dictionary is null
+ dup //null ne {
+ %% and files where the indivudal XObjects are not dictionaries
+ dup type /dicttype eq {
+ dup /Subtype get /Form eq {
+ exch
+ 4 index 3 1 roll pdf_object_detect_cspacesub {
+ pop //true exit
+ } if
+ } {
+ pop pop
+ }ifelse
+ }{
pop pop
- }ifelse
+ } ifelse
}{
pop pop
- } ifelse
+ }
+ ifelse
}{
pop pop
- }
- ifelse
- }{
- pop pop
- } ifelse
- } forall
- }{
- pop
+ } ifelse
+ } forall
+ }{
+ pop
+ }ifelse
+ } {
+ %% No forms, so can't be any Default* spaces
+ //false
}ifelse
} {
- %% No forms, so can't be any Default* spaces
//false
- }ifelse
- } {
- //false
+ } ifelse
} ifelse
- } ifelse
- %% Remove the calling object ID, return our boolean
+ %% Remove the calling object ID, return our boolean
+ exch pop exit
+ } loop
+ %% remove and discard the loopdict
exch pop
} bind def
@@ -2966,12 +3195,11 @@ currentdict /PDF2PS_matrix_key undef
% not using UseCIEColor with pdfwrite.
%
/pdfshowpage_detect_cspacesub {
- dup 0 pdf_object_detect_cspacesub
+ dup 0 1 dict 3 1 roll pdf_object_detect_cspacesub
/HighLevelDevice /GetDeviceParam .special_op {
exch pop not exch pop
}if
-
} bind def
%
@@ -3110,3 +3338,36 @@ currentdict /PDF2PS_matrix_key undef
end % pdfdict
.setglobal
+
+DELAYBIND not {
+%% This list of operators are used internally by various parts of the Ghostscript PDF interpreter.
+%% Since each operator is a potential security vulnerability, and any operator listed here
+%% is not required once the initislisation is complete and functions are bound, we undefine
+%% the ones that aren't needed at runtime.
+[
+/.pdfawidthshow /.pdfwidthshow
+/.setfillcolor /.setfillcolorspace /.setstrokecolor /.setstrokecolorspace /.currentrenderingintent /.setrenderingintent
+/.currenttextrenderingmode /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading
+/.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling
+/.settextlinematrix /.currenttextlinematrix /.currenttextmatrix /.settextmatrix /.currentblendmode
+/.currentopacityalpha /.currentshapealpha /.currenttextknockout
+/.pushextendedgstate /.popextendedgstate /.begintransparencytextgroup
+/.endtransparencytextgroup /.begintransparencymaskgroup /.begintransparencymaskimage /.endtransparencymask /.image3x
+/.abortpdf14devicefilter /.pdfinkpath /.pdfFormName /.setstrokeconstantalpha
+/.setfillconstantalpha /.setalphaisshape /.currentalphaisshape
+/.settextspacing /.currenttextspacing /.settextleading /.currenttextleading /.settextrise /.currenttextrise
+/.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling
+
+% Used by our own test suite files
+%/.pushpdf14devicefilter % transparency-example.ps
+%/.poppdf14devicefilter % transparency-example.ps
+%/.setopacityalpha % transparency-example.ps
+%/.setshapealpha % transparency-example.ps
+%/.endtransparencygroup % transparency-example.ps
+
+% undefining these causes errors/incorrect output
+%/.settextrenderingmode /.setblendmode /.begintransparencygroup /.settextknockout /check_r6_password /.setstrokeoverprint /.setfilloverprint
+%/.currentstrokeoverprint /.currentfilloverprint /.currentfillconstantalpha /.currentstrokeconstantalpha
+]
+{systemdict exch .undef} forall
+} if
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps
index ba53b54cd7e..fabef68a90a 100644
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps
@@ -211,76 +211,69 @@ currentdict /gput_always_allow .undef
} ifelse
} bdef
-% Save most of graphic state attributes.
-% - get-gs-attrs ...
-/get-gs-attrs {
- currentsmoothness
- currentflat
- currentoverprint
- currentstrokeadjust
- currentdash
- currentmiterlimit
- currentlinejoin
- currentlinecap
- currentlinewidth
- currentfont
- currentcolor
- currentcolorspace
- { currentpoint } stopped
- matrix currentmatrix
-} bdef
-
-% Restore most of graphic state attributes.
-% ... get-gs-attrs -
-/set-gs-attrs {
- setmatrix
- { newpath } { moveto } ifelse
- setcolorspace
- setcolor
- setfont
- setlinewidth
- setlinecap
- setlinejoin
- setmiterlimit
- setdash
- setstrokeadjust
- setoverprint
- setflat
- setsmoothness
-} bdef
-
% ---------------- Color setting ---------------- %
-/fcput % <color> <colorspace> fcput -
- { /FillColorSpace gput /FillColor gput
- } bdef
-/scput % <color> <colorspace> scput -
- { /StrokeColorSpace gput /StrokeColor gput
- } bdef
-/csput % <colorspace> csput -
- { csset 2 copy fcput scput
- } bdef
-
-/csdevgray [/DeviceGray] readonly def
-/csdevrgb [/DeviceRGB] readonly def
-/csdevcmyk [/DeviceCMYK] readonly def
-/cspattern [/Pattern] readonly def
/nullpatternproc { pop } bdef
/nullpattern mark
/PatternType 1 /PaintType 1 /TilingType 3 /BBox [0 0 1 1]
/XStep 1 /YStep 1 /PaintProc //nullpatternproc
.dicttomark readonly def
-% Each entry in the color space dictionary is a procedure of the form
-% <cspace> -proc- <cspace> <initial-color>
+/PDFsetpattern {
+ % Since multiple patterns may share
+ % same data stream, we need to ensure
+ % that the stream is at 0 position.
+ % Making this consistently with resolveshading,
+ % which applies ReusableStreamDecode filter
+ % to the PS stream, which represents the
+ % PDF stream in dynamics.
+
+ dup /Shading knownoget {
+ dup /ShadingType oget 4 ge {
+ /DataSource knownoget {
+ dup type /filetype eq {
+ 0 setfileposition
+ } {
+ pop
+ } ifelse
+ } if
+ } {
+ pop
+ } ifelse
+ } if
+
+ % Associate pattern instance with the default qstate for the context.
+ % A single pattren object can be reused in several contexts.
+ dup DefaultQstate .knownget {
+ exch pop
+ } {
+ % But don't update read-only initial null pattern.
+ dup /PaintProc .knownget { //nullpatternproc ne } { //true } ifelse {
+ dup dup /Matrix knownoget not { { 1 0 0 1 0 0 } } if
+
+ gsave
+ .currentfillconstantalpha
+ .currentstrokeconstantalpha
+ DefaultQstate setqstate
+ .setstrokeconstantalpha
+ .setfillconstantalpha
+ makepattern
+ grestore
+
+ dup 3 1 roll
+ DefaultQstate exch put
+ } if
+ } ifelse
+} bdef
+
/CSdict mark
- /DeviceGray { pop //csdevgray 0 } bind
- /DeviceRGB { pop //csdevrgb [0 0 0] cvx } bind
- /DeviceCMYK { pop //csdevcmyk [0 0 0 1] cvx } bind
+ /DeviceGray { 0 } bind
+ /DeviceRGB { [0 0 0] cvx } bind
+ /DeviceCMYK { [0 0 0 1] cvx } bind
/CIEBasedA { 0 } bind
/CIEBasedABC { [0 0 0] cvx } bind
- /CalGray { pop //csdevgray 0 } bind
- /CalRGB { pop //csdevrgb [0 0 0] cvx } bind
+ /CalGray { pop /DeviceGray 0 } bind
+ /CalRGB { pop /DeviceRGB [0 0 0] cvx } bind
/Lab {[0 0 0] cvx } bind
/ICCBased { [ 1 index 1 oget /N get { 0 } repeat ] cvx } bind
/Separation { 1 } bind
@@ -288,91 +281,111 @@ currentdict /gput_always_allow .undef
[ 1 index 1 get length { 1 } repeat ] cvx
} bind
/Indexed { 0 } bind
- /Pattern {
- dup type /nametype eq 1 index length 1 eq or {
- pop //cspattern //nullpattern matrix makepattern
- } {
- //nullpattern matrix makepattern 1 index 1 get csset
- % Stack: patternspace nullpattern basecolor basespace
- pop [ 3 1 roll dup type /arraytype eq { aload pop } if
- counttomark -1 roll ] cvx
- } ifelse
- } bind
+ /Pattern { //nullpattern matrix makepattern } bind
.dicttomark readonly def
-/csset % <cspace> csset <color> <cspace>
- { dup dup type /nametype ne { 0 get } if //CSdict exch get exec exch
- } bdef
-/g { //csdevgray fcput } bdef
-/G { //csdevgray scput } bdef
-/rg { 3 array astore cvx //csdevrgb fcput } bdef
-/RG { 3 array astore cvx //csdevrgb scput } bdef
-/k { 4 array astore cvx //csdevcmyk fcput } bdef
-/K { 4 array astore cvx //csdevcmyk scput } bdef
-%%
-%% Bug #694412, we set the colour space immediately now. Previously we
-%% only set the colour space and colour when a stroke or fill took place.
-%% if that happened inside a gsave/grestore we could end up setting the
-%% same colour space many times, which is a problem if its an expensive
-%% space, like ICCBased.
-%%
-/cs { csset dup setgcolorspace fcput } bdef
-/CS { csset dup .swapcolors setgcolorspace .swapcolors scput } bdef
-/ri { //.renderingintentdict exch .knownget { .setrenderingintent } if } bdef
-% We have to break up sc according to the number of operands.
-%%
-%% Also Bug #694412, we need to set the actual colour in response to the
-%% PDF operators as well. However, the transparenmcy code also uses the
-%% original calls (sc, SC, sc1, SC1, sc* and SC*) and so we create
-%% a duplicate set which do the same as the originals, but se the current
-%% colour as well.
-%%
-/sc1_and_set { /FillColor gput FillColor FillColorSpace setgcolor} bdef
-/sc1 { /FillColor gput } bdef
-/SC1_and_set {/StrokeColor gput .swapcolors StrokeColor StrokeColorSpace setgcolor .swapcolors } bdef
-/SC1 { /StrokeColor gput } bdef
-% We have to avoid storing into a color array associated with an outer
-% gsave level, so we do a kind of "copy on write".
-/sc* {
- currentdict /FillColor .knownget {
- astore pop
- } {
- /FillColor load
- % FillColor may contain either a single value or an array.
- dup type /arraytype eq { length }{ pop 1 } ifelse
- array astore cvx /FillColor gput
- } ifelse
-} bdef
-/SC* {
- currentdict /StrokeColor .knownget {
- astore pop
- } {
- /StrokeColor load
- % StrokeColor may contain either a single value or an array.
- dup type /arraytype eq { length }{ pop 1 } ifelse
- array astore cvx /StrokeColor gput
- } ifelse
-} bdef
+/ri {//.renderingintentdict exch .knownget { .setrenderingintent } if } bdef
+/g {/DeviceGray .setfillcolorspace .setfillcolor } bdef
+/G {/DeviceGray .setstrokecolorspace .setstrokecolor} bdef
+/rg {/DeviceRGB .setfillcolorspace .setfillcolor} bdef
+/RG {/DeviceRGB .setstrokecolorspace .setstrokecolor} bdef
+/k {/DeviceCMYK .setfillcolorspace .setfillcolor} bdef
+/K {/DeviceCMYK .setstrokecolorspace .setstrokecolor} bdef
+/cs {dup dup type /nametype ne { 0 get } if //CSdict exch get exec exch .setfillcolorspace exec .setfillcolor} bdef
+/CS {dup dup type /nametype ne { 0 get } if //CSdict exch get exec exch .setstrokecolorspace exec .setstrokecolor} bdef
+/sc {.setfillcolor} bdef
+/SC {.setstrokecolor} bdef
+/sc* {.setfillcolor} bdef
+/SC* {.setstrokecolor} bdef
/sc*_and_set {
- sc*
- FillColor FillColorSpace setgcolor
+ dup type /dicttype eq
+ {
+ dup /Type known
+ {
+ dup /Type get /Pattern eq {PDFsetpattern} if
+ }
+ {
+ dup /PatternType known {PDFsetpattern} if
+ } ifelse
+ } if
+ .setfillcolor
} bdef
/SC*_and_set {
- SC*
- .swapcolors StrokeColor StrokeColorSpace setgcolor .swapcolors
+ dup type /dicttype eq
+ {
+ dup /Type known
+ {
+ dup /Type get /Pattern eq {PDFsetpattern} if
+ }
+ {
+ dup /PatternType known {PDFsetpattern} if
+ } ifelse
+ } if
+ .setstrokecolor
+} bdef
+/sc1 {.setfillcolor} bdef
+/SC1 {.setstrokecolor} bdef
+/sc1_and_set {
+ dup type /dicttype eq
+ {
+ dup /Type known
+ {
+ dup /Type get /Pattern eq {PDFsetpattern} if
+ }
+ {
+ dup /PatternType known {PDFsetpattern} if
+ } ifelse
+ } if
+ .setfillcolor
+} bdef
+/SC1_and_set {
+ dup type /dicttype eq
+ {
+ dup /Type known
+ {
+ dup /Type get /Pattern eq {PDFsetpattern} if
+ }
+ {
+ dup /PatternType known {PDFsetpattern} if
+ } ifelse
+ } if
+ .setstrokecolor
} bdef
+/csput {dup dup type /nametype ne { 0 get } if //CSdict exch get exec exch 2 copy .setfillcolorspace exec .setfillcolor .setstrokecolorspace exec .setstrokecolor} bdef
+/csset {dup dup type /nametype ne { 0 get } if //CSdict exch get exec exch} bdef
+
+% ---------------- Color setting ---------------- %
+
% ---------------- Overprint/transparency setting ---------------- %
-/op { /FillOverprint gput } bdef % NB pdf_draw:gsparamdict handled /OP with no /op
-/OP { /StrokeOverprint gput } bdef
+/op { .setfilloverprint
+} bdef % NB pdf_draw:gsparamdict handled /OP with no /op
+/OP { .setstrokeoverprint
+} bdef
/OPM {
/.setoverprintmode where { pop dup .setoverprintmode .swapcolors .setoverprintmode .swapcolors } { pop } ifelse
} bdef
-/ca { /FillConstantAlpha gput } bdef
-/CA { /StrokeConstantAlpha gput } bdef
-/SMask { /SoftMask gput } bdef
-/AIS { /AlphaIsShape gput } bdef
+/ca { .setfillconstantalpha } bdef
+/CA { .setstrokeconstantalpha } bdef
+/SMask {
+ dup type /booleantype eq {
+ .currentSMask type /dicttype eq {
+ .currentSMask /Processed 2 index .forceput
+ } {
+ .setSMask
+ }ifelse
+ }{
+ .setSMask
+ }ifelse
+
+ %% This is some craziness to do with annotations and graphics states
+ %% the original nodict can't be written to, and we haven't (I think) done
+ %% a gsave, so we haven't copied it to /self, if we don't do that here
+ %% then transparent annotations cause an invalid access error.
+ currentdict //nodict eq {/self dup load end 5 dict begin def} if
+} bdef
+/AIS { .setalphaisshape } bdef
/BM {
/.setblendmode where {
pop [ exch dup type /nametype ne { aload pop } if /Normal ] {
@@ -386,13 +399,19 @@ currentdict /gput_always_allow .undef
/.settextknockout where { pop .settextknockout } { pop } ifelse
} bdef
+/UseBlackPtComp {
+ %% Our implementation of black point compensation uses 0 or 1, not a boolean
+ /.setblackptcomp where {pop false eq {0}{1}ifelse .setblackptcomp }{ pop } ifelse
+} bdef
+
% ---------------- Color installation ---------------- %
% Establish a given color (and color space) as current.
/.settransparencyparams { % <alpha> <smask> .settransparencyparams -
PDFusingtransparency {
/.begintransparencygroup where {
- pop AlphaIsShape {
+ pop .currentalphaisshape
+ {
1 .setopacityalpha exch .setshapealpha 1
} {
1 .setshapealpha exch .setopacityalpha 0
@@ -415,23 +434,28 @@ currentdict /gput_always_allow .undef
dup /Draw get exec
} ifelse
} {
- dup /Draw get exec
+ dup /Processed .knownget {
+ {
+ pop pop
+ } {
+ dup /Draw get exec
+ }ifelse
+ }{
+ dup /Draw get exec
+ } ifelse
} ifelse
} bdef
% (Non-mask) images must execute setfillblend.
/setfillblend {
- FillOverprint setoverprint
- FillConstantAlpha SoftMask .settransparencyparams
+ .currentfillconstantalpha
+ .currentSMask .settransparencyparams
} def
/setfillstate {
- FillColor FillColorSpace setgcolor setfillblend
+ setfillblend
} def
-
/setstrokestate {
- .swapcolors
- StrokeColor StrokeColorSpace setgcolor StrokeOverprint setoverprint
- StrokeConstantAlpha SoftMask .settransparencyparams
- .swapcolors
+ .currentstrokeconstantalpha
+ .currentSMask .settransparencyparams
} def
/Cdict 15 dict dup begin % <color...> <colorspace> -proc- -
/DeviceGray { pop setgray } bdef
@@ -530,7 +554,16 @@ currentdict /gput_always_allow .undef
% But don't update read-only initial null pattern.
dup /PaintProc .knownget { //nullpatternproc ne } { //true } ifelse {
dup dup /Matrix knownoget not { { 1 0 0 1 0 0 } } if
- gsave DefaultQstate setqstate makepattern grestore
+
+ gsave
+ .currentfillconstantalpha
+ .currentstrokeconstantalpha
+ DefaultQstate setqstate
+ .setstrokeconstantalpha
+ .setfillconstantalpha
+ makepattern
+ grestore
+
dup 3 1 roll
DefaultQstate exch put
} if
@@ -582,8 +615,10 @@ end def
pop currentcolorspace 1 get % use the base space
} if
known {
- /stroke ne { FillOverprint } { StrokeOverprint } ifelse
- .currentblendmode dup /Normal eq exch /Compatible eq or not and
+ /stroke ne { .currentfilloverprint
+ } { .currentstrokeoverprint
+ } ifelse
+ .currentblendmode dup /Normal eq exch /Compatible eq or not and
} {
pop //false
} ifelse
@@ -592,23 +627,25 @@ end def
/fsexec % <fillop|strokeop> fsexec -
{
PDFusingtransparency {
- SoftMask //null ne {
+ .currentSMask //null ne {
mark /Subtype /Group /Isolated //true .dicttomark pathbbox .begintransparencygroup
+ .currentshapealpha .currentopacityalpha 3 -1 roll % avoid double application
+ 1 .setopacityalpha 1 .setshapealpha
} if
dup checkOPtrans exch 1 index {
% We need to push a non-isolated, non-knockout transparency group and
% perform the operation in CompatibleOverprint mode, then end the
% transparency group. Do the begintransparencygroup step here.
mark /Subtype /Group /Isolated //false .dicttomark pathbbox .begintransparencygroup
- exch .currentblendmode exch .currentopacityalpha exch 4 -1 roll % save current values
+ .currentblendmode .currentopacityalpha 4 -2 roll % save current values
/CompatibleOverprint .setblendmode 1 .setopacityalpha
} if
cvx exec
{
.endtransparencygroup .setopacityalpha .setblendmode % end the CompatibleOverprint group
} if
- SoftMask //null ne {
- .endtransparencygroup
+ .currentSMask //null ne {
+ .endtransparencygroup .setopacityalpha .setshapealpha
} if
} {
cvx exec
@@ -792,29 +829,72 @@ end def
% Clipping:
-/Wdict 4 dict dup begin
+/Wdict 8 dict dup begin
/S { OFFlevels length 0 eq { gsave setstrokestate .swapcolors stroke .swapcolors grestore } if n } bdef
/f { OFFlevels length 0 eq { gsave setfillstate fill grestore } if n } bdef
/f* { OFFlevels length 0 eq { gsave setfillstate eofill grestore } if n } bdef
+/B {
+ OFFlevels length 0 eq {
+ PDFusingtransparency {
+ % knockout trans group around the filled and stroked object
+ mark
+ /Isolated //true /Knockout //true
+ .dicttomark
+ % strokepath will return empty path (no currentpoint) if nothing is stroked
+ gsave {strokepath pathbbox } stopped grestore not
+ {
+ 1 .setopacityalpha
+ .begintransparencygroup
+ gsave setfillstate fill grestore
+ setstrokestate .swapcolors /stroke fsexec .swapcolors
+ .endtransparencygroup
+ } {
+ newpath pop
+ } ifelse
+ } {
+ gsave setfillstate fill grestore
+ setstrokestate .swapcolors /stroke fsexec .swapcolors
+ } ifelse
+ } if
+ n
+} bdef
+/b { closepath B } bdef
+/B* {
+ OFFlevels length 0 eq {
+ PDFusingtransparency {
+ % knockout trans group around the filled and stroked object
+ mark
+ /Isolated //true /Knockout //true
+ .dicttomark
+ % strokepath will return empty path (no currentpoint) if nothing is stroked
+ gsave {strokepath pathbbox} stopped grestore not {
+ 1 .setopacityalpha
+ .begintransparencygroup
+ gsave setfillstate eofill grestore
+ setstrokestate .swapcolors /stroke fsexec .swapcolors
+ .endtransparencygroup
+ } { newpath pop } ifelse
+ } {
+ gsave setfillstate eofill grestore
+ setstrokestate .swapcolors /stroke fsexec .swapcolors
+ } ifelse
+ } if
+ n
+} bdef
+/b { closepath B* } bdef
/n { end { currentpoint } stopped not { pop pop clip } if newpath } bdef
end readonly def
/W { //Wdict begin } bdef
-/W*dict 4 dict dup begin
+/W*dict 8 dict dup begin
Wdict { def } forall
/n { end { currentpoint } stopped not { pop pop eoclip } if newpath } bdef
end readonly def
/W* { //W*dict begin } bdef
-
% ---------------- Text control ---------------- %
/textbeginpage
- { /TextSpacing 0 def % 0 Tc
- /TextLeading 0 def % 0 TL
- /TextRenderingMode 0 def % 0 Tr
- /TextRise 0 def % 0 Ts
- /WordSpacing 0 def % 0 Tw
- /TextHScaling 1.0 def % 100 Tz
- /TextFont //null def
+ {
+ 1.0 .settexthscaling
/FontMatrixNonHV //false def
/Show { showfirst } def
/TextFillStateNeeded //true def
@@ -844,7 +924,8 @@ end readonly def
/settextmatrix {
matrix currentmatrix
- TextMatrix concat
+ matrix .currenttextmatrix
+ concat
TestDegenerateCTM {
(\n **** Error: Degenerate text matrix detected, ignoring Tm operation\n) pdfformaterror
( Output may be incorrect.\n) pdfformaterror
@@ -852,9 +933,11 @@ end readonly def
} {
pop
} ifelse
- TextHScaling 1 ne { TextHScaling 1 scale } if
- TextRise 0 ne { 0 TextRise translate } if
- TextFont dup //null eq { pop } { setfont } ifelse
+ .currenttexthscaling
+ 1 ne { .currenttexthscaling
+ 1 scale } if
+ .currenttextrise 0 ne { 0 .currenttextrise
+ translate } if
} bdef
/settextstate {
@@ -879,14 +962,22 @@ end readonly def
/settextposition {
% Update the TextMatrix translation.
gsave TextSaveMatrix setmatrix
- {currentpoint} stopped not { TextRise sub TextMatrix 4 2 getinterval astore pop
+ {currentpoint} stopped not {
+ .currenttextrise
+ sub
+ matrix .currenttextmatrix
+ dup 5 4 -1 roll put
+ dup 4 4 -1 roll put
+ .settextmatrix
% We would like to do "grestore currentpoint translate"
% here, but some PDF files set a singular text matrix
% (0 0 0 0 <x> <y> Tm), so we can't do this.
- TextTempMatrix identmatrix setmatrix currentpoint
- grestore
- TextTempMatrix currentmatrix 4 2 getinterval astore pop
- TextTempMatrix setmatrix
+ TextTempMatrix identmatrix setmatrix currentpoint
+ matrix .currenttextmatrix
+ grestore
+ .settextmatrix
+ TextTempMatrix currentmatrix 4 2 getinterval astore pop
+ TextTempMatrix setmatrix
} {
( **** Error: Invalid currentpoint, probable degenerate CTM.\n) pdfformaterror
( Ignroing error, output may be incorrect.\n) pdfformaterror
@@ -932,10 +1023,9 @@ end readonly def
currentdict end
/.W exch def
} if
- currentdict /TextLineMatrix .knownget
- { identmatrix pop TextMatrix identmatrix pop }
- { matrix /TextLineMatrix gput matrix /TextMatrix gput }
- ifelse
+ matrix .settextlinematrix
+ matrix .settextmatrix
+
{ showfirst } /Show gput
currentdict /TextSaveMatrix .knownget not {
matrix dup /TextSaveMatrix gput
@@ -957,7 +1047,7 @@ end readonly def
/ET_NO_TXT_KO {
currentdict /TextSaveMatrix known {
- TextRenderingMode 4 ge { .currentfilladjust 0 .setfilladjust clip .setfilladjust} if
+ .currenttextrenderingmode 4 ge { .currentfilladjust 0 .setfilladjust clip .setfilladjust} if
newpath TextSaveMatrix setmatrix
currentdict /TextSaveMatrix undef
@@ -988,11 +1078,11 @@ end readonly def
} if
} bdef
-/Tc { /TextSpacing gput { showfirst } /Show gput } bdef
-/TL { /TextLeading gput } bdef
-/Tr { dup .settextrenderingmode /TextRenderingMode gput { showfirst } /Show gput } bdef
-/Ts { /TextRise gput settextstate } bdef
-/Tw { /WordSpacing gput { showfirst } /Show gput } bdef
+/Tc { .settextspacing { showfirst } /Show gput } bdef
+/TL { .settextleading } bdef
+/Tr { .settextrenderingmode { showfirst } /Show gput } bdef
+/Ts { .settextrise settextstate } bdef
+/Tw { .setwordspacing { showfirst } /Show gput } bdef
/Tz {
dup 0 eq {
(\n **** Error: Invalid 0.0 horizontal text scaling given for Tz\n)
@@ -1001,7 +1091,8 @@ end readonly def
pop 0.00000001 % handle invalid scale by using a really small value
}{
100 div
- }ifelse /TextHScaling gput settextstate} bdef
+ }ifelse .settexthscaling %/TextHScaling gput
+ settextstate} bdef
% ---------------- Font control ---------------- %
@@ -1080,7 +1171,7 @@ end readonly def
} {
pop
} ifelse
- /TextFont gput settextstate
+ setfont
} bdef
% Copy a font, removing its FID. If changed is true, also remove
@@ -1210,11 +1301,17 @@ end readonly def
( Output may be incorrect.\n) pdfformaterror
pop 0
} if
- TextLineMatrix transform TextLineMatrix 4 2 getinterval astore pop
- TextLineMatrix TextMatrix copy pop settextstate
+ matrix .currenttextlinematrix transform
+ matrix .currenttextlinematrix
+ dup 3 -1 roll 5 exch put
+ dup 3 -1 roll 4 exch put
+ .settextlinematrix
+ matrix .currenttextlinematrix .settextmatrix
+
+ settextstate
} bdef
-/TD { dup neg /TextLeading gput Td } bdef
-/T* { 0 TextLeading neg Td } bdef
+/TD { dup neg .settextleading Td } bdef
+/T* { 0 .currenttextleading neg Td } bdef
/Tm {
5 index 0 ne 3 index 0 ne and
5 index 0 ne 5 index 0 ne and or not {
@@ -1226,7 +1323,9 @@ end readonly def
0.00000001 0 0 0.00000001
6 -2 roll
}if
- TextLineMatrix astore TextMatrix copy pop settextstate
+ matrix .currenttextlinematrix astore .settextlinematrix
+ matrix .currenttextlinematrix .settextmatrix
+ settextstate
} bdef
% ---------------- Text painting ---------------- %
@@ -1329,8 +1428,8 @@ end readonly def
//false
}ifelse
{
- TextRenderingMode 1 eq TextRenderingMode 2 eq or
- TextRenderingMode 5 eq TextRenderingMode 6 eq or or {
+ .currenttextrenderingmode 1 eq .currenttextrenderingmode 2 eq or
+ .currenttextrenderingmode 5 eq .currenttextrenderingmode 6 eq or or {
setstrokestate
% Need to set the stroke width to a value which gives the correct
% width under pdfwrite. Pdfwrite uses (in text mode) an identity
@@ -1360,7 +1459,7 @@ end readonly def
/TextTransSetup { % showarg path_valid TextTransSetup false showarg
% showarg path_valid false TextTransSetup prev_BM prev_opacity true showarg
% NB: if 'show' is used, then we use the clippath, but a smaller bbox is preferred
- SoftMask //null ne {
+ .currentSMask //null ne {
dup mark /Subtype /Group /Isolated //true .dicttomark exch
{ pathbbox } { gsave clippath pathbbox grestore } ifelse
.begintransparencygroup
@@ -1385,13 +1484,15 @@ end readonly def
.endtransparencygroup
OPsavedict dup /saveOA get .setopacityalpha /saveBM get .setblendmode
} if
- SoftMask //null ne {
+ .currentSMask //null ne {
.endtransparencygroup
} if
} bind def
/setshowstate
- { WordSpacing 0 eq TextSpacing 0 eq and FontMatrixNonHV not and
+ {
+ .currentwordspacing 0 eq .currenttextspacing
+ 0 eq and FontMatrixNonHV not and
{
% Check to see if the current device supports Tr
/PreserveTrMode /GetDeviceParam .special_op {
@@ -1400,16 +1501,16 @@ end readonly def
//false
}ifelse
{
- pdfwrite_textrenderingprocs TextRenderingMode get
+ pdfwrite_textrenderingprocs .currenttextrenderingmode get
}
{
- TextRenderingMode 0 eq
- currentfont /FontType get 3 eq TextRenderingMode 3 eq not
+ .currenttextrenderingmode 0 eq
+ currentfont /FontType get 3 eq .currenttextrenderingmode 3 eq not
and or
{
{ settextfillstate //false TextTransSetup show TextTransTeardown }
} {
- TextRenderingMode 3 eq {
+ .currenttextrenderingmode 3 eq {
% Some PDF files execute 'tm' with a singular matrix,
% and then use the text rendering mode 3.
% The graphics library currently cannot handle text
@@ -1437,7 +1538,7 @@ end readonly def
moveto
}
} {
- { //false charpath textrenderingprocs TextRenderingMode get exec }
+ { //false charpath textrenderingprocs .currenttextrenderingmode get exec }
} ifelse
} ifelse
} ifelse
@@ -1446,7 +1547,7 @@ end readonly def
% If we are doing a plain old fill, or no text at all, *or* we are going to
% a device supporting text rendering modes, then go through this route.
%
- TextRenderingMode 0 eq TextRenderingMode 3 eq or
+ .currenttextrenderingmode 0 eq .currenttextrenderingmode 3 eq or
currentfont /FontType get 3 eq or
/PreserveTrMode /GetDeviceParam .special_op {
@@ -1455,7 +1556,7 @@ end readonly def
//false
}ifelse
% pdfwrite can't handle rendering modes which involve clipping
- TextRenderingMode 4 lt and or
+ .currenttextrenderingmode 4 lt and or
% Tr was set to graphic state.
{
FontMatrixNonHV {
@@ -1464,7 +1565,7 @@ end readonly def
currentlinewidth exch
setstrokeforTrpreservation
settextfillstate //false TextTransSetup
- [ TextSpacing WordSpacing 3 index
+ [ .currenttextspacing .currentwordspacing 3 index
{ % str [... weach wword c undef|ythis xthis|undef
exch % will be removed, unless FontMatrix.xx/yy == 0 (FontMatrixNonHV already true)
Vexch pop % str [... weach wword c wthis
@@ -1480,20 +1581,23 @@ end readonly def
setlinewidth TextTransTeardown
}
} {
- WordSpacing 0 eq {
+ .currentwordspacing
+ 0 eq {
{
{ setstrokeforTrpreservation
- settextfillstate //false TextTransSetup TextSpacing 0 Vexch 3 -1 roll ashow TextTransTeardown
+ settextfillstate //false TextTransSetup .currenttextspacing
+ 0 Vexch 3 -1 roll ashow TextTransTeardown
}
currentlinewidth
{ setlinewidth }
3 .execn
}
} {
- TextSpacing 0 eq {
+ .currenttextspacing 0 eq {
{ % preserve current line width around possible stroke setup
{ setstrokeforTrpreservation
- settextfillstate //false TextTransSetup WordSpacing 0 Vexch 32 4 -1 roll .pdfwidthshow
+ settextfillstate //false TextTransSetup .currentwordspacing
+ 0 Vexch 32 4 -1 roll .pdfwidthshow
TextTransTeardown
}
currentlinewidth
@@ -1503,8 +1607,9 @@ end readonly def
} {
{ % preserve current line width around possible stroke setup
{ setstrokeforTrpreservation
- settextfillstate //false TextTransSetup WordSpacing 0 Vexch 32
- TextSpacing 0 Vexch 6 -1 roll .pdfawidthshow TextTransTeardown
+ settextfillstate //false TextTransSetup .currentwordspacing
+ 0 Vexch 32
+ .currenttextspacing 0 Vexch 6 -1 roll .pdfawidthshow TextTransTeardown
}
currentlinewidth
{ setlinewidth }
@@ -1516,7 +1621,8 @@ end readonly def
}
{
{ currentlinewidth exch
- WordSpacing TextSpacing
+ .currentwordspacing
+ .currenttextspacing
% Implement the combination of t3 and false charpath.
% Note that we must use cshow for this, because we
% can't parse multi-byte strings any other way.
@@ -1543,7 +1649,7 @@ end readonly def
% or we wouldn't be here. Subtract 4 from the Tr and preserve
% that mode, then do a charpath so the clip path gets set up
% correctly.
- gsave TextRenderingMode 4 sub .settextrenderingmode
+ gsave .currenttextrenderingmode 4 sub .settextrenderingmode
setstrokeforTrpreservation
setstrokestate settextfillstate //false TextTransSetup dup show grestore TextTransTeardown } if
//false charpath
@@ -1569,7 +1675,7 @@ end readonly def
}{
//true
}ifelse {
- textrenderingprocs TextRenderingMode get exec
+ textrenderingprocs .currenttextrenderingmode get exec
} if
setlinewidth
}
@@ -1588,9 +1694,7 @@ end readonly def
OFFlevels length 0 eq {
exec
} {
- gsave get-gs-attrs nulldevice set-gs-attrs
- exec
- get-gs-attrs grestore set-gs-attrs
+ gsave nulldevice exec grestore
} ifelse
//true /TextFillStateNeeded gput
} bdef
@@ -1610,9 +1714,7 @@ end readonly def
OFFlevels length 0 eq {
exec
} {
- gsave get-gs-attrs nulldevice set-gs-attrs
- exec
- get-gs-attrs grestore set-gs-attrs
+ gsave nulldevice exec grestore
} ifelse
//true /TextFillStateNeeded gput
} bdef
@@ -1741,9 +1843,13 @@ end readonly def
2 0 moveto % start at bottom left of rect
counttomark 1 1 3 -1 roll { % for every string
pop gsave
- <FEFF> anchorsearch {
- pop
- } if
+ <EFBBBF> anchorsearch {
+ pop
+ } {
+ <FEFF> anchorsearch {
+ pop
+ } if
+ } ifelse
Show grestore % pop loop counter, show string (saving current point)
counttomark 1 add index 0 exch rmoveto % get line height, move that amount vertically.
} for
@@ -1755,9 +1861,13 @@ end readonly def
2 0 moveto % start at bottom left of rect
counttomark 1 1 3 -1 roll { % for every string
pop gsave % pop loop counter
- <FEFF> anchorsearch {
- pop
- } if
+ <EFBBBF> anchorsearch {
+ pop
+ } {
+ <FEFF> anchorsearch {
+ pop
+ } if
+ } ifelse
dup stringwidth pop counttomark 5 add index % get rectangle width
exch sub 2 div 0 rmoveto % subtract width of string, divide by 2 move that amount
Show grestore % show string
@@ -1770,9 +1880,13 @@ end readonly def
2 0 moveto % start at bottom left of rect
counttomark 1 1 3 -1 roll { % for every string
pop gsave % pop loop counter
- <FEFF> anchorsearch {
+ <EFBBBF> anchorsearch {
pop
- } if
+ } {
+ <FEFF> anchorsearch {
+ pop
+ } if
+ } ifelse
dup stringwidth pop counttomark 5 add index % get rectangle width
exch sub 2 sub 0 rmoveto % subtract width of string,move that amount
Show grestore % show string
@@ -1790,9 +1904,13 @@ end readonly def
0 exch moveto % MaxLen (V) Ff Q dx
1 index 0 ne {
3 index
- <FEFF> anchorsearch {
- pop
- } if
+ <EFBBBF> anchorsearch {
+ pop
+ } {
+ <FEFF> anchorsearch {
+ pop
+ } if
+ } ifelse
stringwidth pop % MaxLen (V) Ff Q dx w
sub exch 1 eq { 2 div } { 2 sub } ifelse % MaxLen (V) Ff (dx-w)/2
0 rmoveto % MaxLen (V) Ff
@@ -1802,9 +1920,13 @@ end readonly def
2 0 rmoveto
} ifelse
exch pop
- <FEFF> anchorsearch {
+ <EFBBBF> anchorsearch {
pop
- } if
+ } {
+ <FEFF> anchorsearch {
+ pop
+ } if
+ } ifelse
Show % -
} ifelse
} ifelse
diff --git a/Master/tlpkg/tlgs/bin/gsdll32.dll b/Master/tlpkg/tlgs/bin/gsdll32.dll
index 33790e4d0f9..16681d74f1b 100755
--- a/Master/tlpkg/tlgs/bin/gsdll32.dll
+++ b/Master/tlpkg/tlgs/bin/gsdll32.dll
Binary files differ
diff --git a/Master/tlpkg/tlgs/bin/gsdll32.lib b/Master/tlpkg/tlgs/bin/gsdll32.lib
index 90b1b74bb9f..40ea8d94934 100644
--- a/Master/tlpkg/tlgs/bin/gsdll32.lib
+++ b/Master/tlpkg/tlgs/bin/gsdll32.lib
Binary files differ
diff --git a/Master/tlpkg/tlgs/bin/gswin32.exe b/Master/tlpkg/tlgs/bin/gswin32.exe
index 30c5552dd9a..f34ad66378f 100755
--- a/Master/tlpkg/tlgs/bin/gswin32.exe
+++ b/Master/tlpkg/tlgs/bin/gswin32.exe
Binary files differ
diff --git a/Master/tlpkg/tlgs/bin/gswin32c.exe b/Master/tlpkg/tlgs/bin/gswin32c.exe
index a3739bd4cc7..cf0e655ce2b 100755
--- a/Master/tlpkg/tlgs/bin/gswin32c.exe
+++ b/Master/tlpkg/tlgs/bin/gswin32c.exe
Binary files differ
diff --git a/Master/tlpkg/tlgs/iccprofiles/default_cmyk.icc b/Master/tlpkg/tlgs/iccprofiles/default_cmyk.icc
index 00d4ae0e042..fce61bf2bcb 100644
--- a/Master/tlpkg/tlgs/iccprofiles/default_cmyk.icc
+++ b/Master/tlpkg/tlgs/iccprofiles/default_cmyk.icc
Binary files differ
diff --git a/Master/tlpkg/tlgs/iccprofiles/default_rgb.icc b/Master/tlpkg/tlgs/iccprofiles/default_rgb.icc
index 627e8feb0ec..055997234cc 100644
--- a/Master/tlpkg/tlgs/iccprofiles/default_rgb.icc
+++ b/Master/tlpkg/tlgs/iccprofiles/default_rgb.icc
Binary files differ
diff --git a/Master/tlpkg/tlgs/iccprofiles/gray_to_k.icc b/Master/tlpkg/tlgs/iccprofiles/gray_to_k.icc
index bb52dd937e9..c9f585d2660 100644
--- a/Master/tlpkg/tlgs/iccprofiles/gray_to_k.icc
+++ b/Master/tlpkg/tlgs/iccprofiles/gray_to_k.icc
Binary files differ
diff --git a/Master/tlpkg/tlgs/iccprofiles/lab.icc b/Master/tlpkg/tlgs/iccprofiles/lab.icc
index cd34beb967b..df5c56c127b 100644
--- a/Master/tlpkg/tlgs/iccprofiles/lab.icc
+++ b/Master/tlpkg/tlgs/iccprofiles/lab.icc
Binary files differ
diff --git a/Master/tlpkg/tlgs/iccprofiles/ps_cmyk.icc b/Master/tlpkg/tlgs/iccprofiles/ps_cmyk.icc
index 3c35d710587..ebb0dc0a2eb 100644
--- a/Master/tlpkg/tlgs/iccprofiles/ps_cmyk.icc
+++ b/Master/tlpkg/tlgs/iccprofiles/ps_cmyk.icc
Binary files differ
diff --git a/Master/tlpkg/tlgs/iccprofiles/ps_gray.icc b/Master/tlpkg/tlgs/iccprofiles/ps_gray.icc
index e670a2fb16c..00e65458878 100644
--- a/Master/tlpkg/tlgs/iccprofiles/ps_gray.icc
+++ b/Master/tlpkg/tlgs/iccprofiles/ps_gray.icc
Binary files differ
diff --git a/Master/tlpkg/tlgs/iccprofiles/ps_rgb.icc b/Master/tlpkg/tlgs/iccprofiles/ps_rgb.icc
index 645542ceed9..1bbaaf539e9 100644
--- a/Master/tlpkg/tlgs/iccprofiles/ps_rgb.icc
+++ b/Master/tlpkg/tlgs/iccprofiles/ps_rgb.icc
Binary files differ
diff --git a/Master/tlpkg/tlgs/iccprofiles/srgb.icc b/Master/tlpkg/tlgs/iccprofiles/srgb.icc
index 627e8feb0ec..055997234cc 100644
--- a/Master/tlpkg/tlgs/iccprofiles/srgb.icc
+++ b/Master/tlpkg/tlgs/iccprofiles/srgb.icc
Binary files differ
diff --git a/Master/tlpkg/tlgs/lib/addxchar.ps b/Master/tlpkg/tlgs/lib/addxchar.ps
deleted file mode 100644
index d9027d6046c..00000000000
--- a/Master/tlpkg/tlgs/lib/addxchar.ps
+++ /dev/null
@@ -1,356 +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.
-%
-
-% Add the Central European and other Adobe extended Latin characters to a
-% Type 1 font.
-% Requires -dWRITESYSTEMDICT to disable access protection.
-
-(type1ops.ps) runlibfile
-
-% ---------------- Utilities ---------------- %
-
-/addce_dict 50 dict def
-addce_dict begin
-
-% Define the added copyright notice.
-/addednotice (. Portions Copyright (C) 2012 Artifex Software Inc.) def
-
-% Open a font for modification by removing the FID and changing the
-% FontName. Removing UniqueID and XUID is not necessary, since we
-% will only be adding characters.
-/openfont { % <name> <font> openfont <name> <font'>
- dup length dict copy
- dup /FID undef
- dup /FontName 3 index put
-} def
-
-% Do the equivalent of false charpath for a glyph.
-% This should really be an operator!
-/glyphpath { % <glyph> glyphpath -
- currentfont /Encoding get 0 3 -1 roll put
- <00> false charpath
-} def
-
-% Do the equivalent of charpath + pathbbox for a glyph.
-/glyphbbox { % <glyph> glyphbbox <llx> <lly> <urx> <ury>
- % We cache this value, because it's expensive to compute.
- BBoxes 1 index .knownget {
- exch pop
- } {
- gsave newpath 0 0 moveto dup glyphpath [pathbbox] grestore
- BBoxes 3 -1 roll 2 index put
- } ifelse aload pop
-} def
-
-% Get the side bearing and width for a glyph.
-/glyphsbw { % <glyph> glyphsbw <lsbx> <wx>
- % We cache this value, because it's expensive to compute.
- SBW 1 index .knownget {
- exch pop
- } {
- dup glyphcs { dup /hsbw eq { pop exit } if } forall
- 2 array astore
- SBW 3 -1 roll 2 index put
- } ifelse aload pop
-} def
-
-% Get the CharString for a glyph, as an array.
-/glyphcs { % <glyph> glyphcs <array>
- CharStrings exch get
- 4330 exch dup length string .type1decrypt exch pop
- dup length lenIV sub lenIV exch getinterval
- 0 () /SubFileDecode filter [ exch charstack_read ]
-} def
-
-% Find an occurrence of a value in an array.
-/asearch { % <array> <value> asearch <index> true
- % <array> <value> asearch false
- false 0 4 2 roll exch {
- % Stack: false index value element
- 2 copy eq { pop pop exch not exch dup exit } if
- exch 1 add exch
- } forall pop pop
-} def
-
-% Convert an array back to a CharString.
-/csdef { % <glyph> <array> csdef -
- charproc_string
- 4330 exch dup .type1encrypt exch pop readonly
- CharStrings 3 1 roll put
-} def
-
-% Split an accented character name.
-/splitaccented { % <Baccent> splitaccented <Baccent> <B> <accent>
- dup =string cvs
- dup 0 1 getinterval cvn
- exch dup length 1 sub 1 exch getinterval cvn
-} def
-
-% Begin the definition of a 'seac' character.
-% Defines accent, base, abox, bbox.
-% The initial dx lines up the origins of the base and the accent.
-/beginseac { % <bchar> <achar> beginseac
- % -mark- <lsbx> <wx> /hsbw <asb> <dx>
- /accent exch def /base exch def
- /abox [accent glyphbbox] def
- /bbox [base glyphbbox] def
- [ base glyphsbw /hsbw accent glyphsbw pop
- dup 4 index sub
-} def
-
-% Center the accent over the base of a 'seac' character.
-/centeraccent { % <dx> centeraccent <adx>
- bbox 2 get bbox 0 get add 2 div
- abox 2 get abox 0 get add 2 div
- sub add
-} def
-
-% Finish the definition of a 'seac' character.
-/finishseac { % <charname> -mark- ... <adx> <ady> finishseac -
- exch cvi exch cvi
- charindex base get charindex accent get /seac ] csdef
-} def
-
-% ---------------- Main program ---------------- %
-
-% Define accented characters that can be made with seac,
-% with the accent centered over the character.
-/seacchars [
- /Abreve /Amacron
- /Cacute /Ccaron /Dcaron
- /Ecaron /Edotaccent /Emacron
- /Gbreve
- /Idotaccent /Imacron
- /Lacute
- /Nacute /Ncaron
- /Ohungarumlaut /Omacron
- /Racute /Rcaron
- /Sacute /Scedilla
- /Tcaron
- /Uhungarumlaut /Umacron /Uogonek /Uring
- /Zacute /Zdotaccent
- /abreve /amacron
- /cacute /ccaron
- /ecaron /edotaccent /emacron
- /gbreve
- /lacute
- /nacute /ncaron
- /ohungarumlaut /omacron
- /racute /rcaron
- /sacute /scedilla
- /uhungarumlaut /umacron /uring
- /zacute /zdotaccent
-] def
-
-% Define seac characters where the accent lines up with the right
-% edge of the character.
-/seacrightchars [
- /Aogonek /Eogonek /Iogonek /aogonek /eogonek /iogonek /uogonek
-] def
-
-% Define seac characters where the caron becomes an appended quoteright.
-/seaccaronchars [
- /dcaron /lcaron /tcaron
-] def
-
-% Define seac characters using commaaccent.
-/seaccommachars [
- /Gcommaaccent /Kcommaaccent /Lcommaaccent /Ncommaaccent /Rcommaaccent
- /Scommaaccent /Tcommaaccent
- /gcommaaccent /kcommaaccent /lcommaaccent /ncommaaccent /rcommaaccent
- /scommaaccent /tcommaaccent
-] def
-
-% Define the characters copied from the Symbol font.
-/symbolchars [
- /Delta /greaterequal /lessequal /lozenge /notequal /partialdiff
- /summation
-] def
-
-% Define the procedures for editing the commaaccent character.
-% Delete all the hints, since it's too hard to adjust them.
-/caedit mark
- /rmoveto { exch commatop sub cvi exch }
- /hstem { pop pop pop }
- /vstem 1 index
- /callothersubr {
- dup 3 eq { 4 { pop } repeat /skip true def } if
- }
- /pop { skip { pop /skip false def } if }
-.dicttomark def
-
-/addce { % <name> <font> addce <font'>
- 20 dict begin
- /origfont 1 index def
- openfont
- dup /CharStrings 2 copy get dup length dict copy put
- dup /Encoding 2 copy get dup length array copy put
- dup /FontInfo 2 copy get dup length dict copy put
- definefont /font exch def
- currentdict font end begin begin
- font 1000 scalefont setfont
- /symbolfont /Symbol findfont def
- /BBoxes CharStrings length dict def
- /SBW CharStrings length dict def
-
- /italfactor FontInfo /ItalicAngle .knownget {
- neg dup sin exch cos div
- } {
- 0
- } ifelse def
-
- % Invert the Encoding (needed for seac).
-
- /charindex 256 dict def
- 0 1 255 {
- charindex exch Encoding 1 index get exch put
- } for
-
- % Add the commaaccent character, by moving the comma downward.
-
- /comma glyphbbox /commatop exch def pop pop pop
- /comma glyphcs
- /skip false def
- [ exch { caedit 1 index .knownget { exec } if } forall ]
- /commaaccent exch csdef
-
- % Add the accented characters that can be made with seac.
-
- seacchars {
- splitaccented beginseac
- centeraccent
- % If the accent would collide with the base character,
- % raise it a little.
- abox 1 get bbox 3 get sub dup 0 le {
- % ... but not if the accent is in the low position.
- abox 1 get 0 gt {
- neg 60 add
- % Adjust the X position if italic.
- dup italfactor mul 3 -1 roll add exch
- } {
- pop 0
- } ifelse
- } {
- pop 0
- } ifelse
- finishseac
- } forall
-
- seacrightchars {
- splitaccented beginseac
- bbox 2 get abox 2 get sub add % line up right edges
- 0 finishseac
- } forall
-
- /dcroat /d /hyphen beginseac
- bbox 2 get abox 2 get sub add % line up right edges
- 0 finishseac
-
- /imacron /dotlessi /macron beginseac
- centeraccent
- 0 finishseac
-
- /Lcaron /L /quoteright beginseac
- bbox 2 get abox 2 get sub add % line up right edges
- 0 finishseac
-
- seaccaronchars {
- dup =string cvs 0 1 getinterval cvn /quoteright beginseac
- % Move the quote to the right of the character.
- bbox 2 get abox 0 get sub 50 add add
- % Adjust the character width as well.
- 4 -1 roll abox 2 get abox 0 get sub 50 add add cvi 4 1 roll
- 0 finishseac
- } forall
-
- seaccommachars {
- dup =string cvs 0 1 getinterval cvn /comma beginseac
- centeraccent
- commatop neg
- % Lower the accent if the character extends below
- % the baseline
- bbox 1 get 0 .min add
- finishseac
- } forall
-
- % Add the characters from the Symbol font.
- % We should scale them to match the FontBBox, but we don't.
-
- symbolchars {
- symbolfont /CharStrings get 1 index get
- CharStrings 3 1 roll put
- } forall
-
- % Add the one remaining character.
-
- CharStrings /Dcroat CharStrings /Eth get put
-
- % Recompute the FontBBox, since some of the accented characters
- % may have enlarged it.
-
- /llx 1000 def /lly 1000 def /urx 0 def /ury 0 def
- CharStrings {
- pop glyphbbox
- ury .max /ury exch def urx .max /urx exch def
- lly .min /lly exch def llx .min /llx exch def
- } forall
- /FontBBox llx cvi lly cvi urx ceiling cvi ury ceiling cvi 4 packedarray def
-
- % Restore the Encoding and wrap up.
-
- [/Copyright /Notice] {
- FontInfo 1 index .knownget {
- addednotice concatstrings FontInfo 3 1 roll put
- } {
- pop
- } ifelse
- } forall
- FontName font openfont
- dup /Encoding origfont /Encoding get put
- definefont
-
- end end
-} def
-
-currentdict end readonly pop % addce_dict
-
-/addce { addce_dict begin addce end } def
-
-% ---------------- Integration ---------------- %
-
-% We would like to patch the font loader so that it adds the extended
-% Latin characters automatically. We haven't done this yet.
-
-% ---------------- Test program ---------------- %
-
-/TEST where { pop TEST } { false } ifelse {
- /FONT where { pop } { /FONT /Palatino-Italic def } ifelse
- (unprot.ps) runlibfile
- unprot
- (wrfont.ps) runlibfile
- wrfont_dict begin
- /eexec_encrypt true def
- /binary_CharStrings true def
- end
- save
- FONT findfont
- /Latin-CE exch addce setfont
- (t.ce.pfb) (w) file dup writefont closefile
- restore
- (prfont.ps) runlibfile
- (t.ce.pfb) (r) file .loadfont
- /Latin-CE DoFont
- quit
-} if
diff --git a/Master/tlpkg/tlgs/lib/decrypt.ps b/Master/tlpkg/tlgs/lib/decrypt.ps
deleted file mode 100644
index 92249182885..00000000000
--- a/Master/tlpkg/tlgs/lib/decrypt.ps
+++ /dev/null
@@ -1,14 +0,0 @@
-%!
-% Decrypt an eexec-encoded file.
-
-(t.in) (r) file /in exch def
-(t.out) (w) file /out exch def
-256 string /buf exch def
-55665 % eexec encryption seed
- { in buf readhexstring /more exch def
- dup .type1decrypt out exch writestring
- more not { exit } if
- } loop
-in closefile
-out closefile
-quit
diff --git a/Master/tlpkg/tlgs/lib/font2c.ps b/Master/tlpkg/tlgs/lib/font2c.ps
deleted file mode 100644
index dffc24745e0..00000000000
--- a/Master/tlpkg/tlgs/lib/font2c.ps
+++ /dev/null
@@ -1,674 +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.
-%
-
-% font2c.ps
-% Write out a PostScript Type 0 or Type 1 font as C code
-% that can be linked with the interpreter.
-% This even works on protected fonts, if you use the -dWRITESYSTEMDICT
-% switch in the command line. The code is reentrant and location-
-% independent and has no external references, so it can be put into
-% a sharable library even on VMS.
-
-/font2cdict 100 dict dup begin
-
-% Define the maximum string length that all compilers will accept.
-% This must be approximately
-% min(max line length, max string literal length) / 4 - 5.
-
-/max_wcs 50 def
-
-% Define a temporary file for writing out procedures.
-/wtempname (_.tmp) def
-
-% ------ Protection utilities ------ %
-
-% Protection values are represented by a mask:
-/a_noaccess 0 def
-/a_executeonly 1 def
-/a_readonly 3 def
-/a_all 7 def
-/prot_names
- [ (0) (a_execute) null (a_readonly) null null null (a_all)
- ] def
-/prot_opers
- [ {noaccess} {executeonly} {} {readonly} {} {} {} {}
- ] def
-
-% Get the protection of an object.
- /getpa
- { dup wcheck
- { pop a_all }
- { % Check for executeonly or noaccess objects in protected.
- dup protected exch known
- { protected exch get }
- { pop a_readonly }
- ifelse
- }
- ifelse
- } bind def
-
-% Get the protection appropriate for (all the) values in a dictionary.
- /getva
- { a_noaccess exch
- { exch pop
- dup type dup /stringtype eq 1 index /arraytype eq or
- exch /packedarraytype eq or
- { getpa a_readonly and or }
- { pop pop a_all exit }
- ifelse
- }
- forall
- } bind def
-
-% Keep track of executeonly and noaccess objects,
-% but don't let the protection actually take effect.
-.currentglobal
-false .setglobal % so protected can reference local objs
-/protected % do first so // will work
- systemdict wcheck { 1500 dict } { 1 dict } ifelse
-def
-systemdict wcheck not
- { (Warning: you will not be able to convert protected fonts.\n) print
- (If you need to convert a protected font, please\n) print
- (restart the program and specify the -dWRITESYSTEMDICT switch.\n) print
- flush
- (%end) .skipeof
- }
-if
-userdict begin
- /executeonly
- { dup //protected exch //a_executeonly put readonly
- } bind def
- /noaccess
- { dup //protected exch //a_noaccess put readonly
- } bind def
-end
-true .setglobal
-systemdict begin
- /executeonly
- { userdict /executeonly get exec
- } bind odef
- /noaccess
- { userdict /noaccess get exec
- } bind odef
-end
-%end
-.setglobal
-
-% ------ Output utilities ------ %
-
-% By convention, the output file is named cfile.
-
-% Define some utilities for writing the output file.
- /wtstring 100 string def
- /wb {cfile exch write} bind def
- /ws {cfile exch writestring} bind def
- /wl {ws (\n) ws} bind def
- /wt {wtstring cvs ws} bind def
-
-% Write a C string. Some compilers have unreasonably small limits on
-% the length of a string literal or the length of a line, so every place
-% that uses wcs must either know that the string is short,
-% or be prepared to use wcca instead.
- /wbx
- { 8#1000 add 8 (0000) cvrs dup 0 (\\) 0 get put ws
- } bind def
- /wcst
- [
- 32 { /wbx load } repeat
- 95 { /wb load } repeat
- 129 { /wbx load } repeat
- ] def
- ("\\) { wcst exch { (\\) ws wb } put } forall
- /wcs
- { (") ws { dup wcst exch get exec } forall (") ws
- } bind def
- /can_wcs % Test if can use wcs
- { length max_wcs le
- } bind def
- /wncs % name -> C string
- { wtstring cvs wcs
- } bind def
-% Write a C string as an array of character values.
-% We only need this because of line and literal length limitations.
- /wca % <string> <prefix> <suffix> wca -
- { 0 4 -2 roll exch
- { % Stack: suffix n prefix char
- exch ws
- exch dup 19 ge { () wl pop 0 } if 1 add
- exch dup 32 ge 1 index 126 le and
- { 39 wb dup 39 eq 1 index 92 eq or { 92 wb } if wb 39 wb }
- { wt }
- ifelse (,)
- } forall
- pop pop ws
- } bind def
- /wcca % <string> wcca -
- { ({\n) (}) wca
- } bind def
-
-% Write object protection attributes. Note that dictionaries and arrays are
-% the only objects that can be writable.
- /wpa
- { dup xcheck { (a_executable|) ws } if
- dup type dup /dicttype eq exch /arraytype eq or
- { getpa }
- { getpa a_readonly and }
- ifelse prot_names exch get ws
- } bind def
- /wva
- { getva prot_names exch get ws
- } bind def
-
-% ------ Object writing ------ %
-
- /wnstring 128 string def
-
-% Convert an object to a string to be scanned at a later time.
- /cvos % <obj> cvos <string>
- { % We'd like to use == and write directly to a string,
- % but we can't do the former because of operators,
- % and we can't do the latter because we can't predict
- % how long the string would have to be....
- wtempname (w) file dup 3 -1 roll wproc closefile
- wtempname status pop pop pop exch pop string
- wtempname (r) file dup 3 -1 roll readstring pop exch closefile
- } bind def
-
-% Write a string/name or null as an element of a string/name/null array.
-% Convert any other kind of value to a token to be read back in.
- /wsn
- { dup null eq
- { pop (\t255,255,) wl
- }
- { dup type /nametype eq { wnstring cvs } if
- dup type /stringtype ne { cvos (255,) ws } if
- dup length 256 idiv wt (,) ws
- dup length 256 mod wt
- (,) (,\n) wca
- }
- ifelse
- } bind def
-% Write a packed string/name/null array.
- /wsna % <name> <(string|name|null)*> wsna -
- { (\tstatic const unsigned char ) ws exch wt ([] = {) wl
- { wsn } forall
- (\t0\n};) wl
- } bind def
-
-% Write a number or an array of numbers, as refs.
-/isnumber
- { type dup /integertype eq exch /realtype eq or
- } bind def
-/wnums
- { dup isnumber
- { (real_v\() ws wt (\),) ws }
- { { wnums } forall }
- ifelse
- } bind def
-
-% Test whether a procedure or unusual array can be written (printed).
-/iswx 4 dict dup begin
- /arraytype { { iswproc } isall } def
- /nametype { pop true } def
- /operatortype { pop true } def % assume it has been bound in
- /packedarraytype /arraytype load def
-end def
-/iswnx 6 dict dup begin
- /arraytype { { iswproc } isall } def
- /integertype { pop true } def
- /nametype { pop true } def
- /realtype { pop true } def
- /stringtype { pop true } def
- /packedarraytype /arraytype load def
-end def
-/iswproc % <obj> iswproc <bool>
- { dup xcheck { iswx } { iswnx } ifelse
- 1 index type .knownget { exec } { pop false } ifelse
- } bind def
-
-% Write a printable procedure (one for which iswproc returns true).
-/wproca 3 dict dup begin
- /arraytype
- { 1 index ({) writestring
- { 1 index ( ) writestring 1 index exch wproc } forall
- (}) writestring
- } bind def
- /packedarraytype /arraytype load def
- /operatortype { .writecvs } bind def % assume binding would work
-end def
-/wproc % <file> <proc> wproc -
- { dup type wproca exch .knownget { exec } { write==only } ifelse
- } bind def
-
-% Write a named object. Return true if this was possible.
-% Legal types are: boolean, integer, name, real, string,
-% array of (integer, integer+real, name, null+string),
-% and certain procedures and other arrays (see iswproc above).
-% All other objects are either handled specially or ignored.
- /isall % <array> <proc> isall <bool>
- { true 3 -1 roll
- { 2 index exec not { pop false exit } if }
- forall exch pop
- } bind def
- /wott 8 dict dup begin
- /arraytype
- { woatt
- { aload pop 2 index 2 index exec
- { exch pop exec exit }
- { pop pop }
- ifelse
- }
- forall
- } bind def
- /booleantype
- { { (\tmake_true\(&) } { (\tmake_false\(&) } ifelse ws
- wt (\);) wl true
- } bind def
- /integertype
- { (\tmake_int\(&) ws exch wt (, ) ws
- wt (\);) wl true
- } bind def
- /nametype
- { (\tcode = (*pprocs->name_create)\(i_ctx_p, &) ws exch wt
- (, ) ws wnstring cvs wcs % OK, names are short
- (\);) wl
- (\tif ( code < 0 ) return code;) wl
- true
- } bind def
- /packedarraytype
- /arraytype load def
- /realtype
- { (\tmake_real\(&) ws exch wt (, (float)) ws
- wt (\);) wl true
- } bind def
- /stringtype
- { ({\tstatic const unsigned char s_[] = ) ws
- dup dup can_wcs { wcs } { wcca } ifelse
- (;) wl
- (\tmake_const_string\(&) ws exch wt
- (, a_readonly, ) ws length wt (, (const byte *)s_\);) wl
- (}) wl true
- } bind def
- end def
-% Write some other kind of object, if known.
- /wother
- { dup otherobjs exch known
- { otherobjs exch get (\t) ws exch wt ( = ) ws wt (;) wl true }
- { pop pop false }
- ifelse
- } bind def
-% Top-level procedure.
- /wo % name obj -> OK
- { dup type wott exch .knownget { exec } { wother } ifelse
- } bind def
-
-% Write an array (called by wo).
- /wap % <name> <array> wap -
- { dup xcheck not 1 index wcheck not and 1 index rcheck and
- { pop pop }
- { (\tr_set_attrs\(&) ws exch wt (, ) ws wpa (\);) wl }
- ifelse
- } bind def
- /wnuma { % <name> <array> <element_C_type> <<type>_v> wnuma -
- ({\tstatic const ref_\() ws exch ws (\) a_[] = {) wl exch
- % Stack: name type_v array
- dup length 0 eq {
- (\t) ws 1 index ws (\(0\)) wl
- } {
- dup {
- (\t) ws 2 index ws (\() ws wt (\),) wl
- } forall
- } ifelse exch pop
- % Stack: name array
- (\t};) wl
- dup wcheck {
- (\tcode = (*pprocs->scalar_array_create)\(i_ctx_p, &) ws exch wt
- (, (const ref *)a_, ) ws dup length wt
- (, ) ws wpa (\);) wl
- (\tif ( code < 0 ) return code;) wl
- } {
- (\tmake_const_array\(&) ws exch wt
- (, avm_foreign|) ws dup wpa (, ) ws length wt
- (, (const ref *)a_\);) wl
- } ifelse
- (}) wl
- } bind def
- /woatt [
- % Integers
- { { { type /integertype eq } isall }
- { (long) (integer_v) wnuma true }
- }
- % Integers + reals
- { { { type dup /integertype eq exch /realtype eq or } isall }
- { (float) (real_v) wnuma true }
- }
- % Strings + nulls
- { { { type dup /nulltype eq exch /stringtype eq or } isall }
- { ({) ws dup (sa_) exch wsna
- (\tcode = (*pprocs->string_array_create)\(i_ctx_p, &) ws exch wt
- (, \(const char *\)sa_, ) ws dup length wt (, ) ws wpa (\);) wl
- (\tif ( code < 0 ) return code;) wl
- (}) wl true
- }
- }
- % Names
- { { { type /nametype eq } isall }
- { ({) ws dup (na_) exch wsna
- (\tcode = (*pprocs->name_array_create)\(i_ctx_p, &) ws 1 index wt
- (, \(const char *\)na_, ) ws dup length wt (\);) wl
- (\tif ( code < 0 ) return code;) wl
- wap (}) wl true
- }
- }
- % Procedure
- { { iswproc }
- { dup cvos
- % Stack: name proc string
- ({\tstatic const unsigned char s_[] = ) ws
- dup dup can_wcs { wcs } { wcca } ifelse
- (;) wl
- (\tcode = (*pprocs->ref_from_string)\(i_ctx_p, &) ws 2 index wt
- (, \(const char *\)s_, ) ws length wt (\);) wl
- (\tif ( code < 0 ) return code;) wl
- wap (}) wl true
- wtempname deletefile
- }
- }
- % Default
- { { pop true }
- { wother }
- }
- ] def
-
-% Write a named dictionary. We assume the ref is already declared.
- /wd % <name> <dict> <extra> wd -
- { 3 1 roll
- ({) ws
- (\tref v_[) ws dup length wt (];) wl
- dup [ exch
- { counttomark 2 sub wtstring cvs
- (v_[) exch concatstrings (]) concatstrings exch wo not
- { (Skipping ) print ==only (....\n) print }
- if
- } forall
- ]
- % Stack: array of keys (names)
- ({) ws dup (str_keys_) exch wsna
- (\tstatic const cfont_dict_keys keys_ =) wl
- (\t { 0, 0, ) ws length wt (, ) ws 3 -1 roll wt (, ) ws
- dup wpa (, ) ws dup wva ( };) wl pop
- (\tcode = \(*pprocs->ref_dict_create\)\(i_ctx_p, &) ws wt
- (, &keys_, \(const char *\)str_keys_, v_\);) wl
- (\tif ( code < 0 ) return code;) wl
- (}) wl
- (}) wl
- } bind def
-
-% Write character dictionary keys.
-% We save a lot of space by abbreviating keys which appear in
-% StandardEncoding or ISOLatin1Encoding.
-% Writes code to declare and initialize enc_keys_, str_keys, and keys_.
-/wcdkeys % <dict> wcdkeys -
- { % Write keys present in StandardEncoding or ISOLatin1Encoding,
- % pushing other keys on the o-stack.
- (static const charindex enc_keys_[] = {) wl
- dup [ exch 0 exch
- { pop decoding 1 index known
- { decoding exch get ({) ws dup -8 bitshift wt
- (,) ws 255 and wt (}, ) ws
- 1 add dup 5 mod 0 eq { (\n) ws } if
- }
- { exch }
- ifelse
- }
- forall pop
- ]
- ({0,0}\n};) wl
- % Write other keys.
- (str_keys_) exch wsna
- % Write the declaration for keys_.
- (static const cfont_dict_keys keys_ = {) wl
- (\tenc_keys_, countof\(enc_keys_\) - 1,) wl
- (\t) ws dup length wt ( - \(countof\(enc_keys_\) - 1\), 0, ) ws
- dup wpa (, ) ws wva () wl
- (};) wl
- } bind def
-
-% Enumerate character dictionary values in the same order that
-% the keys appear in enc_keys_ and str_keys_.
-% <proc> is called with each value in turn.
-/cdforall % <dict> <proc> cdforall -
- { 2 copy
- { decoding 3 index known
- { 3 -1 roll pop exec }
- { pop pop pop }
- ifelse
- }
- /exec cvx 3 packedarray cvx
- /forall cvx
- 5 -2 roll
- { decoding 3 index known
- { pop pop pop }
- { 3 -1 roll pop exec }
- ifelse
- }
- /exec cvx 3 packedarray cvx
- /forall cvx
- 6 packedarray cvx exec
- } bind def
-
-% ------ Writers for special objects ------ %
-
-/writespecial 10 dict dup begin
-
- /FontInfo { 0 wd } def
-
- /Private { 0 wd } def
-
- /CharStrings
- { ({) wl
- dup wcdkeys
- (static const unsigned char values_[] = {) wl
- { wsn } cdforall
- (\t0\n};) wl
- (\tcode = \(*pprocs->string_dict_create\)\(i_ctx_p, &) ws wt
- (, &keys_, (const char *)str_keys_, \(const char *\)values_\);) wl
- (\tif ( code < 0 ) return code;) wl
- (}) wl
- } bind def
-
- /Metrics
- { ({) wl
- dup wcdkeys
- (static const ref_(float) values_[] = {) wl
- dup { (\t) ws wnums () wl } cdforall
- (\t0\n};) wl
- (static const unsigned char lengths_[] = {) wl
- { (\t) ws dup isnumber
- { pop 0 }
- { length 1 add }
- ifelse wt (,) wl
- } cdforall
- (\t0\n};) wl
- (\tcode = \(*pprocs->num_dict_create\)\(i_ctx_p, &) ws wt
- (, &keys_, str_keys_, (const ref *)values_, lengths_\);) wl
- (\tif ( code < 0 ) return code;) wl
- (}) wl
- } bind def
-
- /Metrics2 /Metrics load def
-
- /FDepVector pop % (converted to a list of font names)
-
-end def
-
-% ------ The main program ------ %
-
-% Construct an inverse dictionary of encodings.
-[ /StandardEncoding /ISOLatin1Encoding
- /SymbolEncoding /DingbatsEncoding
- /KanjiSubEncoding
-]
-dup length dict begin
- { mark exch dup { .findencoding exch def } stopped cleartomark
- } forall
-currentdict end /encodingnames exch def
-
-% Invert the StandardEncoding and ISOLatin1Encoding vectors.
-512 dict begin
- 0 1 255 { dup ISOLatin1Encoding exch get exch 256 add def } for
- 0 1 255 { dup StandardEncoding exch get exch def } for
-currentdict end /decoding exch def
-
-/writefont % cfilename procname -> [writes the current font]
- { (gsf_) exch concatstrings
- /fontprocname exch def
- /cfname exch def
- /cfile cfname (w) file def
-
-% Remove unwanted keys from the font.
- currentfont dup length dict begin { def } forall
- { /FID /MIDVector /CurMID } { currentdict exch undef } forall
- /Font currentdict end def
-
-% Replace the FDepVector with a list of font names.
- Font /FDepVector .knownget
- { [ exch { /FontName get } forall ]
- Font /FDepVector 3 -1 roll put
- }
- if
-
-% Find all the special objects we know about.
-% wo uses this to write out references to otherwise intractable objects.
- /otherobjs writespecial length dict dup begin
- writespecial
- { pop Font 1 index .knownget { exch def } { pop } ifelse
- }
- forall
- end def
-
-% Define a dummy FontInfo, in case the font doesn't have one.
- /FontInfo 0 dict def
-
-% Write out the boilerplate.
- Font begin
- (/****************************************************************) wl
- ( Portions of this file are subject to the following notice(s):) wl
- systemdict /copyright get wl
- FontInfo /Notice .knownget
- { (----------------------------------------------------------------) wl wl
- } if
- (****************************************************************/) wl
- () wl
- (/* ) ws cfname ws ( */) wl
- (/* This file was created by the ) ws product ws ( font2c utility. */) wl
- () wl
- (#undef DEBUG) wl
- (#include "ccfont.h") wl
- () wl
-
-% Write the procedure prologue.
- (#ifdef __PROTOTYPES__) wl
- (ccfont_proc\() ws fontprocname ws (\);) wl
- (int) wl
- fontprocname ws ((i_ctx_t *i_ctx_p, const cfont_procs *pprocs, ref *pfont)) wl
- (#else) wl
- (int) wl
- fontprocname ws ((i_ctx_p, pprocs, pfont) i_ctx_t *i_ctx_p; const cfont_procs *pprocs; ref *pfont;) wl
- (#endif) wl
- ({\tint code;) wl
- (\tref Font;) wl
- otherobjs
- { exch pop (\tref ) ws wt (;) wl }
- forall
-
-% Write out the special objects.
- otherobjs
- { exch writespecial 2 index get exec
- }
- forall
-
-% Write out the main font dictionary.
-% If possible, substitute the encoding name for the encoding;
-% PostScript code will fix this up.
- { /Encoding /PrefEnc }
- { Font 1 index .knownget
- { encodingnames exch .knownget { def } { pop } ifelse }
- { pop }
- ifelse
- }
- forall
- (Font) Font FontType 0 eq { 5 } { 1 } ifelse wd
-
-% Finish the procedural initialization code.
- (\t*pfont = Font;) wl
- (\treturn 0;) wl
- (}) wl
- end % Font
-
- cfile closefile
-
- } bind def
-
-end def % font2cdict
-
-% Compute the procedure name from the font name.
-% Replace all non-alphanumeric characters with '_'.
-/makefontprocnamemap 256 string
- 0 1 255 { 2 copy 95 put pop } for
- (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz)
- { 2 copy dup put pop } forall
-readonly def
-/makefontprocname % <fontname> makefontprocname <procnamestring>
- { dup length string cvs
- dup length 1 sub -1 0
- { % Stack: string index
- 2 copy 2 copy get //makefontprocnamemap exch get put pop
- }
- for
- } def
-
-/writefont { font2cdict begin writefont end } def
-
-% If the program was invoked from the command line, run it now.
-[ shellarguments
- { counttomark dup 2 eq exch 3 eq or
- { counttomark -1 roll cvn
- (Converting ) print dup =only ( font.\n) print flush
- % Ensure that we get a clean copy of the font from the
- % file system.
- 2 { % do both local and global
- currentglobal not setglobal
- dup undefinefont
- } repeat
- findfont setfont
- (FontName is ) print currentfont /FontName get ==only (.\n) print flush
- counttomark 1 eq
- { % Construct the procedure name from the file name.
- currentfont /FontName get makefontprocname
- }
- if
- writefont
- (Done.\n) print flush
- }
- { cleartomark
- (Usage: font2c fontname cfilename.c [shortname]\n) print
- ( e.g.: font2c Courier cour.c\n) print flush
- mark
- }
- ifelse
- }
-if pop
diff --git a/Master/tlpkg/tlgs/lib/font2pcl.ps b/Master/tlpkg/tlgs/lib/font2pcl.ps
deleted file mode 100644
index df0c92d7279..00000000000
--- a/Master/tlpkg/tlgs/lib/font2pcl.ps
+++ /dev/null
@@ -1,600 +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.
-%
-
-% font2pcl.ps
-% Write out a font as a PCL bitmap font.
-
-/pcldict 60 dict def
-
-% Write out the current font as a PCL bitmap font.
-% The current transformation matrix defines the font size and orientation.
-
-/WriteResolution? false def % true=use "resolution bound font" format,
- % false=use older format
-
-/LJ4 false def % true=use LJ4 Typeface code
- % false=use LJIIP/IID/IIIx Typeface code
-
-pcldict begin % internal procedures
-
-/findstring % <string> <substring> findstring <bool>
- { search { pop pop pop true } { pop false } ifelse
- } def
-
- % Determine which set of keywords is present in a string.
- % The last keyword set must be empty.
-
-/keysearch % <string> <array of arrays of keywords> keysearch <index>
- { 0 1 2 index length 1 sub
- { 2 copy get true exch
- { % Stack: <string> <a.a.k.> <index> <bool> <keyword>
- 4 index exch findstring and
- }
- forall
- { 0 exch getinterval exit
- }
- if pop
- }
- for
- exch pop length % invalid index if missing
- } def
-
- % Determine the device height of a string in quarter-dots.
-
-/charheight % <string> charheight <int>
- { gsave newpath 0 0 moveto false charpath
- pathbbox exch pop exch sub exch pop 0 exch grestore
- dtransform add abs 4 mul cvi
- } def
-
- % Compute an integer version of the transformed FontBBox.
-
-/inflate % <num> inflate <num>
- { dup 0 gt { ceiling } { floor } ifelse
- } def
-/ixbbox % - ixbbox <llx> <lly> <urx> <ury>
- { /FontBBox load aload pop % might be executable or literal
- 4 2 roll transform exch truncate cvi exch truncate cvi
- 4 2 roll transform exch inflate cvi exch inflate cvi
- } def
-
- % Determine the original font of a possibly transformed font.
- % Since some badly behaved PostScript files construct transformed
- % fonts "by hand", we can't just rely on the OrigFont pointers.
- % Instead, if a font with the given name exists, and if its
- % entries for FontType and UniqueID match those of the font we
- % obtain by following the OrigFont chain, we use that font.
-
-/origfont
- { { dup /OrigFont known not { exit } if /OrigFont get } loop
- FontDirectory 1 index /FontName get .knownget
- { % Stack: origfont namedfont
- 1 index /FontType get 1 index /FontType get eq
- { 1 index /UniqueID .knownget
- { 1 index /UniqueID .knownget
- { eq { exch } if }
- { pop }
- ifelse
- }
- if
- }
- if pop
- }
- if
- } def
-
- % Determine the bounding box of the current device's image.
- % Free variables: row, zerow.
-
-/devbbox % <rw> <rh> devbbox <ymin> <ymax1> <xmin> <xmax1>
- { % Find top and bottom whitespace.
- dup
- { dup 0 eq { exit } if 1 sub
- dup currentdevice exch row copyscanlines
- zerow ne { 1 add exit } if
- }
- loop % ymax1
- 0
- { 2 copy eq { exit } if
- dup currentdevice exch row copyscanlines
- zerow ne { exit } if
- 1 add
- }
- loop % ymin
- exch
- % Find left and right whitespace.
- 3 index 0
- % Stack: rw rh ymin ymax1 xmin xmax1
- 3 index 1 4 index 1 sub
- { currentdevice exch row copyscanlines .findzeros
- exch 4 1 roll .max 3 1 roll .min exch
- }
- for % xmin xmax1
- % Special check: xmin > xmax1 if height = 0
- 2 copy gt { exch pop dup } if
- 6 -2 roll pop pop
-
- } def
-
- % Write values on outfile.
-
- /w1 { 255 and outfile exch write } def
- /w2 { dup -8 bitshift w1 w1 } def
- /wbyte % <byte> <label> wbyte
- { VDEBUG { print ( =byte= ) print dup == flush } { pop } ifelse w1
- } def
- /wword % <word16> <label> wword
- { VDEBUG { print ( =word= ) print dup == flush } { pop } ifelse w2
- } def
- /wdword % <word32> <label> wdword
- { VDEBUG { print ( =dword= ) print dup == flush } { pop } ifelse
- dup -16 bitshift w2 w2
- } def
-
-/style.posture.keys
- [ { (Italic) } { (Oblique) }
- { }
- ] def
-/style.posture.values <010100> def
-
-/style.appearance.width.keys
- [ { (Ultra) (Compressed) }
- { (Extra) (Compressed) }
- { (Extra) (Condensed) }
- { (Extra) (Extended) }
- { (Extra) (Expanded) }
- { (Compressed) }
- { (Condensed) }
- { (Extended) }
- { (Expanded) }
- { }
- ] def
-/style.appearance.width.values <04030207070201060600> def
-
-/width.type.keys
- [ { (Ultra) (Compressed) }
- { (Extra) (Compressed) }
- { (Extra) (Condensed) }
- { (Extra) (Expanded) }
- { (Compressed) }
- { (Condensed) }
- { (Expanded) }
- { }
- ] def
-/width.type.values <fbfcfd03fdfe0200> def
-
-/stroke.weight.keys
- [ { (Ultra) (Thin) }
- { (Ultra) (Black) }
- { (Extra) (Thin) }
- { (Extra) (Light) }
- { (Extra) (Bold) }
- { (Extra) (Black) }
- { (Demi) (Light) }
- { (Demi) (Bold) }
- { (Semi) (Light) }
- { (Semi) (Bold) }
- { (Thin) }
- { (Light) }
- { (Bold) }
- { (Black) }
- { }
- ] def
-/stroke.weight.values <f907fafc0406fe02ff01fbfd030500> def
-
-/vendor.keys
- [ { (Agfa) }
- { (Bitstream) }
- { (Linotype) }
- { (Monotype) }
- { (Adobe) }
- { }
- ] def
-/vendor.default.index 4 def % might as well be Adobe
-/old.vendor.values <020406080a00> def
-/new.vendor.values <010203040500> def
-/vendor.initials (CBLMA\000) def
-
-currentdict readonly end pop % pcldict
-
-% Convert and write a PCL font for the current font and transformation.
-
-% Write the font header. We split this off only to avoid overflowing
-% the limit on the maximum size of a procedure.
-% Free variables: outfile uury u0y rw rh orientation uh ully
-/writefontheader
- { outfile (\033\)s) writestring
- outfile 64 WriteResolution? { 4 add } if
- Copyright length add write==only
- outfile (W) writestring
- WriteResolution? { 20 68 } { 0 64 } ifelse
- (Font Descriptor Size) wword
- (Header Format) wbyte
- 1 (Font Type) wbyte
- FullName style.posture.keys keysearch style.posture.values exch get
- FullName style.appearance.width.keys keysearch
- style.appearance.width.values exch get 4 mul add
- PaintType 2 eq { 32 add } if
- /style exch def
- style -8 bitshift (Style MSB) wbyte
- 0 (Reserved) wbyte
- /baseline uury 1 sub u0y sub def
- baseline (Baseline Position) wword
- rw (Cell Width) wword
- rh (Cell Height) wword
- orientation (Orientation) wbyte
- FontInfo /isFixedPitch .knownget not { false } if
- { 0 } { 1 } ifelse (Spacing) wbyte
- % Use loop/exit to fake a multiple-exit block.
- { Encoding StandardEncoding eq { 10 (J) exit } if
- Encoding ISOLatin1Encoding eq { 11 (J) exit } if
- Encoding SymbolEncoding eq { 19 (M) exit } if
- Encoding DingbatsEncoding eq { 10 (L) exit } if
-% (Warning: unknown Encoding, using ISOLatin1.\n) print flush
- 11 (J) exit
- }
- loop
- 0 get 64 sub exch 32 mul add (Symbol Set) wword
- ( ) stringwidth pop 0 dtransform add abs 4 mul
- /pitch exch def
- pitch cvi (Pitch) wword
- uh 4 mul (Height) wword % Height
- (x) charheight (x-Height) wword
- FullName width.type.keys keysearch
- width.type.values exch get (Width Type) wbyte
- style 255 and (Style LSB) wbyte
- FullName stroke.weight.keys keysearch
- stroke.weight.values exch get (Stroke Weight) wbyte
- FullName vendor.keys keysearch
- dup vendor.initials exch get 0 eq
- { % No vendor in FullName, try Notice
- pop Copyright vendor.keys keysearch
- dup vendor.initials exch get 0 eq { pop vendor.default.index } if
- }
- if
- /vendor.index exch def
- 0 (Typeface LSB) wbyte % punt
- 0 (Typeface MSB) wbyte % punt
- 0 (Serif Style) wbyte % punt
- 2 (Quality) wbyte
- 0 (Placement) wbyte
- gsave FontMatrix concat rot neg rotate
- /ulwidth
- FontInfo /UnderlineThickness .knownget
- { 0 exch dtransform exch pop abs }
- { resolution 100 div }
- ifelse def
- FontInfo /UnderlinePosition .knownget
- { 0 exch transform exch pop negY ulwidth 2 div add }
- { ully ulwidth add }
- ifelse u0y sub
- round cvi 1 .max 255 .min (Underline Position) wbyte
- ulwidth round cvi 1 .max 255 .min (Underline Thickness) wbyte
- grestore
- uh 1.2 mul 4 mul cvi (Text Height) wword
- (average lowercase character) dup stringwidth
- pop 0 dtransform add abs
- exch length div 4 mul cvi (Text Width) wword
- 0
- { dup Encoding exch get /.notdef ne { exit } if
- 1 add
- }
- loop (First Code) wword
- 255
- { dup Encoding exch get /.notdef ne { exit } if
- 1 sub
- }
- loop (Last Code) wword
- pitch dup cvi sub 256 mul cvi (Pitch Extended) wbyte
- 0 (Height Extended) wbyte
- 0 (Cap Height) wword % (default)
- currentfont /UniqueID known { UniqueID } { 0 } ifelse
- 16#c1000000 add (Font Number (Adobe UniqueID)) wdword
- FontName length 16 .max string
- dup FontName exch cvs pop
- outfile exch 0 16 getinterval writestring % Font Name
- WriteResolution?
- { resolution dup (X Resolution) wword (Y Resolution) wword
- }
- if
- outfile Copyright writestring % Copyright
- } def
-
-/writePCL % <fontfile> <resolution> writePCL -
- {
- save
- currentfont begin
- pcldict begin
- 80 dict begin % allow for recursion
- /saved exch def
- /resolution exch def
- /outfile exch def
- matrix currentmatrix dup 4 0 put dup 5 0 put setmatrix
-
- % Supply some default values so we don't have to check later.
-
- currentfont /FontInfo known not { /FontInfo 1 dict def } if
- currentfont /FontName known not { /FontName () def } if
- /Copyright FontInfo /Notice .knownget not { () } if def
- /FullName
- FontInfo /FullName .knownget not
- { FontName dup length string cvs }
- if def
-
- % Determine the original font, and its relationship to this one.
-
- /OrigFont currentfont origfont def
- /OrigMatrix OrigFont /FontMatrix get def
- /OrigMatrixInverse OrigMatrix matrix invertmatrix def
- /ScaleMatrix matrix currentfont OrigFont ne
- { FontMatrix exch OrigMatrixInverse exch concatmatrix
- } if
- def
- /CurrentScaleMatrix
- matrix currentmatrix
- matrix defaultmatrix
- dup 0 get 1 index 3 get mul 0 lt
- 1 index dup 1 get exch 2 get mul 0 gt or
- /flipY exch def
- dup invertmatrix
- dup concatmatrix
- def
- /negY flipY { {neg} } { {} } ifelse def
-
- % Print debugging information.
-
- /CDEBUG where { pop } { /CDEBUG false def } ifelse
- /VDEBUG where { pop } { /VDEBUG false def } ifelse
- CDEBUG { /VDEBUG true def } if
- DEBUG
- { (currentmatrix: ) print matrix currentmatrix ==
- (defaultmatrix: ) print matrix defaultmatrix ==
- (flipY: ) print flipY ==
- (scaling matrix: ) print CurrentScaleMatrix ==
- (FontMatrix: ) print FontMatrix ==
- (FontBBox: ) print /FontBBox load ==
- currentfont OrigFont ne
- { OrigFont /FontName .knownget { (orig FontName: ) print == } if
- (orig FontMatrix: ) print OrigMatrix ==
- } if
- currentfont /ScaleMatrix .knownget { (ScaleMatrix: ) print == } if
- gsave
- FontMatrix concat
- (combined matrix: ) print matrix currentmatrix ==
- grestore
- flush
- } if
-
- % Determine the orientation.
-
- ScaleMatrix matrix currentmatrix dup concatmatrix
- 0 1 3
- { 1 index 1 get 0 eq 2 index 2 get 0 eq and 2 index 0 get 0 gt and
- { exit } if
- pop -90 matrix rotate exch dup concatmatrix
- }
- for
- dup type /integertype ne
- { (Only rotations by multiples of 90 degrees are supported:\n) print
- == flush
- saved end end end restore stop
- }
- if
- /orientation exch def
- /rot orientation 90 mul def
- DEBUG { (orientation: ) print orientation == flush } if
-
- dup dup 0 get exch 3 get negY sub abs 0.5 ge
- { (Only identical scaling in X and Y is supported:\n) print
- exch flipY 3 array astore ==
- currentdevice .devicename ==
- matrix defaultmatrix == flush
- saved end end end restore stop
- }
- if pop
-
- % Determine the font metrics, in the PCL character coordinate system,
- % which has +Y going towards the top of the page.
-
- gsave
- FontMatrix concat
- 0 0 transform
- negY round cvi /r0y exch def
- round cvi /r0x exch def
- ixbbox
- negY /rury exch def /rurx exch def
- negY /rlly exch def /rllx exch def
- /rminx rllx rurx .min def
- /rminy rlly negY rury negY .min def
- /rw rurx rllx sub abs def
- /rh rury rlly sub abs def
- gsave rot neg rotate
- 0 0 transform
- negY round cvi /u0y exch def
- round cvi /u0x exch def
- ixbbox
- negY /uury exch def /uurx exch def
- negY /ully exch def /ullx exch def
- /uw uurx ullx sub def
- /uh uury ully sub def
- grestore
- DEBUG
- { (rmatrix: ) print matrix currentmatrix ==
- (rFontBBox: ) print [rllx rlly rurx rury] ==
- (uFontBBox: ) print [ullx ully uurx uury] ==
- flush
- } if
- grestore
-
- % Disable the character cache, to avoid excessive allocation
- % and memory sandbars.
-
- mark cachestatus /upper exch def
- cleartomark 0 setcachelimit
-
- % Write the font header.
-
- writefontheader
-
- % Establish an image device for rasterizing characters.
-
- matrix currentmatrix
- dup 4 rminx neg put
- dup 5 rminy neg put
- % Round the width up to a multiple of 8
- % so we don't get garbage bits in the last byte of each row.
- rw 7 add -8 and rh <ff 00> makeimagedevice
- /cdevice exch def
- nulldevice % prevent page device switching
- cdevice setdevice
-
- % Rasterize each character in turn.
-
- /raster rw 7 add 8 idiv def
- /row raster string def
- /zerow row length string def
- 0 1 Encoding length 1 sub
- { /cindex exch def
- Encoding cindex get /.notdef ne
- { VDEBUG { Encoding cindex get == flush } if
- erasepage initgraphics
- 0 0 moveto currentpoint transform add
- ( ) dup 0 cindex put show
- currentpoint transform add exch sub round cvi
- /cwidth exch abs def
- rw rh devbbox
- VDEBUG
- { (image bbox: ) print 4 copy 4 2 roll 4 array astore == flush
- } if
- % Save the device bounding box.
- % Note that this is in current device coordinates,
- % not PCL (right-handed) coordinates.
- /bqx exch def /bpx exch def /bqy exch def /bpy exch def
- % Re-render with the character justified to (0,0).
- % This may be either the lower left or the upper left corner.
- bpx neg bpy neg idtransform moveto
- erasepage
- VDEBUG { (show point: ) print [ currentpoint transform ] == flush } if
- ( ) dup 0 cindex put show
- % Find the bounding box. Note that xmin and ymin are now 0,
- % xmax1 = xw, and ymax1 = yh.
- rw rh devbbox
- /xw exch def
- % xmin or ymin can be non-zero only if the character is blank.
- xw 0 eq
- { pop }
- { dup 0 ne { (Non-zero xmin! ) print = } { pop } ifelse }
- ifelse
- /yh exch def
- yh 0 eq
- { pop }
- { dup 0 ne { (Non-zero ymin! ) print = } { pop } ifelse }
- ifelse
-
- /xbw xw 7 add 8 idiv def
- /xright raster 8 mul xw sub def
- % Write the Character Code command.
- outfile (\033*c) writestring
- outfile cindex write==only
- outfile (E) writestring
- % Write the Character Definition command.
- outfile (\033\(s) writestring
- yh xbw mul 16 add
- outfile exch write=only
- % Record the character position for the .PCM file.
- /cfpos outfile fileposition 1 add def
- outfile (W\004\000\016\001) writestring
- orientation (Orientation) wbyte 0 (Reserved) wbyte
- rminx bpx add r0x sub (Left Offset) wword
- flipY { rminy bpy add neg } { rminy bqy add } ifelse r0y sub
- (Top Offset) wword
- xw (Character Width) wword
- yh (Character Height) wword
- cwidth orientation 2 ge { neg } if 4 mul (Delta X) wword
- % Write the character data.
- flipY { 0 1 yh 1 sub } { yh 1 sub -1 0 } ifelse
- { cdevice exch row copyscanlines
- 0 xbw getinterval
- CDEBUG
- { dup
- { 8
- { dup 128 ge { (+) } { (.) } ifelse print
- 127 and 1 bitshift
- }
- repeat pop
- }
- forall (\n) print
- }
- if
- outfile exch writestring
- }
- for
- }
- { /bpx 0 def /bpy 0 def /bqx 0 def /bqy 0 def
- /cwidth 0 def
- /cfpos 0 def
- }
- ifelse
-
- }
- for
-
- % Wrap up.
-
- upper setcachelimit
- outfile closefile
-
- nulldevice % prevent page device switching
- saved end end end restore
-
- } def
-
-% Provide definitions for testing with older or non-custom interpreters.
-
-/.findzeros where { pop (%END) .skipeof } if
-/.findzeros
- { userdict begin /zs exch def /zl zs length def
- 0 { dup zl ge { exit } if dup zs exch get 0 ne { exit } if 1 add } loop
- zl { dup 0 eq { exit } if dup 1 sub zs exch get 0 ne { exit } if 1 sub } loop
- exch 3 bitshift exch 3 bitshift
- 2 copy lt
- { exch zs 1 index -3 bitshift get
- { dup 16#80 and 0 ne { exit } if exch 1 add exch 1 bitshift } loop pop
- exch zs 1 index -3 bitshift 1 sub get
- { dup 1 and 0 ne { exit } if exch 1 sub exch -1 bitshift } loop pop
- }
- if end
- } bind def
-%END
-
-/write=only where { pop (%END) .skipeof } if
-/w=s 128 string def
-/write=only
- { w=s cvs writestring
- } bind def
-%END
-
-%**************** Test
-/PCLTEST where {
- pop
- /DEBUG true def
- /CDEBUG true def
- /VDEBUG true def
- /Times-Roman findfont 10 scalefont setfont
- (t.pcf) (w) file
- 300 72 div dup scale
- 300 writePCL
- flush quit
-} if
diff --git a/Master/tlpkg/tlgs/lib/gs_pfile.ps b/Master/tlpkg/tlgs/lib/gs_pfile.ps
deleted file mode 100644
index 1118d8aa567..00000000000
--- a/Master/tlpkg/tlgs/lib/gs_pfile.ps
+++ /dev/null
@@ -1,126 +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.
-%
-
-% Runtime support for minimum-space fonts and packed files.
-
-% ****** NOTE: This file must be kept consistent with
-% ****** packfile.ps and wrfont.ps.
-
-% ---------------- Packed file support ---------------- %
-
-% A packed file is the concatenation of several file groups, each of which
-% is the result of compressing several files concatenated together.
-% The packed file begins with a procedure that creates an appropriate
-% decoding filter for each file group, as follows:
-% <group-subfile-filter> -proc- <group-decode-filter>
-% Thus, accessing an individual file requires 4 parameters:
-% the starting address and length of the outer compressed file,
-% and the starting address and length of the inner file.
-/.packedfilefilter % <file> <ostart> <olength> <istart> <ilength>
- % .packedfilefilter <filter>
- { 4 index systemdict begin token pop end 6 1 roll
- % Stack: fproc file ostart olength istart ilength
- 4 index 5 -1 roll setfileposition
- % Stack: fproc file olength istart ilength
- 4 -2 roll () /SubFileDecode filter
- % Stack: fproc istart ilength ofilter
- 4 -1 roll exec
- % Filters don't support setfileposition, so we must skip data
- % by reading it into a buffer. We rely on the fact that
- % save/restore don't affect file positions.
- % Stack: istart ilength dfilter
- save exch 64000 string
- % Stack: istart ilength save dfilter scratch
- 4 index 1 index length idiv { 2 copy readstring pop pop } repeat
- 2 copy 0 8 -1 roll 2 index length mod getinterval readstring pop pop pop
- % Stack: ilength save dfilter
- exch restore exch () /SubFileDecode filter
- } bind def
-
-% Run a packed library file.
-/.runpackedlibfile % <filename> <ostart> <olength> <istart> <ilength>
- % .runpackedlibfile
- { 5 -1 roll findlibfile
- { exch pop dup 6 2 roll .packedfilefilter
- currentobjectformat exch 1 setobjectformat run
- setobjectformat closefile
- }
- { 5 1 roll /findlibfile .systemvar /undefinedfilename signalerror
- }
- ifelse
- } bind def
-
-% ---------------- Compacted font support ---------------- %
-
-% Compacted fonts written by wrfont.ps depend on the existence and
-% specifications of the procedures and data in this section.
-
-/.compactfontdefault mark
- /PaintType 0
- /FontMatrix [0.001 0 0 0.001 0 0] readonly
- /FontType 1
- /Encoding StandardEncoding
-.dicttomark readonly def
-
-/.checkexistingfont % <fontname> <uid> <privatesize> <fontsize>
- % .checkexistingfont
- % {} (<font> on d-stack)
- % <fontname> <uid> <privatesize> <fontsize>
- % .checkexistingfont
- % -save- --restore-- (<font> on d-stack)
- { FontDirectory 4 index .knownget
- { dup /UniqueID .knownget
- { 4 index eq exch /FontType get 1 eq and }
- { pop false }
- ifelse
- }
- { false
- }
- ifelse
- { save /restore load 6 2 roll }
- { {} 5 1 roll }
- ifelse
- dict //.compactfontdefault exch .copydict begin
- dict /Private exch def
- Private begin
- /MinFeature {16 16} def
- /Password 5839 def
- /UniqueID 1 index def
- end
- /UniqueID exch def
- /FontName exch def
- } bind def
-
-/.knownEncodings [
- ISOLatin1Encoding
- StandardEncoding
- SymbolEncoding
-] readonly def
-
-/.readCharStrings % <count> <encrypt> .readCharStrings <dict>
- { exch dup dict dup 3 -1 roll
- { currentfile token pop dup type /integertype eq
- { dup -8 bitshift //.knownEncodings exch get exch 255 and get } if
- currentfile token pop dup type /nametype eq
- { 2 index exch get
- }
- { % Stack: encrypt dict dict key value
- 4 index { 4330 exch dup .type1encrypt exch pop } if
- readonly
- }
- ifelse put dup
- }
- repeat pop exch pop
- } bind def
diff --git a/Master/tlpkg/tlgs/lib/gs_rdlin.ps b/Master/tlpkg/tlgs/lib/gs_rdlin.ps
deleted file mode 100644
index aefd6d00438..00000000000
--- a/Master/tlpkg/tlgs/lib/gs_rdlin.ps
+++ /dev/null
@@ -1,19 +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.
-%
-
-% Patch for systems with readline support in the interpreter.
-
-% Disable the prompt message, since readline will generate it.
-/.promptmsg { } def
diff --git a/Master/tlpkg/tlgs/lib/impath.ps b/Master/tlpkg/tlgs/lib/impath.ps
deleted file mode 100644
index 8ddc1ef1a89..00000000000
--- a/Master/tlpkg/tlgs/lib/impath.ps
+++ /dev/null
@@ -1,178 +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.
-%
-
-% impath.ps
-% Reverse-rasterize a bitmap to produce a Type 1 outline.
-% (This was formerly a Ghostscript operator implemented in C.)
-
-% <image> <width> <height> <wx> <wy> <ox> <oy> <string>
-% type1imagepath <substring>
-% Converts an image (bitmap) description of a character into
-% a scalable description in Adobe Type 1 format. The
-% current transformation matrix should be the same as the
-% FontMatrix of the font in which this character will be
-% used: this establishes the scaling relationship between
-% image pixels (the image is assumed to be 1 unit high in
-% user space) and the character coordinate system used in
-% the scalable description. wx and wy are the character
-% width, and ox and oy are the character origin relative
-% to the lower left corner of the bitmap, in *pixels*.
-% The image is assumed to be stored in left-to-right,
-% top-to-bottom order. Note that this is not consistent
-% with the `image' operator's interpretation of the CTM.
-% All coordinates in the scalable description are rounded to
-% integers, so the coefficients in the FontMatrix should
-% be on the order of 1/N for some value of N that is
-% either a multiple of the height/width or is large
-% compared to the width and height. (There is a
-% convention, which some PostScript programs rely on, that
-% N=1000.)
-% Note that the encoded description has *not* been subjected
-% to CharString encryption, which is necessary before the
-% description can be given to type1addpath: to do this,
-% follow the type1imagepath with
-% 4330 exch dup .type1encrypt exch pop
-% If the description is too complex to fit into the supplied
-% string, a limitcheck error results. A good rule of
-% thumb is that the size of the string should be about 6
-% times the number of 1-bits in the image that are not
-% completely surrounded by other 1-bits.
-
-% Import the Type 1 opcodes.
-(type1ops.ps) runlibfile
-
-100 dict
-dup /type1imagepath_dict exch def
-begin
-
-/rc { round cvi } bind def
-/moving [/rmoveto /hmoveto /vmoveto] def
-/drawing [/rlineto /hlineto /vlineto] def
-
-% Convert the current path to a Type 1 token array.
-/putxy % x y ops -> cs_elements
- { 3 -1 roll dup x sub rc exch /x exch def
- 3 -1 roll dup y sub rc exch /y exch def
- % stack: ops dx dy
- dup 0 eq
- { % dy = 0, use hmoveto/lineto
- pop exch 1 get
- }
- { 1 index 0 eq
- { % dx = 0, use vmoveto/lineto
- exch pop exch 2 get
- }
- { % use rmoveto/rlineto
- 3 -1 roll 0 get
- }
- ifelse
- }
- ifelse
- } bind def
-/pathtotype1 % -> charstack
- { 3 dict begin /x 0 def /y 0 def
- mark
- { moving putxy
- }
- { drawing putxy
- }
- { % Convert curve to relative form
- x y 3
- { exch neg 7 index add rc
- exch neg 6 index add rc
- 8 -2 roll
- }
- repeat /y exch def /x exch def
- 1 index 0 eq 5 index 0 eq and % dy1=dx3=0, hv
- { 5 -1 roll pop exch pop /hvcurveto
- }
- { dup 0 eq 6 index 0 eq and % dx1=dy3=0, vh
- { 6 -1 roll pop pop /vhcurveto
- }
- { /rrcurveto % none of the above
- }
- ifelse
- }
- ifelse
- }
- { /closepath
- }
- pathforall end
- } bind def
-
-end % type1imagepath_dict
-
-% The main program
-/type1imagepath % image width height wx wy ox oy string ->
- % substring
- { type1imagepath_dict begin
- /tsave save def
- /ostring exch def
- /oy exch def /ox exch def
- /wy exch def /wx exch def
- /height exch def /width exch def
- /data exch def
-
- /ofilter ostring /NullEncode filter def
- /raster width 7 add 8 idiv def
-
-% Construct the coordinate transformation.
- height dup scale
- matrix currentmatrix matrix invertmatrix setmatrix
-
-% Determine the left side bearing.
- /lsbx width
- 0 1 width 1 sub
- { dup dup 8 idiv 0 exch
- raster raster height mul 1 sub
- { data exch get or }
- for exch 8 mod bitshift 128 and 0 ne
- { exch pop exit }
- if pop
- }
- for def
-
-% Compute and encode the origin, width, and side bearing.
- mark
- ox oy dtransform
- rc /opty exch def rc /optx exch def
- wx wy dtransform
- rc /iwy exch def rc /iwx exch def
- lsbx ox sub 0 dtransform
- rc /ilsby exch def rc /ilsbx exch def
- ilsbx
- iwy 0 ne ilsby 0 ne or
- { ilsby iwx iwy /sbw }
- { iwx /hsbw }
- ifelse
- ofilter charstack_write
-
-% Flip over the Y axis, because the image is stored top-to-bottom.
- [1 0 0 -1 0 height] concat
-% Account for the character origin.
- lsbx oy translate
-% Trace the outline.
- newpath
- width height data .imagepath
- gsave matrix setmatrix pathtotype1 grestore
- ofilter charstack_write
-% Terminate the output
- mark /endchar ofilter charstack_write
-
- ofilter .fileposition ofilter closefile % flush buffers
- ostring 0 3 -1 roll getinterval
- tsave restore
- end
- } bind def
diff --git a/Master/tlpkg/tlgs/lib/level1.ps b/Master/tlpkg/tlgs/lib/level1.ps
deleted file mode 100644
index b4c53c1a453..00000000000
--- a/Master/tlpkg/tlgs/lib/level1.ps
+++ /dev/null
@@ -1,2 +0,0 @@
-%!
-/.setlanguagelevel where { pop 1 .setlanguagelevel } if
diff --git a/Master/tlpkg/tlgs/lib/markhint.ps b/Master/tlpkg/tlgs/lib/markhint.ps
deleted file mode 100644
index f83d62d85af..00000000000
--- a/Master/tlpkg/tlgs/lib/markhint.ps
+++ /dev/null
@@ -1,129 +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.
-%
-
-% markhint.ps
-% Draw the hints for a Type 1 font.
-
-(type1ops.ps) runlibfile
-
-/mhsetup % <matrix> <print> mhsetup -
- { /mhprint exch def
- /mhmx exch def
- /mhdash 0 9 gsave initmatrix dtransform grestore idtransform add abs def
- gsave
- clippath pathbbox
- 2 index sub /bbh exch def
- 2 index sub /bbw exch def
- /bby exch def
- /bbx exch def
- grestore
- } def
-
-/markfonthints % <matrix> <print> markfonthints -
- { mhsetup
- } def
-
-/hmark % <y> hmark -
- { bbx exch moveto bbw 0 rlineto stroke
- } def
-/hsmark % <y0> <dy> hsmark -
- { 1 index add exch gsave
- [mhdash] 0 setdash 0 exch mhmx transform exch pop hmark
- [mhdash 2 div dup 2 mul] 0 setdash 0 exch mhmx transform exch pop hmark
- grestore
- } def
-/vmark % <x> vmark -
- { bby moveto 0 bbh rlineto stroke
- } def
-/vsmark % <x0> <dx> vsmark -
- { 1 index add exch gsave
- [mhdash] mhdash setdash 0 mhmx transform pop vmark
- [mhdash 2 div dup 2 mul] 0 setdash 0 mhmx transform pop vmark
- grestore
- } def
-/pmark % <x> <y> pmark -
- { newpath 0 4.5 gsave initmatrix dtransform grestore idtransform add abs
- 0 360 arc stroke
- } def
-/mchdict mark
- /hsbw { pop 0 mhmx transform translate 0 0 pmark }
- /sbw { pop pop mhmx transform translate 0 0 pmark }
- /hstem
- { mhprint { (hstem ) print 2 copy 2 packedarray == } if
- hsmark
- }
- /vstem
- { mhprint { (vstem ) print 2 copy 2 packedarray == } if
- vsmark
- }
- /hstem3
- { mhprint { (hstem3 ) print 6 copy 6 packedarray == } if
- 3 { hsmark } repeat
- }
- /vstem3
- { mhprint { (vstem3 ) print 6 copy 6 packedarray == } if
- 3 { vsmark } repeat
- }
- /div
- { div
- }
- /callothersubr
- { 3 eq
- { pop
- mhprint { (replace) = } if
- % We're replacing hints; lighten the color.
- currentrgbcolor 3 { 2 mul 3 div 3 1 roll } repeat setrgbcolor
- }
- { { pop } repeat
- } ifelse
- }
- /callsubr
- { Private /Subrs get exch get mchinterp
- }
- /pop
- {
- }
- /return
- {
- }
-.dicttomark def
-
-/mchinterp % <charstring> mchinterp -
- { 4330 exch dup length string .type1decrypt exch pop
- dup length lenIV sub lenIV exch getinterval
- 0 () /SubFileDecode filter
- mark exch charstack_read ]
- { dup type /nametype eq
- { mchdict exch .knownget { exec } { cleartomark mark } ifelse
- }
- if
- }
- forall
- } def
-
-/markcharhints % <charname> <matrix> <print> markcharhints -
- { mhsetup
- gsave mark
- /Private currentfont /Private get def
- Private rcheck % make sure we won't get an access error
- { /lenIV Private /lenIV .knownget not { 4 } if def
- currentfont /CharStrings get 3 -1 roll get mchinterp
- }
- { (Sorry, this font is protected; I can't show the hints.\n) print flush
- exch
- }
- ifelse
- cleartomark grestore
- } def
diff --git a/Master/tlpkg/tlgs/lib/markpath.ps b/Master/tlpkg/tlgs/lib/markpath.ps
deleted file mode 100644
index 4aec660c177..00000000000
--- a/Master/tlpkg/tlgs/lib/markpath.ps
+++ /dev/null
@@ -1,58 +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.
-%
-
-% markpath.ps
-% Mark the corners of a path, drawing it slowly if desired.
-
-/Delay where { pop } { /Delay 0 def } ifelse
-/setxy0
- { currentpoint /y0 exch def /x0 exch def
- } def
-/bip
- { epsx epsy idtransform /ey exch def /ex exch def
- currentpoint ex 2 div ey 2 div rlineto currentpoint 0 ey neg rlineto
- ex neg 0 rlineto 0 ey rlineto lineto lineto
- stroke
- } def
-/dally
- { Delay { } repeat
- Delay 0 ne { flushpage } if
- } def
-/movebip
- { /xs 2 index def /ys 1 index def
- gsave newpath mpmx transform moveto setxy0 bip grestore
- } def
-/linebip
- { gsave newpath x0 y0 moveto mpmx transform lineto setxy0 bip dally grestore
- } def
-/curvebip
- { gsave newpath x0 y0 moveto 5 index 5 index mpmx transform lineto bip
- 2 copy mpmx transform moveto 3 index 3 index mpmx transform lineto bip
- x0 y0 moveto
- 3 { mpmx transform 6 2 roll } repeat
- curveto setxy0 bip dally grestore
- } def
-/closebip
- { xs ys linebip
- } def
-
-/markpath % <matrix> markpath -
- { /mpmx exch def
- gsave initgraphics 9 dup dtransform grestore
- /epsy exch def /epsx exch def
- gsave 0 setlinewidth
- { movebip } { linebip } { curvebip } { closebip } pathforall
- grestore
- } def
diff --git a/Master/tlpkg/tlgs/lib/packfile.ps b/Master/tlpkg/tlgs/lib/packfile.ps
deleted file mode 100644
index 8bad56f6dff..00000000000
--- a/Master/tlpkg/tlgs/lib/packfile.ps
+++ /dev/null
@@ -1,332 +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.
-%
-
-% packfile.ps
-% Pack groups of files together, with compression, for use in
-% storage-scarce environments.
-
-% ****** NOTE: This file must be kept consistent with gs_pfile.ps.
-
-% ---------------- Huffman coding utilities ---------------- %
-
-% We count runs of zeros, and individual byte frequencies separately
-% depending on whether they follow or do not follow a run of zeros.
-/zruns 256 array def
-/zfreq 256 array def
-/nzfreq 256 array def
-/maxcode 13 def % max code length, must be between 10 and 16
-/maxzrun 100 def % max length of zero run, must be <= 100
-/statbuf 10000 string def
-
-% Initialize statistics.
-/initstats % - initstats -
- { 0 1 255 { zruns exch 0 put } for
- 0 1 255 { zfreq exch 0 put } for
- 0 1 255 { nzfreq exch 0 put } for
- } bind def
-
-% Accumulate statistics from an individual file.
-/addstats % <file> addstats -
- { 0
- { 1 index //statbuf readstring 3 1 roll
- % Stack: file eof numzeros data
- { dup 0 eq
- { pop 1 add
- }
- { 1 index 0 ne
- { exch 255 .min
- //zruns exch 2 copy get 1 add put
- 0 exch //zfreq
- }
- { //nzfreq
- }
- ifelse
- exch 2 copy get 1 add put
- }
- ifelse
- } forall
- exch not { exit } if (.) print flush
- } loop
- pop closefile
- } bind def
-
-% Compute the Huffman codes from the statistics.
-/statcodes % - statcodes <array>
- { maxcode 1 add 256 add maxzrun 2 sub add 1 add array % full array
- dup maxcode 1 add dup 2 index length exch sub getinterval % data
- % Put statistics into array
- dup 0 1 255
- { zfreq 1 index get nzfreq 2 index get add put dup
- } for
- 0 zruns 1 get put
- 256 zruns 2 maxzrun 2 sub getinterval putinterval
- dup dup length 1 sub 1 put % EOD
- maxcode .computecodes
- } bind def
-
-% ---------------- File handling ---------------- %
-
-% Copy one file to another.
-% Close the input file, but not the output file.
-/copyfile % <infile> <outfile> copyfile <outfile> <length>
- { 0 mark statbuf
- { 4 index 1 index readstring
- exch 5 index 1 index writestring
- length 5 -1 roll add 4 1 roll
- not { exit } if (.) print flush
- } loop
- cleartomark 3 -1 roll closefile dup == flush
- } bind def
-
-% Represent a Type 1 font in its most compressed format.
-% Requires -dWRITESYSTEMDICT to run.
-% Does not close the output file.
-(wrfont.ps) runlibfile
-/compressfont % <fontname> <outfile> compressfont <outfile>
- { exch save
- systemdict /executeonly /readonly load put
- systemdict /noaccess /readonly load put
- systemdict readonly pop
- wrfont_dict begin
- /binary_CharStrings true def
- /binary_tokens true def
- /encrypt_CharStrings false def
- /standard_only false def
- /use_lenIV 0 def
- /smallest_output true def
- end
- exch findfont setfont
- 1 index writefont
- restore
- } bind def
-
-% ---------------- Main program ---------------- %
-
-% Find the length of a file.
-/filelength % <filename> filelength <length>
- { status { pop pop exch pop } { -1 } ifelse
- } bind def
-
-% Define the header string for a compressed file.
-/beginfilestring
-({dup token pop exch[/MaxCodeLength 2 index token pop/Tables 4 index token pop
-/EndOfData true/EncodeZeroRuns 256 .dicttomark
-/BoundedHuffmanDecode filter/MoveToFrontDecode filter
-[/BlockSize 4 -1 roll .dicttomark/BWBlockSortDecode filter
-}) readonly def
-
-% Write a 16-bit big-endian non-negative integer on a file.
-/write16 % <file> <int> write16 -
- { 2 copy -8 bitshift write 255 and write
- } bind def
-
-% Compress a group of files together.
-% Return a dictionary in which the keys are the input file names
-% and the values are [startpos length] in the uncompressed concatenation.
-% Does not open or close the output file.
-/tempname (t.em) def
-/packfiles % <filenames> <outfile> packfiles <outfile> <posdict>
- { % Concatenate files to a temporary file.
- tempname (w) file
- dup /MoveToFrontEncode filter
- dup <<
- /BlockSize 1000000
- >> /BWBlockSortEncode filter
- % Stack: filenames outfile tempfile mtfe bwe
- 5 -1 roll dup length dict 0 6 2 roll
- { % Stack: outfile posdict pos tempfile mtfe bwe infilename
- dup ==only dup (r) file 2 index copyfile exch pop
- dup 7 index 4 2 roll 7 index exch 2 array astore put
- 5 -1 roll add 4 1 roll
- } forall
- closefile closefile closefile pop exch
- % Stack: posdict outfile
- % Compute an optimal Huffman code.
- initstats
- tempname (r) file addstats
- % Actually compress the file.
- % Write the decompression information on the output first.
- dup tempname filelength write==
- dup maxcode write==
- % Write the code table as a homogenous number array.
- statcodes exch
- dup 149 write dup 32 write dup 2 index length write16
- exch { 2 copy write16 pop } forall
- dup <<
- /MaxCodeLength maxcode
- /EndOfData true
- /EncodeZeroRuns 256
- /Tables statcodes
- >> /BoundedHuffmanEncode filter
- tempname (r) file exch copyfile pop closefile
- exch
- } bind def
-
-% Squeeze a font to a .cpf file in anticipation of compression.
-/squeezefont % <fontname> squeezefont <filename.cpf>
- { dup type /nametype ne { cvn } if
- dup
- { dup type /stringtype eq { exit } if
- Fontmap exch get
- }
- loop
- % Stack: fontname filename
- dup dup
- { (.) search not { exit } if
- exch pop exch 3 -1 roll pop
- }
- loop
- % Stack: fontname filename noextname extension
- exch
- { (/) search not { (\\) search not { exit } if } if
- pop pop
- }
- loop
- % If the font extension is anything other than
- % .pfa or .pfb, we assume it can't be rewritten
- % using compressfont.
- % Stack: fontname filename extension basename
- (.cpf) concatstrings dup 5 1 roll (w) file
- % Stack: outfilename fontname filename extension outfile
- exch dup (pfa) eq exch (pfb) eq or
- % Stack: outfilename fontname filename outfile bool
- { exch pop compressfont
- }
- { 3 -1 roll pop
- exch findlibfile pop exch pop
- exch copyfile pop
- }
- ifelse closefile
- } bind def
-
-% ---------------- Production code ---------------- %
-
-% The following code constructs a packed version of the commercial-quality
-% fonts available from Artifex Software Inc. To use this code:
-% - If desired, change the output file names below.
-% - Make sure you have the synthetic font data (fontmap.shs and the
-% *.ps files for the commercial fonts) in a directory that is on
-% Ghostscript's search path.
-% - Construct the packed fonts by running
-% gs -dNODISPLAY -dWRITESYSTEMDICT packfile.ps
-% - If desired, move the output files to the directory that will be
-% used at run time. You no longer need the *.pfb or *.ps files
-% for the original fonts; however, you do still need the Fontmap
-% for these fonts, because it defines the font name aliases.
-% - Add the following line to the end of gs_fonts.ps:
-% (ALL.cmp) run
-% (substituting the definition of allmapname if you changed it).
-
-% Define the output file names. The extensions are arbitrary;
-% any legal file name is allowed.
-/allname (ALL.cff) def % the compressed font file
-/allmapname (ALL.cmp) def % the Fontmap override file
-
-% Load an alternate Fontmap that references the synthetic oblique and
-% narrow fonts.
-true .setglobal
-(fontmap.shs) findlibfile pop exch pop .loadFontmap
-false .setglobal
-
-% Define the packaging of fonts into font groups.
-% Fewer larger groups compress better, but make decompression slower.
-/Lists [
-[ % The oblique and narrow fonts are synthetic,
- % and take very little space.
- /AvantGarde-BookOblique /AvantGarde-DemiOblique
- /Courier-Oblique /Courier-BoldOblique
- /Helvetica-Oblique /Helvetica-BoldOblique
- /Helvetica-Narrow /Helvetica-Narrow-Oblique
- /Helvetica-Narrow-Bold /Helvetica-Narrow-BoldOblique
-]
-[/AvantGarde-Book /AvantGarde-Demi
- /Bookman-Light] [/Bookman-LightItalic
- /Bookman-Demi /Bookman-DemiItalic
- /Courier] [/Courier-Bold
- /Helvetica /Helvetica-Bold]
-[/NewCenturySchlbk-Roman /NewCenturySchlbk-Italic
- /NewCenturySchlbk-Bold /NewCenturySchlbk-BoldItalic]
-[/Palatino-Roman /Palatino-Italic
- /Palatino-Bold /Palatino-BoldItalic]
-[/Times-Roman /Times-Italic
- /Times-Bold /Times-BoldItalic]
-[/Symbol
- /ZapfChancery-MediumItalic
- /ZapfDingbats]
-] def
-
-% We need to register the fonts under their true names, not aliases.
-/Lists Lists mark exch
- { mark exch
- { { Fontmap 1 index get dup type /nametype ne { pop exit } if
- exch pop
- }
- loop
- }
- forall ]
- }
-forall ] def
-
-% Squeeze the fonts to their .cpf format.
-(Squeezing... ) print flush
-/fdict mark
-Lists
- { { dup squeezefont } forall } forall
-.dicttomark def
-(done.\n) print flush
-
-% Invert fdict.
-/f2dict fdict length dict def
-fdict { exch f2dict 3 1 roll put } forall
-
-% Construct the compressed font file.
-(Creating ) print allname print (... ) print flush
-/posdict fdict length dict def
-/all allname (w) file def
-all beginfilestring writestring
-Lists
- { dup == flush
- /fbegin all fileposition def
- mark exch { fdict exch get } forall ]
- all packfiles exch pop
- /flength all fileposition fbegin sub def
- { fbegin flength 3 -1 roll aload pop 4 packedarray
- exch f2dict exch get exch posdict 3 1 roll put
- }
- forall
- }
-forall
-all closefile
-(done.\n) print flush
-
-% Write the Fontmap addendum for accessing compressed fonts.
-(Writing ) print allmapname print (... ) print flush
-allmapname (w) file
-dup (%!
-/.runpackedlibfile where{pop}{(gs_pfile.ps)runlibfile}ifelse
-.currentglobal true .setglobal
-) writestring
-posdict
- { exch 2 index exch write==only exch dup ({) writestring
- dup allname write==only
- exch { 1 index dup ( ) writestring exch write==only } forall
- dup ( .runpackedlibfile}bind .definefontmap
-) writestring
- }
-forall
-dup (.setglobal
-) writestring
-closefile
-(done.\n) print flush
diff --git a/Master/tlpkg/tlgs/lib/pcharstr.ps b/Master/tlpkg/tlgs/lib/pcharstr.ps
deleted file mode 100644
index 7f38fc96670..00000000000
--- a/Master/tlpkg/tlgs/lib/pcharstr.ps
+++ /dev/null
@@ -1,125 +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.
-%
-
-% pcharstr.ps
-% Print the CharStrings and Subrs (if present) from a Type 1 font,
-% in either a PostScript-like or a C-compatible form,
-% depending on whether CSFormat is defined as /PS or /C.
-
-% Load the Type 1 utilities.
-(type1ops.ps) runlibfile
-
-% Define the printing procedures for PostScript-like output.
-/pcs_ps_dict mark
- /, {( ) print}
- /charname {==only}
- /csbegin {}
- /beginchars {(%---------------- CharStrings\n) print}
- /charbegin {==only}
- /char1 {( ) print ==only}
- /endchars {}
- /beginsubrs {(%---------------- Subrs\n) print}
- /subrbegin {=only}
- /endsubrs {}
- /beginboxes {(%---------------- Encoding & metrics\n) print}
- /notdefbox {}
- /boxbegin {=only ( ) print}
- /boxend {(\n) print}
- /endboxes {(%----------------\n) print}
-.dicttomark readonly def
-
-% Define the printing procedures for C-like output.
-/pcs_c_dict mark
- /, {(, ) print}
- /charname {(") print =only (") print}
- /csbegin {counttomark =only ,}
- /beginchars {(\nconstdata int CSCharData[] = {\n) print}
- /charbegin {pop}
- /char1 {=only ,}
- /endchars {
- (-1\n};\nconstdata char *CSCharNames[] = {\n) print
- CharStrings {pop charname ,} forall (0\n};\n) print
- }
- /beginsubrs {(\nconstdata int CSSubrs[] = {\n) print}
- /subrbegin {pop}
- /endsubrs {(-1\n};\n) print}
- /beginboxes {(\nconstdata type1_box CSboxes[] = {\n) print}
- /notdefbox {( {""},\n) print}
- /boxbegin {pop ( {) print}
- /boxend {(},) =}
- /endboxes {( {0}\n};\n) print}
-.dicttomark readonly def
-
-/printcs
- { dup type /stringtype eq
- { printcs1 (\n) print }
- { ( ) print == }
- ifelse
- } bind def
-/printcs1
- { save exch
- lenIV 0 ge {
- 4330 exch dup length string .type1decrypt exch pop
- dup length lenIV sub lenIV exch getinterval
- } if
- 0 () /SubFileDecode filter
- mark exch charstack_read csbegin
- counttomark 1 sub -1 0 { index char1 } for
- cleartomark restore
- } bind def
-
-/printfont
- { pcs_ps_dict
- /CSFormat where { pop CSFormat /C eq { pop pcs_c_dict } if } if
- begin
- currentfont begin Private begin 10 dict begin
-
- % Print the CharStrings and Subrs
-
- beginchars
- CharStrings { exch charbegin printcs } forall
- endchars
- /Subrs where
- { pop % the dictionary
- beginsubrs
- 0 1 Subrs length 1 sub
- { dup subrbegin
- Subrs exch get printcs
- } for
- endsubrs
- } if
-
- % Print the bounding boxes
-
- gsave nulldevice FontMatrix matrix invertmatrix concat
- beginboxes
- 0 1 Encoding length 1 sub
- { dup Encoding exch get dup /.notdef eq
- { pop pop notdefbox
- }
- { 1 index boxbegin charname ,
- ( ) dup 0 4 -1 roll put
- newpath 0 0 moveto false charpath
- pathbbox ({) print 4 -1 roll =only ,
- 3 -1 roll =only , exch =only , =only (}) print
- boxend
- }
- ifelse
- } for
- endboxes
- grestore
-
- end end end end
- } bind def
diff --git a/Master/tlpkg/tlgs/lib/pdfwrite.ps b/Master/tlpkg/tlgs/lib/pdfwrite.ps
deleted file mode 100644
index 8aa9dca1d4d..00000000000
--- a/Master/tlpkg/tlgs/lib/pdfwrite.ps
+++ /dev/null
@@ -1,396 +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.
-%
-
-% Writer for transmuting PDF files.
-
-% NOTES:
-% We do editing by replacing objects (in the cache) and then doing a
-% simple recursive walk with object renumbering.
-% Free variables:
-% RMap [per input file] (dict): input_obj# => output_obj#
-% PDFfile (file): current input file
-% OFile (file): current output file
-% XRef (dict): output_obj# => output_file_pos
-% ToWrite: 0..N-1 => [obj# gen#]
-
-.languagelevel 2 .setlanguagelevel
-.currentglobal true .setglobal
-
-/PDFWRDEBUG where { pop } { /PDFWRDEBUG false def } ifelse
-
-% ======== Long dictionary support =============== %
-
-% The key must be a non-negative iteger.
-
-/ld_dict { % <len> ld_dict <ldict>
- pop << 0 <<>> >>
-} bind def
-
-/ld_length { % <ldict> ld_length <length>
- 0 exch { exch pop length add } forall
-} bind def
-
-/ld_get { % <ldict> <key> ld_get <any>
- dup 3 1 roll -15 bitshift get exch get
-} bind def
-
-/ld_put { % <ldict> <key> <any> ld_put -
- 3 1 roll dup % any ldict key key
- 4 1 roll -15 bitshift % key any ldict key>>15
- 2 copy known {
- get % key any subdict
- 3 1 roll put % -
- } {
- 64 dict dup 6 1 roll % <<>> key any ldict key>>15 <<>>
- put put
- } ifelse % -
-} bind def
-
-/ld_known { % <ldict> <key> ld_known <bool>
- dup 3 1 roll -15 bitshift % key <<>> key<<15
- 2 copy known {
- get exch known
- } {
- pop pop pop //false
- } ifelse
-} bind def
-
-/ld_knownget { % <ldict> <key> ld_known false | <any> true
- dup 3 1 roll -15 bitshift % key <<>> key<<15
- 2 copy known {
- get exch .knownget
- } {
- pop pop pop //false
- } ifelse
-} bind def
-
-/ld_def { % <key> <any> ld_def -
- currentdict 3 1 roll ld_put
-} bind def
-
-/ld_forall { % <ldict> <proc} ld_forall -
- { forall exch pop } aload pop
- 4 2 roll 4 packedarray cvx forall
-} bind def
-
-/ld_clone { % <ldict> ld_clone <ldict copy>
- << exch { dup length dict copy } forall >>
-} bind def
-
-% ================ Object mapping ================ %
-
-% Initialize the object number and location map.
-/omapinit { % - omapinit -
- /RMap 100 ld_dict def
- /XRef 100 ld_dict def
- PDFWRDEBUG { (omapinit) = } if
-} bind def
-
-% Map an object number.
-/omapnew { % <oldobj#> omap <newobj#> <isnew>
- RMap 1 index ld_knownget {
- exch pop //false
- } {
- PDFWRDEBUG { (omap\() print dup =only } if
- RMap dup ld_length 1 add % old# <<>> len+1
- 2 index exch dup % old# <<>> old# len+1 len+1
- 5 1 roll % len+1 old# <<>> old# len+1
- ld_put pop //true % len+1 true
- PDFWRDEBUG { (\) = ) print 1 index = } if
- } ifelse
-} bind def
-/omap { % <oldobj#> omap <newobj#>
- omapnew pop
-} bind def
-
-% Save and restore the object map.
-% Note that currentomap either returns a copy or calls omapinit.
-/currentomap { % <copy> currentomap <omap>
- {
- [RMap ld_clone XRef ld_clone]
- } {
- [RMap XRef] omapinit
- } ifelse
-} bind def
-/setomap { % <omap> setomap -
- aload pop /XRef exch def /RMap exch def
- PDFWRDEBUG {
- (setomap: #Xref = ) print XRef ld_length =only
- (, #RMap = ) print RMap ld_length =
- } if
-} bind def
-
-% ================ Writing ================ %
-
-% ---------------- Low-level output ---------------- %
-
-% Write a string on the output file.
-/ows { % <string> ows -
- OFile exch writestring
-} bind def
-
-% ---------------- Scalars ---------------- %
-
-% Note that the '#' character isn't legal in a name unless it is a prefix
-% for a hex encoded character (for PDF 1.2 and later). The following assumes
-% that the names are already valid PDF 1.2+ names so that we can treat the
-% '#' as a legal character. The next two hex characters are already in the
-% set of valid name characters. PDF 1.1 and earlier allowed spaces in names
-% which probably wouldn't make it past the tokenizer anyway.
-/pdfnamechars
- (!"$&'*+,-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_`abcdefghijklmnopqrstuvwxyz|~)
-readonly def
-/pdfwritename { % <name> pdfwritename -
- (/) ows .namestring {
- ( ) dup 0 4 -1 roll put
- //pdfnamechars 1 index search {
- pop pop pop
- } {
- pop 0 get 256 add 16 =string cvrs
- dup 0 (#) 0 get put
- } ifelse ows
- } forall
-} bind def
-
-% ---------------- Composite objects ---------------- %
-
-/pdfwriteprocs mark
- /resolveR { pdfwriteref }
- /O { pdfwritenewref }
-.dicttomark readonly def
-/pdfwritearray { % <array> pdfwritearray -
- dup xcheck {
- aload pop //pdfwriteprocs exch get exec
- } {
- % Because of a bug in Acrobat's parser for linearization parameters,
- % we have to include some whitespace after the opening [ (!).
- ([ ) ows { pdfwritevalue (\n) ows } forall (]) ows
- } ifelse
-} bind def
-
-/pdfwritedict { % <dict> pdfwritedict -
- dup xcheck {
- pdfwritestream
- } {
- (<<) ows {
- exch pdfwritevalue ( ) ows pdfwritevalue (\n) ows
- } forall (>>) ows
- } ifelse
-} bind def
-
-% ---------------- References ---------------- %
-
-/pdfwritenewref { % <newobj#> pdfwritenewref -
- OFile exch write=only ( 0 R) ows
-} bind def
-
-/pdfwriteref { % <obj#> <gen#> pdfwriteref -
- 1 index omapnew {
- ToWrite dup length 5 -2 roll 2 packedarray put
- } {
- exch pop exch pop
- } ifelse
- pdfwritenewref
-} bind def
-
-/pdfcopystring 200 string def
-/pdfwritestream { % <streamdict> pdfwritestream -
- % Remove File, FilePosition, and StreamKey;
- % optimize by replacing an indirect Length.
- dup dup length dict copy
- % Stack: origdict dict
- dup /File undef dup /FilePosition undef dup /StreamKey undef
- dup /Length known {
- dup /Length get dup oforce ne {
- dup /Length 2 copy oget put
- } if
- } {
- 1 index /File get dup
- 3 index /FilePosition get setfileposition
- dup 0 (endstream) /SubFileDecode filter flushfile
- .fileposition 9 sub
- 2 index /FilePosition get sub
- 1 index exch /Length exch put
- } ifelse
- exch dup /File get dup 3 -1 roll /FilePosition get setfileposition
- pdfcopystream
-} bind def
-
-% We put copying the stream contents in separate procedures so that we
-% can replace this function if desired.
-/pdfcopybytes { % <fromfile> <tofile> <length> pdfcopybytes -
- {
- dup 0 eq { exit } if
- //pdfcopystring 0 2 index 2 index length .min getinterval
- 3 index exch readstring 3 1 roll
- 3 index 1 index writestring length sub exch not { exit } if
- } loop pop pop pop
-} bind def
-/pdfcopystream { % <newstreamdict> <file> pdfcopystream -
- % (file has been positioned)
- 1 index pdfwritevalue (stream\n) ows
- exch /Length get OFile exch pdfcopybytes
- (endstream) ows
-} bind def
-
-% ---------------- General values/objects ---------------- %
-
-/pdfwritetypes mark
- % Scalars
- /nulltype { pop (null) ows } bind
- /integertype { =string cvs ows } bind
- /booleantype 1 index
- /realtype {
- =string cvs
- (e) search { % PDF has no exponential format
- exch pop % exp pre
- exch cvi exch
- (-) anchorsearch { ows } if
- (.) search {
- exch pop % exp (frac) (int)
- 1 index length % exp (frac) (int) len
- 3 1 roll % exp len (frac) (int)
- exch concatstrings % exp len (int_frac)
- 3 1 roll sub % (int_frac) exp-len
- exch % exp-len (int_frac)
- } if % exp (mant)
- 1 index 0 ge {
- ows { (0) ows } repeat (.) ows
- } {
- dup length % exp (mant) len
- 3 -1 roll add % (mant) exp+len
- dup 0 le {
- (0.) ows neg { (0) ows } repeat ows
- } {
- 2 copy 0 exch getinterval ows
- (.) ows
- 1 index length 1 index sub getinterval ows
- } ifelse
- } ifelse
- } {
- ows
- } ifelse
- } bind
- /stringtype { OFile exch write===only } bind
- /nametype { pdfwritename } bind
- % Composite/reference objects
- /arraytype { pdfwritearray } bind
- /packedarraytype 1 index
- /dicttype { pdfwritedict } bind
-.dicttomark readonly def
-
-/pdfwritevalue { % <obj> pdfwritevalue -
- PDFWRDEBUG { (****Writing: ) print dup === flush } if
- //pdfwritetypes 1 index type get exec
-} bind def
-
-% We make pdfwriteobjdef a separate procedure for external use.
-/pdfwriteobjheader { % <newobj#> pdfwriteobjheader -
- XRef 1 index OFile .fileposition ld_put
- PDFWRDEBUG { (XRef\() print dup =only (\) = ) print XRef 1 index ld_get = } if
- OFile exch write=only ( 0 obj\n) ows
-} bind def
-/pdfwriteobjdef { % <newobj#> <value> pdfwriteobjdef -
- exch pdfwriteobjheader
- pdfwritevalue (\nendobj\n) ows
-} bind def
-/pdfwriteobj { % <obj#> <gen#> pdfwriteobj -
- 1 index exch resolveR exch omap exch pdfwriteobjdef
-} bind def
-
-% ---------------- File-level entities ---------------- %
-
-% Write a PDF file header.
-% Free variables: OFile, PDFversion.
-/pdfwriteheader { % - pdfwriteheader -
- (%PDF-) ows OFile PDFversion write=
- (%\347\363\317\323\n) ows
-} bind def
-
-% Write a cross-reference table and trailer.
-/pdfwritexref { % <firstobj#> <#objs> pdfwritexref -
- (xref\n) ows
- OFile 2 index write=only ( ) ows OFile 1 index write=
- 1 index add 1 sub 1 exch {
- dup 0 eq {
- pop (0000000000 65535 f \n) ows
- } {
- XRef exch ld_get 1000000000 add =string cvs
- dup 0 (0) 0 get put
- ows ( 00000 n \n) ows
- } ifelse
- } for
-} bind def
-/pdfwritetrailer { % <trailer> pdfwritetrailer -
- (trailer\n) ows
- % Since we always write a complete "classic" xref, the Trailer may need to be adjusted:
- % - remove keys that pertain to xref-streams and hybrid-xref PDFs;
- % - if it's a PDF stream, turn it into a PDF dict by removing keys used for
- % PDF streams (both standard and GS-specific), and the executable attribute
- dup /XRefStm known 1 index xcheck or {
- dup length dict copy
- dup {/Type/Index/W /XRefStm /Filter/DecodeParms/Length/File/FilePosition} {
- undef dup
- } forall pop
- % note: the executable attribute is "removed" by not being copied
- } if
- pdfwritevalue
- (\n) ows
-} bind def
-/pdfwritestartxref { % <startpos> pdfwritestartxref -
- (startxref\n) ows OFile exch write=
- (%%EOF\n) ows
-} bind def
-
-% ================ Top-level control ================ %
-
-/pdfwrite { % <file> <trailer> pdfwrite -
- 10 dict begin
- /trailer exch def
- /OFile exch def
- /ToWrite 100 dict def
- omapinit
-
- % Write the PDF file header.
-
- pdfwriteheader
-
- % Write the objects.
-
- trailer {
- exch pop dup xcheck { % The only executable objects are references.
- aload pop pop pdfwriteobj
- } {
- pop
- } ifelse
- } forall
- % Walk the object graph.
- {
- ToWrite dup length dup 0 eq { pop pop exit } if
- 1 sub 2 copy get 3 1 roll undef aload pop pdfwriteobj
- } loop
-
- % Write the xref table and trailer.
-
- /xref OFile fileposition def
- 0 XRef ld_length 1 add pdfwritexref
- trailer dup length 1 add dict copy trailer xcheck { cvx } if
- dup /Size XRef ld_length 1 add put pdfwritetrailer
- xref pdfwritestartxref
-
- end
-} bind def
-
-.setglobal .setlanguagelevel
diff --git a/Master/tlpkg/tlgs/lib/ps2ascii.ps b/Master/tlpkg/tlgs/lib/ps2ascii.ps
deleted file mode 100644
index 2b0e2d58109..00000000000
--- a/Master/tlpkg/tlgs/lib/ps2ascii.ps
+++ /dev/null
@@ -1,1523 +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.
-%
-
-% Extract the ASCII text from a PostScript file. Nothing is displayed.
-% Instead, ASCII information is written to stdout. The idea is similar to
-% Glenn Reid's `distillery', only a lot more simple-minded, and less robust.
-
-% If SIMPLE is defined, just the text is written, with a guess at line
-% breaks and word spacing. If SIMPLE is not defined, lines are written
-% to stdout as follows:
-%
-% F <height> <width> (<fontname>)
-% Indicate the font height and the width of a space.
-%
-% P
-% Indicate the end of the page.
-%
-% S <x> <y> (<string>) <width>
-% Display a string.
-%
-% <width> and <height> are integer dimensions in units of 1/720".
-% <x> and <y> are integer coordinates, in units of 1/720", with the origin
-% at the lower left.
-% <string> and <fontname> are strings represented with the standard
-% PostScript escape conventions.
-
-% If COMPLEX is defined, the following additional types of lines are
-% written to stdout.
-%
-% C <r> <g> <b>
-% Indicate the current color.
-%
-% I <x> <y> <width> <height>
-% Note the presence of an image.
-%
-% R <x> <y> <width> <height>
-% Fill a rectangle.
-%
-% <r>, <g>, and <b> are RGB values expressed as integers between 0 and 1000.
-%
-% Note that future versions of this program (in COMPLEX mode) may add
-% other output elements, so programs parsing the output should be
-% prepared to ignore elements that they do not recognize.
-
-% Note that this code will only work in all cases if systemdict is writable
-% and if `binding' the definitions of operators defined as procedures
-% is deferred. For this reason, it is normally invoked with
-% gs -q -dNODISPLAY -dDELAYBIND -dWRITESYSTEMDICT ps2ascii.ps
-
-% Thanks to:
-% J Greely <jgreely@cis.ohio-state.edu> for improvements to this code;
-% Jerry Whelan <jerryw@abode.ccd.bnl.gov> for motivating other improvements;
-% David M. Jones <dmjones@theory.lcs.mit.edu> for improvements noted below.
-
-%% Additional modifications by David M. Jones
-%% (dmjones@theory.lcs.mit.edu), December 23, 1997
-%%
-%% (a) Rewrote forall loop at the end of .show.write. This fixes a
-%% stack leakage problem, but the changes are more significant
-%% than that.
-%%
-%% .char.map includes the names of all characters in the
-%% StandardEncoding, ISOLatin1Encoding, OT1Encoding and
-%% T1Encoding vectors. Thus, if the Encoding vector for the
-%% current font contains a name that is not in .char.map, it's
-%% redundant to check if the Encoding vector is equal to one of
-%% the known vectors. Previous versions of ps2ascii would give
-%% up at this point, and substitute an asterisk (*) for the
-%% character. I've taken the liberty of instead using the
-%% OT1Encoding vector to translate the character, on the grounds
-%% that in the cases I'm most interested in, a font without a
-%% useful Encoding vector was most likely created by a DVI to PS
-%% converter such as dvips or DVILASER (and OT1Encoding is
-%% largely compatible with StandardEncoding anyway). [Note that
-%% this does not make my earlier changes to support dvips (see
-%% fix (a) under my 1996 changes) completely obsolete, since
-%% there's additional useful information I can extract in that
-%% case.]
-%%
-%% Overall, this should provide better support for some documents
-%% (e.g, DVILASER documents will no longer be translated into a
-%% series of *'s) without breaking any other documents any worse
-%% than they already were broken.
-%%
-%% (b) Fixed two bugs in dvips.df-tail: (1) changed "dup 127" to "dup
-%% 128" to fix fencepost error, and (2) gave each font it's own
-%% FontName rather than having all fonts share the same name.
-%%
-%% (c) Added one further refinement to the heuristic for detecting
-%% paragraph breaks: do not ever start a new paragraph after a
-%% line ending in a hyphen.
-%%
-%% (d) Added a bunch of missing letters from the T1Encoding,
-%% OT1Encoding and ISOLatin1Encoding vectors to .letter.chars to
-%% improve hyphen-elimination algorithm. This still won't help
-%% if there's no useful Encoding vector.
-%%
-%% NOTE: A better solution to the problem of missing Encoding vectors
-%% might be to redefine definefont to check whether the Encoding
-%% vector is sensible and, if not, replace it by a default. This
-%% would alleviate the need for constant tests in the .show.write
-%% loop, as well as automatically solving the problem noted in fix
-%% (d) above, and the similar problem with .break.chars. This should
-%% be investigated. Also, the hyphen-elimination algorithm really
-%% needs to be looked at carefully and rethought.
-
-%%* Modifications to ps2ascii.ps by David M. Jones
-%%* (dmjones@theory.lcs.mit.edu), June 25-July 8, 1996
-
-%%* Modifications:
-%%*
-%%* (a) added code to give better support for dvips files by providing
-%%* FontBBox's, FontName's and Encoding vectors for downloaded
-%%* bitmap fonts. This is done by using dvips's start-hook to
-%%* overwrite the df-tail and D procedures that dvips uses to
-%%* define its Type 3 bitmap fonts. Thus, this change should
-%%* provide better support for dvips-generated PS files without
-%%* affecting the handling of other documents.
-%%*
-%%* (b) Fixed two bugs that could potentially affect any PS file, not
-%%* just those created by dvips: (1) added missing "get" operator
-%%* in .show.write and (2) fixed bug that caused a hyphen at the
-%%* end of a line to be replaced by a space rather than begin
-%%* deleted. Note that the first bug was a source of stack
-%%* leakage, causing ps2ascii to run out of operand stack space
-%%* occasionally.
-%%*
-%%* Search for "%%* BF" to find these modifications.
-%%*
-%%* (c) Improved the heuristic for determining whether a line break
-%%* has occurred and whether a line break represents a paragraph
-%%* break. Previously, any change in the vertical position caused
-%%* a line break; now a line break is only registered if the
-%%* change is larger than the height of the current font. This
-%%* means that superscripts, subscripts, and such things as
-%%* shifted accents generated by TeX won't cause line breaks.
-%%* Paragraph-recognition is now done by comparing the indentation
-%%* of the new line to the indentation of the previous line and by
-%%* comparing the vertical distance between the new line and the
-%%* previous line to the vertical distance between the previous
-%%* line and its predecessor.
-%%*
-%%* (d) Added a hook for renaming the files where stdout and stderr
-%%* go.
-%%*
-%%* In general, my additions or changes to the code are described in
-%%* comments beginning with "%%*". However, there are numerous other
-%%* places where I have either re-formatted code or added comments to
-%%* the code while I was trying to understand it. These are usually
-%%* not specially marked.
-%%*
-
-/QUIET true def
-systemdict wcheck { systemdict } { userdict } ifelse begin
-/.max where { pop } { /.max { 2 copy lt { exch } if pop } bind def } ifelse
-/COMPLEX dup where { pop true } { false } ifelse def
-/SIMPLE dup where { pop true } { false } ifelse def
-/setglobal where
- { pop currentglobal /setglobal load true setglobal }
- { { } }
-ifelse
-
-% Define a way to store and retrieve integers that survives save/restore.
-/.i.string0 (0 ) def
-/.i.string .i.string0 length string def
-/.iget { cvi } bind def
-/.iput { exch //.i.string exch copy cvs pop } bind def
-/.inew { //.i.string0 dup length string copy } bind def
-
-% We only want to redefine operators if they are defined already.
-
-/codef { 1 index where { pop def } { pop pop } ifelse } def
-
-% Redefine the end-of-page operators.
-
-/erasepage { } codef
-/copypage { SIMPLE { (\014) } { (P\n) } ifelse //print } codef
-/showpage { copypage erasepage initgraphics } codef
-
-% Redefine the fill operators to detect rectangles.
-
-/.orderrect % <llx> <lly> <urx> <ury> .orderrect <llx> <lly> <w> <h>
- { % Ensure llx <= urx, lly <= ury.
- 1 index 4 index lt { 4 2 roll } if
- dup 3 index lt { 3 1 roll exch } if
- exch 3 index sub exch 2 index sub
- } odef
-/.fillcomplex
- { % Do a first pass to see if the path is all rectangles in
- % the output coordinate system. We don't worry about overlapping
- % rectangles that might be partially not filled.
- % Stack: mark llx0 lly0 urx0 ury0 ... true mark x0 y0 ...
- mark true mark
- % Add a final moveto so we pick up any trailing unclosed subpath.
- 0 0 itransform moveto
- { .coord counttomark 2 gt
- { counttomark 4 gt { .fillcheckrect } { 4 2 roll pop pop } ifelse }
- if
- }
- { .coord }
- { cleartomark not mark exit }
- { counttomark -2 roll 2 copy counttomark 2 roll .fillcheckrect }
- pathforall cleartomark
- { .showcolor counttomark 4 idiv
- { counttomark -4 roll .orderrect
- (R ) //print .show==4
- }
- repeat pop
- }
- { cleartomark
- }
- ifelse
- } odef
-/.fillcheckrect
- { % Check whether the current subpath is a rectangle.
- % If it is, add it to the list of rectangles being accumulated;
- % if not exit the .fillcomplex loop.
- % The subpath has not been closed.
- % Stack: as in .fillcomplex, + newx newy
- counttomark 10 eq { 9 index 9 index 4 2 roll } if
- counttomark 12 ne { cleartomark not mark exit } if
- 12 2 roll
- % Check for the two possible forms of rectangles:
- % x0 y0 x0 y1 x1 y1 x1 y0 x0 y0
- % x0 y0 x1 y0 x1 y1 x0 y1 x0 y0
- 9 index 2 index eq 9 index 2 index eq and
- 10 index 9 index eq
- { % Check for first form.
- 7 index 6 index eq and 6 index 5 index eq and 3 index 2 index eq and
- }
- { % Check for second form.
- 9 index 8 index eq and
- 8 index 7 index eq and 5 index 4 index eq and 4 index 3 index eq and
- }
- ifelse not { cleartomark not mark exit } if
- % We have a rectangle.
- pop pop pop pop 4 2 roll pop pop 8 4 roll
- } odef
-/eofill { COMPLEX { .fillcomplex } if newpath } codef
-/fill { COMPLEX { .fillcomplex } if newpath } codef
-/rectfill { gsave newpath .rectappend fill grestore } codef
-/ueofill { gsave newpath uappend eofill grestore } codef
-/ufill { gsave newpath uappend fill grestore } codef
-
-% Redefine the stroke operators to detect rectangles.
-
-/rectstroke
- { gsave newpath
- dup type dup /arraytype eq exch /packedarraytype eq or
- { dup length 6 eq { exch .rectappend concat } { .rectappend } ifelse }
- { .rectappend }
- ifelse stroke grestore
- } codef
-/.strokeline % <fromx> <fromy> <tox> <toy> .strokeline <tox> <toy>
- % Note: fromx and fromy are in output coordinates;
- % tox and toy are in user coordinates.
- { .coord 2 copy 6 2 roll .orderrect
- % Add in the line width. Assume square or round caps.
- currentlinewidth 2 div dup .dcoord add abs 1 .max 5 1 roll
- 4 index add 4 1 roll 4 index add 4 1 roll
- 4 index sub 4 1 roll 5 -1 roll sub 4 1 roll
- (R ) //print .show==4
- } odef
-/.strokecomplex
- { % Do a first pass to see if the path is all horizontal and vertical
- % lines in the output coordinate system.
- % Stack: true mark origx origy curx cury
- true mark null null null null
- { .coord 6 2 roll pop pop pop pop 2 copy }
- { .coord 1 index 4 index eq 1 index 4 index eq or
- { 4 2 roll pop pop }
- { cleartomark not mark exit }
- ifelse
- }
- { cleartomark not mark exit }
- { counttomark -2 roll 2 copy counttomark 2 roll
- 1 index 4 index eq 1 index 4 index eq or
- { pop pop 2 copy }
- { cleartomark not mark exit }
- ifelse
- }
- pathforall cleartomark
- 0 currentlinewidth .dcoord 0 eq exch 0 eq or and
- % Do the second pass to write out the rectangles.
- % Stack: origx origy curx cury
- { .showcolor null null null null
- { 6 2 roll pop pop pop pop 2 copy .coord }
- { .strokeline }
- { }
- { 3 index 3 index .strokeline }
- pathforall pop pop pop pop
- }
- if
- } odef
-/stroke { COMPLEX { .strokecomplex } if newpath } codef
-/ustroke
- { gsave newpath
- dup length 6 eq { exch uappend concat } { uappend } ifelse
- stroke grestore
- } codef
-
-% The image operators must read the input and note the dimensions.
-% Eventually we should redefine these to detect 1-bit-high all-black images,
-% since this is how dvips does underlining (!).
-
-/.noteimagerect % <width> <height> <matrix> .noteimagerect -
- { COMPLEX
- { gsave setmatrix itransform 0 0 itransform
- grestore .coord 4 2 roll .coord .orderrect
- (I ) //print .show==4
- }
- { pop pop pop
- }
- ifelse
- } odef
-/colorimage where
- { pop /colorimage
- { 1 index
- { dup 6 add index 1 index 6 add index 2 index 5 add index }
- { 6 index 6 index 5 index }
- ifelse .noteimagerect gsave nulldevice //colorimage grestore
- } codef
- } if
-/.noteimage % Arguments as for image[mask]
- { dup type /dicttype eq
- { dup /Width get 1 index /Height get 2 index /ImageMatrix get }
- { 4 index 4 index 3 index }
- ifelse .noteimagerect
- } odef
-/image { .noteimage gsave nulldevice //image grestore } codef
-/imagemask { .noteimage gsave nulldevice //imagemask grestore } codef
-
-% Output the current color if necessary.
-/.color.r .inew def
- .color.r -1 .iput % make sure we write the color at the beginning
-/.color.g .inew def
-/.color.b .inew def
-/.showcolor
- { COMPLEX
- { currentrgbcolor
- 1000 mul round cvi
- 3 1 roll 1000 mul round cvi
- exch 1000 mul round cvi
- % Stack: b g r
- dup //.color.r .iget eq
- 2 index //.color.g .iget eq and
- 3 index //.color.b .iget eq and
- { pop pop pop
- }
- { (C ) //print
- dup //.color.r exch .iput .show==only
- ( ) //print dup //.color.g exch .iput .show==only
- ( ) //print dup //.color.b exch .iput .show==only
- (\n) //print
- }
- ifelse
- }
- if
- } bind def
-
-% Redefine `show'.
-
-% Set things up so our output will be in tenths of a point, with origin at
-% lower left. This isolates us from the peculiarities of individual devices.
-
-/.show.ident.matrix matrix def
-/.show.ident { % - .show.ident <scale> <matrix>
-% //.show.ident.matrix defaultmatrix
-% % Assume the original transformation is well-behaved.
-% 0.1 0 2 index dtransform abs exch abs .max /.show.scale exch def
-% 0.1 dup 3 -1 roll scale
- gsave initmatrix
- % Assume the original transformation is well-behaved...
- 0.1 0 dtransform abs exch abs .max
- 0.1 dup scale .show.ident.matrix currentmatrix
- % ... but undo any rotation into landscape orientation.
- dup 0 get 0 eq {
- 1 get dup abs div 90 mul rotate
- .show.ident.matrix currentmatrix
- } if
- grestore
-} bind def
-
-/.coord { % <x> <y> .coord <x'> <y'>
- transform .show.ident exch pop itransform
- exch round cvi exch round cvi
-} odef
-
-/.dcoord { % <dx> <dy> .coord <dx'> <dy'>
- % Transforming distances is trickier, because
- % the coordinate system might be rotated.
- .show.ident pop 3 1 roll
- exch 0 dtransform
- dup mul exch dup mul add sqrt
- 2 index div round cvi
- exch 0 exch dtransform
- dup mul exch dup mul add sqrt
- 3 -1 roll div round cvi
-} odef
-
-% Remember the current X, Y, and height.
-/.show.x .inew def
-/.show.y .inew def
-/.show.height .inew def
-
-% Remember the last character of the previous string; if it was a
-% hyphen preceded by a letter, we didn't output the hyphen.
-
-/.show.last (\000) def
-
-% Remember the current font.
-/.font.name 130 string def
-/.font.name.length .inew def
-/.font.height .inew def
-/.font.width .inew def
-
-%%* Also remember indentation of current line and previous vertical
-%%* skip
-
-/.show.indent .inew def
-/.show.dy .inew def
-
-% We have to redirect stdout somehow....
-
-/.show.stdout { (%stdout) (w) file } bind def
-
-% Make sure writing will work even if a program uses =string.
-/.show.string =string length string def
-/.show.=string =string length string def
-/.show==only
- { //=string //.show.=string copy pop
- dup type /stringtype eq
- { dup length //.show.string length le
- { dup rcheck { //.show.string copy } if
- } if
- } if
- .show.stdout exch write==only
- //.show.=string //=string copy pop
- } odef
-/.show==4
- { 4 -1 roll .show==only ( ) //print
- 3 -1 roll .show==only ( ) //print
- exch .show==only ( ) //print
- .show==only (\n) //print
- } odef
-
-/.showwidth % Same as stringwidth, but disable COMPLEX so that
- % we don't try to detect rectangles during BuildChar.
- { COMPLEX
- { /COMPLEX false def stringwidth /COMPLEX true def }
- { stringwidth }
- ifelse
- } odef
-
-/.showfont % <string> .showfont <string>
- { gsave
- % Try getting the height and width of the font from the FontBBox.
- currentfont /FontBBox .knownget not { {0 0 0 0} } if
- aload pop % llx lly urx ury
- exch 4 -1 roll % lly ury urx llx
- sub % lly ury dx
- 3 1 roll exch % dx ury lly
- sub % dx dy
- 2 copy .max 0 ne
- { currentfont /FontMatrix get dtransform
- }
- { pop pop
- % Fonts produced by dvips, among other applications, have
- % BuildChar procedures that bomb out when given unexpected
- % characters, and there is no way to determine whether a given
- % character will do this. So for Type 1 fonts, we measure a
- % typical character ('X'); for others, we punt.
- currentfont /FontType get 1 eq
- { (X) .showwidth pop dup 1.3 mul
- }
- { % No safe way to get the character size. Punt.
- 0 0
- }
- ifelse
- }
- ifelse .dcoord exch
- currentfont /FontName .knownget not { () } if
- dup type /stringtype ne { //.show.string cvs } if
- grestore
- % Stack: height width fontname
- SIMPLE
- { pop pop //.show.height exch .iput }
- { 2 index //.font.height .iget eq
- 2 index //.font.width .iget eq and
- 1 index //.font.name 0 //.font.name.length .iget getinterval eq and
- { pop pop pop
- }
- { (F ) //print
- 3 -1 roll dup //.font.height exch .iput .show==only ( ) //print
- exch dup //.font.width exch .iput .show==only ( ) //print
- dup length //.font.name.length exch .iput
- //.font.name cvs .show==only (\n) //print
- }
- ifelse
- }
- ifelse
- } odef
-
-% Define the letters -- characters which, if they occur followed by a hyphen
-% at the end of a line, cause the hyphen and line break to be ignored.
-/.letter.chars 100 dict def
-mark
- 65 1 90 { dup 32 add } for
- counttomark
- { StandardEncoding exch get .letter.chars exch dup put }
- repeat
-pop
-
-%%* Add the rest of the letters from the [O]T1Encoding and
-%%* ISOLatin1Encoding vectors
-
-mark
- /AE
- /Aacute
- /Abreve
- /Acircumflex
- /Adieresis
- /Agrave
- /Aogonek
- /Aring
- /Atilde
- /Cacute
- /Ccaron
- /Ccedilla
- /Dcaron
- /Eacute
- /Ecaron
- /Ecircumflex
- /Edieresis
- /Egrave
- /Eng
- /Eogonek
- /Eth
- /Gbreve
- /Germandbls
- /IJ
- /Iacute
- /Icircumflex
- /Idieresis
- /Idot
- /Igrave
- /Lacute
- /Lcaron
- /Lslash
- /Nacute
- /Ncaron
- /Ntilde
- /OE
- /Oacute
- /Ocircumflex
- /Odieresis
- /Ograve
- /Ohungarumlaut
- /Oslash
- /Otilde
- /Racute
- /Rcaron
- /Sacute
- /Scaron
- /Scedilla
- /Tcaron
- /Tcedilla
- /Thorn
- /Uacute
- /Ucircumflex
- /Udieresis
- /Ugrave
- /Uhungarumlaut
- /Uring
- /Yacute
- /Ydieresis
- /Zacute
- /Zcaron
- /Zdot
- /aacute
- /abreve
- /acircumflex
- /adieresis
- /ae
- /agrave
- /aogonek
- /aring
- /atilde
- /cacute
- /ccaron
- /ccedilla
- /dbar
- /dcaron
- /dotlessi
- /dotlessj
- /eacute
- /ecaron
- /ecircumflex
- /edieresis
- /egrave
- /eng
- /eogonek
- /eth
- /exclamdown
- /ff
- /ffi
- /ffl
- /fi
- /fl
- /gbreve
- /germandbls
- /iacute
- /icircumflex
- /idieresis
- /igrave
- /ij
- /lacute
- /lcaron
- /lslash
- /nacute
- /ncaron
- /ntilde
- /oacute
- /ocircumflex
- /odieresis
- /oe
- /ograve
- /ohungarumlaut
- /oslash
- /otilde
- /questiondown
- /racute
- /rcaron
- /sacute
- /scaron
- /scedilla
- /section
- /sterling
- /tcaron
- /tcedilla
- /thorn
- /uacute
- /ucircumflex
- /udieresis
- /ugrave
- /uhungarumlaut
- /uring
- /yacute
- /ydieresis
- /zacute
- /zcaron
- /zdot
-counttomark
- { .letter.chars exch dup put }
-repeat
-pop
-
-% Define a set of characters which, if they occur at the start of a line,
-% are taken as indicating a paragraph break.
-/.break.chars 50 dict def
-mark
- /bullet /dagger /daggerdbl /periodcentered /section
- counttomark
- { .break.chars exch dup put }
- repeat
-pop
-
-% Define character translation to ASCII.
-% We have to do this for the entire character set.
-
-/.char.map 500 dict def
-
-/.chars.def { counttomark 2 idiv { .char.map 3 1 roll put } repeat pop } def
-
-% Encode the printable ASCII characters.
-
-mark 32 1 126
- { 1 string dup 0 4 -1 roll put
- dup 0 get StandardEncoding exch get exch
- }
-for .chars.def
-
- % Encode accents.
-mark
- /acute (')
- /caron (^)
- /cedilla (,)
- /circumflex (^)
- /dieresis (")
- /grave (`)
- /ring (*)
- /tilde (~)
-.chars.def
-
- % Encode the ISO accented characters.
-mark 192 1 255
- { ISOLatin1Encoding exch get =string cvs
- dup 0 1 getinterval 1 index dup length 1 sub 1 exch getinterval
- .char.map 2 index known .char.map 2 index known and
- { .char.map 3 -1 roll get .char.map 3 -1 roll get concatstrings
- .char.map 3 1 roll put
- }
- { pop pop pop
- }
- ifelse
- }
-for .chars.def
-
-% Encode the remaining standard and ISO alphabetic characters.
-
-mark
- /AE (AE) /Eth (DH) /OE (OE) /Thorn (Th)
- /ae (ae) /eth (dh)
- /ffi (ffi) /ffl (ffl) /fi (fi) /fl (fl)
- /germandbls (ss) /oe (oe) /thorn (th)
-.chars.def
-
-% Encode the other standard and ISO characters.
-
-mark
- /brokenbar (|) /bullet (*) /copyright ((C)) /currency (#)
- /dagger (#) /daggerdbl (##) /degree (o) /divide (/) /dotaccent (.)
- /dotlessi (i)
- /ellipsis (...) /emdash (--) /endash (-) /exclamdown (!)
- /florin (f) /fraction (/)
- /guillemotleft (<<) /guillemotright (>>)
- /guilsinglleft (<) /guilsinglright (>) /hungarumlaut ("") /logicalnot (~)
- /macron (_) /minus (-) /mu (u) /multiply (*)
- /ogonek (,) /onehalf (1/2) /onequarter (1/4) /onesuperior (1)
- /ordfeminine (-a) /ordmasculine (-o)
- /paragraph (||) /periodcentered (*) /perthousand (o/oo) /plusminus (+-)
- /questiondown (?) /quotedblbase (") /quotedblleft (") /quotedblright (")
- /quotesinglbase (,) /quotesingle (') /registered ((R))
- /section ($) /sterling (#)
- /threequarters (3/4) /threesuperior (3) /trademark ((TM)) /twosuperior (2)
- /yen (Y)
-.chars.def
-
-% Encode a few common Symbol characters.
-
-mark
- /asteriskmath (*) /copyrightsans ((C)) /copyrightserif ((C))
- /greaterequal (>=) /lessequal (<=) /registersans ((R)) /registerserif ((R))
- /trademarksans ((TM)) /trademarkserif ((TM))
-.chars.def
-
-%%* Add a few characters from StandardEncoding and ISOLatin1Encoding
-%%* that were missing.
-
-mark
- /cent (c)
- /guilsinglleft (<)
- /guilsinglright (>)
- /breve (*)
- /Lslash (L/)
- /lslash (l/)
-.chars.def
-
-%%* Define the OT1Encoding and T1Encoding vectors for use with dvips
-%%* files. Unfortunately, there's no way of telling what font is
-%%* really being used within a dvips document, so we can't provide an
-%%* appropriate encoding for each individual font. Instead, we'll
-%%* just provide support for the two most popular text encodings, the
-%%* OT1 and T1 encodings, and just accept the fact that any font not
-%%* using one of those encodings will be rendered as gibberish.
-%%*
-%%* OT1 is Knuth's 7-bit encoding for the CMR text fonts, while T1
-%%* (aka the Cork encoding) is the 8-bit encoding used by the DC
-%%* fonts, a preliminary version of the proposed Extended Computer
-%%* Modern fonts. Unfortunately, T1 is not a strict extension of OT1;
-%%* they differ in positions 8#000 through 8#040, 8#074, 8#076, 8#134,
-%%* 8#137, 8#173, 8#174, 8#175 and 8#177, so we can't use the same
-%%* vector for both.
-%%*
-%%* Of course, we also can't reliably tell the difference between an
-%%* OT1-encoded font and a T1-encoded font based on the information in
-%%* a dvips-created PostScript file. As a best-guess solution, we'll
-%%* use the T1 encoding if the font contains any characters in
-%%* positions above 8#177 and the OT1 encoding if it doesn't.
-
-/T1Encoding 256 array def
-
-/OT1Encoding 256 array def
-
-%%* T1Encoding shares a lot with StandardEncoding, so let's start
-%%* there.
-
-StandardEncoding T1Encoding copy pop
-
-/OT1.encode {
- counttomark
- 2 idiv
- { OT1Encoding 3 1 roll put }
- repeat
- cleartomark
-} def
-
-/T1.encode {
- counttomark
- 2 idiv
- { T1Encoding 3 1 roll put }
- repeat
- cleartomark
-} def
-
-mark
- 8#000 /grave
- 8#001 /acute
- 8#002 /circumflex
- 8#003 /tilde
- 8#004 /dieresis
- 8#005 /hungarumlaut
- 8#006 /ring
- 8#007 /caron
-
- 8#010 /breve
- 8#011 /macron
- 8#012 /dotaccent
- 8#013 /cedilla
- 8#014 /ogonek
- 8#015 /quotesinglbase
- 8#016 /guilsinglleft
- 8#017 /guilsinglright
-
- 8#020 /quotedblleft
- 8#021 /quotedblright
- 8#022 /quotedblbase
- 8#023 /guillemotleft
- 8#024 /guillemotright
- 8#025 /endash
- 8#026 /emdash
- 8#027 /cwm
-
- 8#030 /perthousandzero
- 8#031 /dotlessi
- 8#032 /dotlessj
- 8#033 /ff
- 8#034 /fi
- 8#035 /fl
- 8#036 /ffi
- 8#037 /ffl
-
-%% 8#040 through 8#176 follow StandardEncoding
-
- 8#177 /hyphen
-T1.encode
-
-mark
- 8#200 /Abreve
- 8#201 /Aogonek
- 8#202 /Cacute
- 8#203 /Ccaron
- 8#204 /Dcaron
- 8#205 /Ecaron
- 8#206 /Eogonek
- 8#207 /Gbreve
- 8#210 /Lacute
- 8#211 /Lcaron
- 8#212 /Lslash
- 8#213 /Nacute
- 8#214 /Ncaron
- 8#215 /Eng
- 8#216 /Ohungarumlaut
- 8#217 /Racute
- 8#220 /Rcaron
- 8#221 /Sacute
- 8#222 /Scaron
- 8#223 /Scedilla
- 8#224 /Tcaron
- 8#225 /Tcedilla
- 8#226 /Uhungarumlaut
- 8#227 /Uring
- 8#230 /Ydieresis
- 8#231 /Zacute
- 8#232 /Zcaron
- 8#233 /Zdot
- 8#234 /IJ
- 8#235 /Idot
- 8#236 /dbar
- 8#237 /section
- 8#240 /abreve
- 8#241 /aogonek
- 8#242 /cacute
- 8#243 /ccaron
- 8#244 /dcaron
- 8#245 /ecaron
- 8#246 /eogonek
- 8#247 /gbreve
- 8#250 /lacute
- 8#251 /lcaron
- 8#252 /lslash
- 8#253 /nacute
- 8#254 /ncaron
- 8#255 /eng
- 8#256 /ohungarumlaut
- 8#257 /racute
- 8#260 /rcaron
- 8#261 /sacute
- 8#262 /scaron
- 8#263 /scedilla
- 8#264 /tcaron
- 8#265 /tcedilla
- 8#266 /uhungarumlaut
- 8#267 /uring
- 8#270 /ydieresis
- 8#271 /zacute
- 8#272 /zcaron
- 8#273 /zdot
- 8#274 /ij
- 8#275 /exclamdown
- 8#276 /questiondown
- 8#277 /sterling
-
- 8#300 /Agrave
- 8#301 /Aacute
- 8#302 /Acircumflex
- 8#303 /Atilde
- 8#304 /Adieresis
- 8#305 /Aring
- 8#306 /AE
- 8#307 /Ccedilla
- 8#310 /Egrave
- 8#311 /Eacute
- 8#312 /Ecircumflex
- 8#313 /Edieresis
- 8#314 /Igrave
- 8#315 /Iacute
- 8#316 /Icircumflex
- 8#317 /Idieresis
- 8#320 /Eth
- 8#321 /Ntilde
- 8#322 /Ograve
- 8#323 /Oacute
- 8#324 /Ocircumflex
- 8#325 /Otilde
- 8#326 /Odieresis
- 8#327 /OE
- 8#330 /Oslash
- 8#331 /Ugrave
- 8#332 /Uacute
- 8#333 /Ucircumflex
- 8#334 /Udieresis
- 8#335 /Yacute
- 8#336 /Thorn
- 8#337 /Germandbls
-
- 8#340 /agrave
- 8#341 /aacute
- 8#342 /acircumflex
- 8#343 /atilde
- 8#344 /adieresis
- 8#345 /aring
- 8#346 /ae
- 8#347 /ccedilla
- 8#350 /egrave
- 8#351 /eacute
- 8#352 /ecircumflex
- 8#353 /edieresis
- 8#354 /igrave
- 8#355 /iacute
- 8#356 /icircumflex
- 8#357 /idieresis
- 8#360 /eth
- 8#361 /ntilde
- 8#362 /ograve
- 8#363 /oacute
- 8#364 /ocircumflex
- 8#365 /otilde
- 8#366 /odieresis
- 8#367 /oe
- 8#370 /oslash
- 8#371 /ugrave
- 8#372 /uacute
- 8#373 /ucircumflex
- 8#374 /udieresis
- 8#375 /yacute
- 8#376 /thorn
- 8#377 /germandbls
-
-T1.encode
-
-%%* Now copy OT1Encoding into T1Encoding and make a few changes.
-
-T1Encoding OT1Encoding copy pop
-
-mark
- 8#000 /Gamma
- 8#001 /Delta
- 8#002 /Theta
- 8#003 /Lambda
- 8#004 /Xi
- 8#005 /Pi
- 8#006 /Sigma
- 8#007 /Upsilon
-
- 8#010 /Phi
- 8#011 /Psi
- 8#012 /Omega
- 8#013 /ff
- 8#014 /fi
- 8#015 /fl
- 8#016 /ffi
- 8#017 /ffl
-
- 8#020 /dotlessi
- 8#021 /dotlessj
- 8#022 /grave
- 8#023 /acute
- 8#024 /caron
- 8#025 /breve
- 8#026 /macron
- 8#027 /ring
-
- 8#030 /cedilla
- 8#031 /germandbls
- 8#032 /ae
- 8#033 /oe
- 8#034 /oslash
- 8#035 /AE
- 8#036 /OE
- 8#037 /Oslash
-
- 8#040 /polishslash
-
- 8#042 /quotedblright
-
- 8#074 /exclamdown
- 8#076 /questiondown
-
- 8#134 /quotedblleft
- 8#137 /dotaccent
-
- 8#173 /endash
- 8#174 /emdash
- 8#175 /hungarumlaut
- 8#177 /dieresis
-OT1.encode
-
-%%* And add a few characters from the OT1Encoding
-
-mark
- /Gamma (\\Gamma )
- /Delta (\\Delta )
- /Theta (\\Theta )
- /Lambda (\\Lambda )
- /Xi (\\Xi )
- /Pi (\\Pi )
- /Sigma (\\Sigma )
- /Upsilon (\\Upsilon )
-
- /Phi (\\Phi )
- /Psi (\\Psi )
- /Omega (\\Omega )
-
- /dotlessj (j)
- /ff (ff)
-
- /cwm ()
-
- /perthousandzero (0)
-
- /polishslash ()
-
- /Abreve (A*)
- /Aogonek (A,)
- /Cacute (C')
- /Ccaron (C^)
- /Dcaron (D^)
- /Ecaron (E^)
- /Eogonek (E,)
- /Gbreve (G*)
- /Lacute (L')
- /Lcaron (L^)
- /Nacute (N')
- /Ncaron (N^)
- /Eng (NG)
- /Ohungarumlaut (O"")
- /Racute (R')
- /Rcaron (R^)
- /Sacute (S')
- /Scaron (S^)
- /Scedilla (S,)
- /Tcaron (T^)
- /Tcedilla (T,)
- /Uhungarumlaut (U"")
- /Uring (U*)
- /Ydieresis (Y")
- /Zacute (Z')
- /Zcaron (Z^)
- /Zdot (Z.)
- /IJ (IJ)
- /Idot (I.)
- /dbar (d-)
- /abreve (a*)
- /aogonek (a,)
- /cacute (c')
- /ccaron (c^)
- /dcaron (d^)
- /ecaron (e^)
- /eogonek (e,)
- /gbreve (g*)
- /lacute (l')
- /lcaron (l^)
- /nacute (n')
- /ncaron (n^)
- /eng (ng)
- /ohungarumlaut (o"")
- /racute (r')
- /rcaron (r^)
- /sacute (s')
- /scaron (s^)
- /scedilla (s,)
- /tcaron (t^)
- /tcedilla (t,)
- /uhungarumlaut (u"")
- /uring (u*)
- /zacute (z')
- /zcaron (z^)
- /zdot (z.)
- /ij (ij)
- /Germandbls (SS)
-.chars.def
-
-%%* We extend the df-tail command to stick in an Encoding vector (see
-%%* above for a discussion of the T1 and OT1 encodings), put in a
-%%* FontName (which will just be dvips's name for the font, i.e., Fa,
-%%* Fb, etc.) and give each font a separate FontBBox instead of
-%%* letting them all share a single one.
-
-/dvips.df-tail % id numcc maxcc df-tail
- {
- /nn 9 dict N
- nn begin
- %%
- %% Choose an encoding based on the highest position occupied.
- %%
- dup 128 gt { T1Encoding } { OT1Encoding } ifelse
- /Encoding X
- /FontType 3 N
- %%
- %% It's ok for all the fonts to share a FontMatrix, but they
- %% need to have separate FontBBoxes
- %%
- /FontMatrix fntrx N
- /FontBBox [0 0 0 0] N
- string /base X
- array /BitMaps X
- %%
- %% And let's throw in a FontName for good measure
- %%
- dup ( ) cvs
- %%
- %% Make sure each font gets it own private FontName. -- dmj,
- %% 12/23/97
- %%
- dup length string copy
- /FontName X
- /BuildChar {CharBuilder} N
- end
- dup { /foo setfont }
- 2 array copy cvx N
- load
- 0 nn put
- /ctr 0 N
- [
-} def
-
-%%* This is functionally equivalent to dvips's /D procedure, but it
-%%* also calculates the Font Bounding Box while defining the
-%%* characters.
-
-/dvips.D % char-data ch D - : define character bitmap in current font
-{
- /cc X % char-data
- dup type /stringtype ne {]} if % char-data
-
- /ch-xoff where
- { pop }
- { dup /Cd exch def
- /ch-width { Cw } def
- /ch-height { Ch } def
- /ch-xoff { Cx } def
- /ch-yoff { Cy } def
- /ch-dx { Cdx } def
- } ifelse
- /ch-data X
- nn /base get cc ctr put % (adds ctr to cc'th position of BASE)
- nn /BitMaps get
- ctr
- ch-data % BitMaps ctr char-data
- sf 1 ne {
- dup dup length 1 sub dup 2 index S get sf div put
- } if
- put % puts char-data into BitMaps at index ctr
- /ctr ctr 1 add N
-%%
-%% Make sure the Font Bounding Box encloses the Bounding Box of the
-%% current character
-%%
- nn /FontBBox get % BB
-
- dup % calculate new llx
- dup 0 get
- ch-xoff
- .min
- 0 exch put
-
- dup % calculate new lly
- dup 1 get
- ch-yoff ch-height sub
- .min
- 1 exch put
-
- dup % calculate new urx
- dup 2 get
- ch-dx ch-width add
- .max
- 2 exch put
-
- dup 3 get % calculate new ury
- ch-yoff
- .max
- 3 exch put
-
-} def
-
-%%* Define start-hook to replace df-tail and D by our versions.
-%%* Unfortunately, the user can redefine start-hook and thus bypass
-%%* these changes, but I don't see an obvious way around that.
-
-userdict /start-hook {
- TeXDict /df-tail /dvips.df-tail load bind put
- TeXDict /D /dvips.D load bind put
-} put
-
-%%* Introduce a symbolic constant for hyphens. (Need to make
-%%* allowance for hyphen being in different place?)
-
-/.hyphen 45 def
-
-% Write out a string. If it ends in a letter and a hyphen,
-% don't write the hyphen, and set .show.last to a hyphen;
-% otherwise, set .show.last to the character (or \000 if it was a hyphen).
-/.show.write % <string>
- {
- dup length 1 ge
- { dup dup length 1 sub get % string last_char
- dup .hyphen eq % string last_char hyphen?
- { % string last_char
- 1 index length 1 gt
- { 1 index dup length 2 sub get }
- { //.show.last 0 get }
- ifelse % string last_char prev-char
- currentfont /Encoding get exch get % look up prev-char
- //.letter.chars exch known % is it a letter?
- { % Remove the hyphen % string last_char
- exch % last_char string
- dup length 1 sub % last_char string len-1
- 0 exch getinterval % last_char string-1
- exch % string-1 last_char
- }
- { pop 0 } % string 0
- ifelse
- }
- if
- //.show.last 0 3 -1 roll put % store last_char
- % in .show.last
- % If .show.last ==
- % hyphen, then
- % last char of
- % previous string
- % was a hyphen
- }
- if % string
- currentfont /FontType get 0 ne
- {
- { % begin forall % c
- dup % c c
- currentfont /Encoding get % c c vec
- exch get % c name
- dup //.char.map exch known % c name bool
- { exch pop }
- { pop OT1Encoding exch get }
- ifelse % name
- //.char.map exch get % translation
- .show.stdout exch writestring
- }
- forall
- }
- { (\0) dup 0 get 0 eq
- { 0 1 put
- (%stderr) (w) file dup
- (*** Warning: composite font characters dumped without decoding.\n) writestring
- closefile
- }
- { pop
- }
- ifelse
- .show.stdout exch writestring
- }
- ifelse
-} odef
-
-/.showstring1 { % string
- currentpoint .coord % string x y
- 3 -1 roll dup .showwidth % x y string dx dy
- 1 index % x y string dx dy dx
- 0 rmoveto % x y string dx dy
- .dcoord pop % x y string width
- SIMPLE
- { % x y string width
- 2 index % x y string width y
- //.show.y .iget % x y string width y old.y
- %%*
- %%* Replaced test "has y changed" by "has y changed by more
- %%* than the current font height" so that subscripts and
- %%* superscripts won't cause line/paragraph breaks
- %%*
- sub abs dup % x y string width dy dy
- //.show.height .iget
- gt
- { % x y string width dy
-
- %%* Vertical position has changed by more than the font
- %%* height, so we now try to figure out whether we've
- %%* started a new paragraph or merely a new line, using a
- %%* variety of heuristics.
-
- %%* If any of the following is true, we start a new
- %%* paragraph:
-
- %%* (a) the current vertical shift is more than 1.1 times
- %%* the previous vertical shift, where 1.1 is an
- %%* arbitrarily chosen factor that could probably be
- %%* refined.
-
- dup % x y string width dy dy
- //.show.dy .iget 1.1 mul
- gt
- exch
-
- %%* Save the new vertical shift
-
- //.show.dy exch .iput
-
- %%* (b) The vertical shift is more than 1.3 times the
- %%* "size" of the current font. I've removed this
- %%* test since it's not really very useful.
-
-%%* //.show.dy .iget
-%%* //.show.height .iget 1.4 mul
-%%* gt % x y string width bool
-%%* .show.height .iget 0 gt and % only perform test if font
-%%* % height is nonzero
-%%* or
-
- %%* (c) the first character of the new line is one of the
- %%* .break.chars
-
- 2 index length % x y string width newpar? len
- 0 gt % x y string width newpar? len>0?
- {
- 2 index 0 get % x y string width newpar? s
- currentfont /Encoding get
- exch get % x y string width newpar? s_enc
- //.break.chars exch known { pop true } if
- }
- if % x y string width newpar?
-
- %%* (d) The indentation of the new line is greater than
- %%* the indentation of the previous line.
-
- 4 index
- //.show.indent .iget
- gt
- or
-
- %%* HOWEVER, if the line ends in a hyphen, we do NOT begin
- %%* a new paragraph (cf. comment at end of BF2). --dmj,
- %%* 12/23/97
-
- //.show.last 0 get .hyphen ne
- and
-
- % newpar?
- { (\n\n) } % Paragraph
- { % Line
- %%*
- %%* BF2: If last character on a line is
- %%* a hyphen, we omit the hyphen and
- %%* run the lines together. Of
- %%* course, this will fail if a word
- %%* with an explicit hyphen (e.g.,
- %%* X-ray) is split across two lines.
- %%* Oh, well. (What should we do
- %%* about a hyphen that ends a
- %%* "paragraph"? Perhaps that should
- %%* inhibit a paragraph break.)
- %%*
- //.show.last 0 get .hyphen eq
- { () }
- { (\n) }
- ifelse % x y string width char
- }
- ifelse
- //print
-
- //.show.y 3 index .iput % x y string width
- //.show.x 4 index .iput % x y string width
- //.show.indent 4 index .iput
- }
- { % x y string width dy
- % If the word processor split a hyphenated word within
- % the same line, put out the hyphen now.
- pop
- //.show.last 0 get .hyphen eq { (-) //print } if
- }
- ifelse
- %%*
- %%* If have moved more than 1 point to
- %%* the right, interpret it as a
- %%* space? This need to be looked at
- %%* more closely.
- %%*
- 3 index % x y string width x
- //.show.x .iget 10 add gt % x y string width bool
- { ( ) //print }
- if
- % x y string width
- 4 1 roll % width x y string
- .show.write pop % width x
- add //.show.x exch .iput % <empty>
- }
- { (S ) //print .show==4 }
- ifelse
-} odef
-
-/.showstring
- { dup () eq { pop } { .showstring1 } ifelse
- } bind def
-
-% Redefine all the string display operators.
-
-/show {
- .showfont
- .showcolor
- .showstring
-} codef
-
-% We define all the other operators in terms of .show1.
-
-/.show1.string ( ) def
-/.show1 { //.show1.string exch 0 exch put //.show1.string .showstring } odef
-/ashow
- { .showfont .showcolor
- { .show1 2 copy rmoveto } forall
- pop pop
- } codef
-/awidthshow
- { .showfont .showcolor
- { dup .show1 4 index eq { 4 index 4 index rmoveto } if
- 2 copy rmoveto
- }
- forall
- pop pop pop pop pop
- } codef
-/widthshow
- { .showfont .showcolor
- //.show1.string 0 4 -1 roll put
- { //.show1.string search not { exit } if
- .showstring .showstring
- 2 index 2 index rmoveto
- } loop
- .showstring pop pop
- } codef
-/kshow
- { .showfont .showcolor
- %**************** Should construct a closure, in case the procedure
- %**************** affects the o-stack.
- { .show1 dup exec } forall pop
- } codef
-
-% We don't really do the right thing with the Level 2 show operators,
-% but we do something semi-reasonable.
-/xshow { pop show } codef
-/yshow { pop show } codef
-/xyshow { pop show } codef
-/glyphshow
- { currentfont /Encoding .knownget not { {} } if
- 0 1 2 index length 1 sub
- { % Stack: glyph encoding index
- 2 copy get 3 index eq { exch pop exch pop null exit } if
- pop
- }
- for null eq { (X) dup 0 4 -1 roll put show } { pop } ifelse
- } codef
-
-end
-
-% Bind the operators we just defined, and all the others if we didn't
-% do it before.
-
-DELAYBIND { .bindnow } if
-
-% Make systemdict read-only if it wasn't already.
-
-systemdict wcheck { systemdict readonly pop } if
-
-% Restore the current local/global VM mode.
-
-exec
diff --git a/Master/tlpkg/tlgs/lib/ps2epsi.ps b/Master/tlpkg/tlgs/lib/ps2epsi.ps
index 35c203a85c6..65d5b862e00 100644
--- a/Master/tlpkg/tlgs/lib/ps2epsi.ps
+++ b/Master/tlpkg/tlgs/lib/ps2epsi.ps
@@ -164,7 +164,9 @@ ps2edict begin
dup rm gt
% If the new index is greater, we save index and element
{ /rm exch def } { pop } ifelse
- } if
+ } {
+ pop
+ } ifelse
} for
% Write out the magic string and bounding box information
diff --git a/Master/tlpkg/tlgs/lib/quit.ps b/Master/tlpkg/tlgs/lib/quit.ps
deleted file mode 100644
index ff604669be5..00000000000
--- a/Master/tlpkg/tlgs/lib/quit.ps
+++ /dev/null
@@ -1 +0,0 @@
-quit
diff --git a/Master/tlpkg/tlgs/lib/showchar.ps b/Master/tlpkg/tlgs/lib/showchar.ps
deleted file mode 100644
index 32a71c6862b..00000000000
--- a/Master/tlpkg/tlgs/lib/showchar.ps
+++ /dev/null
@@ -1,92 +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.
-%
-
-% showchar.ps
-% Show the outline and rasterized forms of a character.
-
-/F where { pop } { /F /Times-Roman def } ifelse
-/P where { pop } { /P 16 def } ifelse
-/Rx where { pop } { /Rx 100 def } ifelse
-/Ry where { pop } { /Ry 100 def } ifelse
-/Cs where { pop } { /Cs (M) def } ifelse
-/Pr where { pop } { /Pr false def } ifelse
-/Delay where { pop } { /Delay 0 def } ifelse
-
-0 setgray
-(markpath.ps) runlibfile
-(markhint.ps) runlibfile
-/mmx [1 0 0 1 0 0] def
-/getpath % - getpath <pathproc>
- { [
- { /moveto cvx } { /lineto cvx } { /curveto cvx } { /closepath cvx }
- pathforall
- ] cvx
- } def
-/bitselectfont % <fontname> <scale> bitselectfont -
- { exch findfont exch scalefont setfont
- % Compute the bounding box in device coordinates.
- gsave [Rx 72 div 0 0 Ry 72 div 0 0] setmatrix
- currentfont /FontMatrix get concat
- currentfont /FontBBox get aload pop
- transform ceiling cvi /ury exch def ceiling cvi /urx exch def
- transform floor cvi /lly exch def floor cvi /llx exch def
- /bbx urx llx sub def /bby ury lly sub def
- grestore
- } def
-/bitshow % <string> bitshow -
- { /S exch def gsave
- /W bbx 8 add 7 or 1 add def
- /H bby 8 add def
- /buf W 8 idiv string def
- /M [Rx 72 div 0 0 Ry -72 div 4 llx sub H 4 sub] def
- M W H <ff 00> makeimagedevice
- /dev exch def
- gsave dev setdevice
- newpath 0 lly idtransform moveto
- 0 setgray
- gsave
- /hpath S false charpath getpath def
- grestore
- S show grestore
- 20 20 translate
- 50000 Rx Ry .max P mul div dup scale
- 0.7 setgray
- 0 W H true M
- { dup 1 add exch dev exch buf copyscanlines
- } imagemask pop
- 0 setlinewidth
- gsave 0.5 1 0.5 setrgbcolor hpath exec mmx markpath grestore
- 0 0.5 1 setrgbcolor hpath exec stroke
- % Show the hints for Type 1 fonts also.
- currentfont /FontType get 1 eq
- { gsave 1 0 0 setrgbcolor
- 0 lly M idtransform translate
- currentfont /FontMatrix get
- dup Pr markfonthints
- currentfont /Encoding get S 0 get get exch Pr markcharhints
- grestore
- }
- if
- } def
-F P bitselectfont
-/S1 1 string def
-Cs
- { /C exch def
- currentfont /Encoding get C get /.notdef ne
- { save S1 0 C put S1 bitshow
- showpage restore
- } if
- } forall
-quit
diff --git a/Master/tlpkg/tlgs/lib/showpage.ps b/Master/tlpkg/tlgs/lib/showpage.ps
deleted file mode 100644
index 97a4789f75d..00000000000
--- a/Master/tlpkg/tlgs/lib/showpage.ps
+++ /dev/null
@@ -1 +0,0 @@
-showpage
diff --git a/Master/tlpkg/tlgs/lib/traceop.ps b/Master/tlpkg/tlgs/lib/traceop.ps
index 0b655df04de..6d5509b10fb 100644
--- a/Master/tlpkg/tlgs/lib/traceop.ps
+++ b/Master/tlpkg/tlgs/lib/traceop.ps
@@ -25,7 +25,7 @@
/traceflush true def
currentpacking true setpacking
-.currentglobal true .setglobal
+currentglobal true setglobal
% Define the default "before" action
/tracebefore { vmstatus 3 traceprint pop pop pop } def
@@ -56,7 +56,7 @@ currentpacking true setpacking
pop userdict
} if
/.tddict exch def /.tdict exch def /.tname exch cvlit def
- .currentglobal [
+ currentglobal [
.tname /=only cvx ( ) /print cvx
/.tpre load /traceprint cvx /traceend cvx
.tdict .tname get /.tdef 1 index cvlit def
@@ -66,17 +66,17 @@ currentpacking true setpacking
} if
} if
/.tpost load /traceprint cvx () /= cvx /traceend cvx
- .tdef gcheck /.tpre load gcheck and /.tpost load gcheck and .setglobal
+ .tdef gcheck /.tpre load gcheck and /.tpost load gcheck and setglobal
] cvx
.tdef type /operatortype eq {
.tname exch .makeoperator
} if
- exch .setglobal
+ exch setglobal
.tddict exch .tname exch put
end % userdict
} bind def
/tracebind /bind load def % in case someone wants to put it back
/bind { } def % disable
-.setglobal
+setglobal
setpacking
diff --git a/Master/tlpkg/tlgs/lib/type1enc.ps b/Master/tlpkg/tlgs/lib/type1enc.ps
deleted file mode 100644
index 42be0cfb218..00000000000
--- a/Master/tlpkg/tlgs/lib/type1enc.ps
+++ /dev/null
@@ -1,64 +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.
-%
-
-% type1enc.ps
-% PostScript language versions of the Type 1 encryption/decryption algorithms.
-
-% This file is normally not needed with Ghostscript, since Ghostscript
-% implements these algorithms in C. For the specifications, see Chapter 7 of
-% "Adobe Type 1 Font Format," ISBN 0-201-57044-0, published by Addison-Wesley.
-
-/.type1crypt % <R> <from> <to> <proc> .type1crypt <R'> <to>
- % (auxiliary procedure)
- { 4 1 roll
- 0 2 index length getinterval
- 0 1 2 index length 1 sub
- { % Stack: proc R from to index
- 2 index 1 index get % proc R from to index C/P
- 4 index -8 bitshift xor 3 copy put % proc R from to index P/C
- 5 index exec % proc R from to C
-
-% Compute R' = ((R + C) * 52845 + 22719) mod 65536
-% without exceeding a 31-bit integer magnitude, given that
-% 0 <= R <= 65535 and 0 <= C <= 255.
-
- 4 -1 roll add
- dup 20077 mul % 52845 - 32768
- exch 1 and 15 bitshift add % only care about 16 low-order bits
- 22719 add 65535 and 3 1 roll
- }
- for exch pop 3 -1 roll pop
- } bind def
-
-% <state> <fromString> <toString> .type1encrypt <newState> <toSubstring>
-% Encrypts fromString according to the algorithm for Adobe
-% Type 1 fonts, writing the result into toString.
-% toString must be at least as long as fromString or a
-% rangecheck error occurs. state is the initial state of
-% the encryption algorithm (a 16-bit non-negative
-% integer); newState is the new state of the algorithm.
-
-/.type1encrypt
- { { exch pop } .type1crypt
- } bind def
-
-% <state> <fromString> <toString> .type1decrypt <newState> <toSubstring>
-% Decrypts fromString according to the algorithm for Adobe
-% Type 1 fonts, writing the result into toString. Other
-% specifications are as for type1encrypt.
-
-/.type1decrypt
- { { pop 2 index exch get } .type1crypt
- } bind def
diff --git a/Master/tlpkg/tlgs/lib/type1ops.ps b/Master/tlpkg/tlgs/lib/type1ops.ps
deleted file mode 100644
index ce9d8d9431e..00000000000
--- a/Master/tlpkg/tlgs/lib/type1ops.ps
+++ /dev/null
@@ -1,236 +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.
-%
-
-% type1ops.ps
-% Define the Type 1 and Type 2 font opcodes for use by Ghostscript utilities.
-
-% Define the default value of lenIV.
-% Note that this expects the current font to be on the dictionary stack.
-
-/lenIV { FontType 2 eq { -1 } { 4 } ifelse } def
-
-% ---------------- Encoding ---------------- %
-
-/Type1encode 70 dict
-
- % Data types
-
-dup /nulltype {
- pop ()
-} put
-dup /nametype {
- Type1encode exch get
-} put
-dup /stringtype {
-} put
-dup /integertype {
- dup dup -107 ge exch 107 le and {
- 139 add (x) dup 0 4 -1 roll put
- } {
- dup dup -1131 ge exch 1131 le and {
- dup 0 ge { 16#f694 } { neg 16#fa94 } ifelse add
- (xx) dup dup 0 4 index -8 bitshift put
- 1 4 -1 roll 255 and put
- } {
- (\377xxxx) 1 1 4 {
- dup 8 mul 32 sub 3 index exch bitshift 255 and
- 2 index 3 1 roll put
- } for exch pop
- } ifelse
- } ifelse
-} put
-
- % Operators
-
-% Identical or similar in Type 1 and Type 2.
-/c_hstem 1 def dup /hstem <01> put
-/c_vstem 3 def dup /vstem <03> put
-/c_vmoveto 4 def dup /vmoveto <04> put
-/c_rlineto 5 def dup /rlineto <05> put
-/c_hlineto 6 def dup /hlineto <06> put
-/c_vlineto 7 def dup /vlineto <07> put
-/c_rrcurveto 8 def dup /rrcurveto <08> put
-/c_callsubr 10 def /s_callsubr <0a> def dup /callsubr s_callsubr put
-/c_return 11 def dup /return <0b> put
-/c_escape 12 def
- /ce_div 12 def /s_div <0c0c> def dup /div s_div put
-/c_endchar 14 def /s_endchar <0e> def dup /endchar s_endchar put
-/c_rmoveto 21 def dup /rmoveto <15> put
-/c_hmoveto 22 def dup /hmoveto <16> put
-/c_vhcurveto 30 def dup /vhcurveto <1e> put
-/c_hvcurveto 31 def dup /hvcurveto <1f> put
-% Only in Type 1.
-/c_closepath 9 def dup /closepath <09> put
-/c_hsbw 13 def /s_hsbw <0d> def dup /hsbw s_hsbw put
- /ce_dotsection 0 def /s_dotsection <0c06> def dup /dotsection s_dotsection put
- /ce_vstem3 1 def /s_vstem3 <0c01> def dup /vstem3 s_vstem3 put
- /ce_hstem3 2 def /s_hstem3 <0c02> def dup /hstem3 s_hstem3 put
- /ce_seac 6 def /s_seac <0c06> def dup /seac s_seac put
- /ce_sbw 7 def /s_sbw <0c07> def dup /sbw s_sbw put
- /ce_callothersubr 16 def /s_callothersubr <0c10> def dup /callothersubr s_callothersubr put
- /ce_pop 17 def /s_pop <0c11> def dup /pop s_pop put
- /ce_setcurrentpoint 33 def /s_setcurrentpoint <0c21> def dup /setcurrentpoint s_setcurrentpoint put
- /s_setcurrentpoint_hmoveto s_setcurrentpoint <8b16> concatstrings def
-% Only in Type 2.
-dup /blend <10> put
-dup /hstemhm <12> put
-dup /hintmask <13> put
-dup /cntrmask <14> put
-dup /vstemhm <17> put
-dup /rcurveline <18> put
-dup /rlinecurve <19> put
-dup /vvcurveto <1a> put
-dup /hhcurveto <1b> put
-dup /callgsubr <1d> put
- dup /and <0c03> put
- dup /or <0c04> put
- dup /not <0c05> put
- dup /store <0c08> put
- dup /abs <0c09> put
- dup /add <0c0a> put
- dup /sub <0c0b> put
- dup /load <0c0d> put
- dup /neg <0c0c> put
- dup /eq <0c0f> put
- dup /drop <0c12> put
- dup /put <0c14> put
- dup /get <0c15> put
- dup /ifelse <0c16> put
- dup /random <0c17> put
- dup /mul <0c18> put
- dup /sqrt <0c1a> put
- dup /dup <0c1b> put
- dup /exch <0c1c> put
- dup /index <0c1d> put
- dup /roll <0c1e> put
- dup /hflex <0c22> put
- dup /flex <0c23> put
- dup /hflex1 <0c24> put
- dup /flex1 <0c25> put
-
-readonly def
-
-% ---------------- Decoding ---------------- %
-
-/Type1decode 512 array
-
-Type1encode {
- dup type /stringtype eq {
- dup length 1 eq { 0 get } { 1 get 256 add } ifelse
- % stack: array key code
- exch 2 index 3 1 roll put
- } {
- pop pop
- } ifelse
-} forall
-
-dup 12 {
- dup read pop dup Type1decode exch 256 add get dup null ne
- { exch pop }
- { pop 2 string dup 0 12 put dup 1 4 -1 roll put }
- ifelse
-} put
-dup 28 { % Type 2 only
- dup read pop 128 xor 128 sub 8 bitshift
- 1 index read pop add
-} put
-32 1 246 { 2 copy dup 139 sub put pop } for
-dup 247 { dup read pop 108 add } put
-dup 248 { dup read pop 364 add } put
-dup 249 { dup read pop 620 add } put
-dup 250 { dup read pop 876 add } put
-dup 251 { dup read pop 108 add neg } put
-dup 252 { dup read pop 364 add neg } put
-dup 253 { dup read pop 620 add neg } put
-dup 254 { dup read pop 876 add neg } put
-dup 255 { % Different for Type 1 and Type 2
- dup read pop 128 xor 128 sub
- 3 { 8 bitshift 1 index read pop add } repeat
- FontType 2 eq { 65536.0 div } if
-} put
-
-readonly def
-
-% ---------------- Procedures ---------------- %
-
-% For these utilities, a CharString is represented by a sequence of
-% integers, reals, strings, and names, either in an array or on the stack.
-% Integers and reals represent themselves; strings are other data that
-% appears in the CharString; names are CharString operator names.
-% A CharString in an array is called a "charproc"; a CharString on
-% the stack is called a "charstack", and is delimited by a mark.
-% Individual elements are called "chartokens".
-
-% ------ Encoding ------ %
-
-% Get the string for a chartoken.
-% Note that this string may be overwritten by the next call.
-/chartoken_string { % <chartoken> chartoken_string <string>
- dup type Type1encode exch get exec
-} bind def
-% Compute the length of a CharString.
-/chartoken_length { % <chartoken> chartoken_length <length>
- chartoken_string length
-} bind def
-/charproc_length { % <charproc> charproc_length <length>
- 0 exch { chartoken_length add } forall
-} bind def
-/charstack_length { % <charstack> charstack_length <charstack> <length>
- counttomark 0 exch -1 1 { index chartoken_length add } for
-} bind def
-
-% Write a CharString to a file. Normally this will be a NullEncode filter
-% writing on a string of the correct length.
-/chartoken_write { % <file> <chartoken> chartoken_write -
- chartoken_string writestring
-} bind def
-/charproc_write { % <file> <charproc> charproc_write -
- { 1 index exch chartoken_write } forall pop
-} bind def
-% Note that the arguments of charstack_write are backwards.
-/charstack_write { % <charstack> <file> charstack_write -
- counttomark 1 sub -1 1 { index 1 index exch chartoken_write } for
- cleartomark
-} bind def
-
-% Convert a charproc or charstack to an *un*encrypted CharString.
-/charproc_string { % <charproc> charproc_string <string>
- mark exch aload pop charstack_string
-} bind def
-/charstack_string { % <charstack> charstack_string <string>
- charstack_length lenIV 0 gt {
- lenIV add string
- dup dup length lenIV sub lenIV exch getinterval % skip lenIV
- } {
- string
- } ifelse
- /NullEncode filter
- exch 1 index counttomark 1 add 2 roll
- charstack_write closefile
-% lenIV 0 ge { 4330 exch dup .type1encrypt exch pop readonly } if
-} bind def
-
-% ------ Decoding ------ %
-
-% Decode a CharString (unencrypted).
-/charstack_read { % <file> charstack_read <no-mark-charstack>
- { dup read not { pop exit } if
- Type1decode 1 index get dup null eq {
- pop 1 string dup 0 4 -1 roll put
- } {
- exch pop exec
- } ifelse exch
- } loop
-} bind def
diff --git a/Master/tlpkg/tlgs/lib/unprot.ps b/Master/tlpkg/tlgs/lib/unprot.ps
deleted file mode 100644
index d5b1d19ff7a..00000000000
--- a/Master/tlpkg/tlgs/lib/unprot.ps
+++ /dev/null
@@ -1,66 +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.
-%
-
-% Disable all access checks. This is useful for printing out
-% eexec-encrypted Type 1 fonts, and similar purposes.
-
-systemdict wcheck
- { /protdict systemdict def
- }
- { (Please restart Ghostscript with the -dWRITESYSTEMDICT switch.\n) print
- (Some access checks will remain active if you do not do this.\n) print
- flush
- /protdict userdict def
- }
-ifelse
-
-% The procedures we're about to define will go in systemdict,
-% so they must be allocated in global VM.
-
-.currentglobal true .setglobal
-
-protdict begin
- /readonly. /readonly load def
- /executeonly. /executeonly load def
- /noaccess. /noaccess load def
- /readonly { } odef
- /readonly.. /readonly load def
- /executeonly { } odef
- /executeonly.. /executeonly load def
- /noaccess { } odef
- /noaccess.. /noaccess load def
-end
-
-% Disable the access checks.
-
-/unprot
- { protdict begin
- /readonly /readonly.. load def
- /executeonly /executeonly.. load def
- /noaccess /noaccess.. load def
- end
- } bind def
-
-% Re-enable the access checks.
-
-/reprot
- { protdict begin
- /readonly /readonly. load def
- /executeonly /executeonly. load def
- /noaccess /noaccess. load def
- end
- } bind def
-
-.setglobal
diff --git a/Master/tlpkg/tlgs/lib/viewmiff.ps b/Master/tlpkg/tlgs/lib/viewmiff.ps
index 01855090348..4c918ea6859 100644
--- a/Master/tlpkg/tlgs/lib/viewmiff.ps
+++ b/Master/tlpkg/tlgs/lib/viewmiff.ps
@@ -100,7 +100,7 @@
{ f token pop
dup (:) eq { pop exit } if
dup type /nametype eq {
- .namestring (=) search {
+ 1024 string cvs (=) search {
exch pop miffwords exch .knownget { exec } { pop } ifelse
} {
pop % who knows?
diff --git a/Master/tlpkg/tlgs/lib/viewpbm.ps b/Master/tlpkg/tlgs/lib/viewpbm.ps
index 177f22bb63e..60d5782da1d 100644
--- a/Master/tlpkg/tlgs/lib/viewpbm.ps
+++ b/Master/tlpkg/tlgs/lib/viewpbm.ps
@@ -128,10 +128,10 @@
% show the tags as pseudo-color image
/ncomp 1 def /invert false def /maxv 1 def
[ /Indexed /DeviceRGB 255
- % TEXT=1, IMAGE=2, PATH=4, UNTOUCHED=8
- % red green blue gray
+ % UNTOUCHED=0, TEXT=1, IMAGE=2, PATH=4
+ % gray red green blue
768 string
- dup 0 <000000 ff0000 00ff00 ffff00 0000ff ff00ff 00ffff ffffff cccccc> putinterval
+ dup 0 <cccccc ff0000 00ff00 ffff00 0000ff ff00ff 00ffff ffffff 000000> putinterval
] setcolorspace
w h {
readstring pop
@@ -190,7 +190,7 @@
pop
/FITPAGE where {/FITPAGE get}{false} ifelse
{
- Width 72 mul SCALE mul Height 72 mul SCALE mul
+ Width SCALE mul Height SCALE mul
}
{
% Map pixels SCALE-for-1. Assume orthogonal transformation.
diff --git a/Master/tlpkg/tlgs/lib/wftopfa.ps b/Master/tlpkg/tlgs/lib/wftopfa.ps
deleted file mode 100644
index 005eaf83f53..00000000000
--- a/Master/tlpkg/tlgs/lib/wftopfa.ps
+++ /dev/null
@@ -1,302 +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.
-%
-
-% wftopfa.ps
-% Convert a Wadalab base font to .PFA (or .PFB) format.
-
-(gs_ksb_e.ps) runlibfile
-(wrfont.ps) runlibfile
-
-/wftopfa_dict 100 dict def
-wftopfa_dict begin
-
-/KanjiSubEncoding dup .findencoding def
-
-% Initialize parameters.
-/init % - init -
- { /chars 256 dict def
- /version (001.001) def
- /highcode 0 def
- /StdHW [32] def
- /StdVW [32] def
- /UniqueID 20000000 def
- /FontBase (Wadalab) def
- /StdEncMode false def
- /CustomEncMode false def
- /Binary false def
- /Encrypt true def
- } bind def
-
-% Read definitions.
-/rdstring 5000 string def
-/readdefs % <filename> readdefs -
- { (r) file
- { dup rdstring readline not { pop exit } if
- dup length 15 ge
- { dup dup length 7 sub 7 getinterval (> CompD) eq
- { token pop exch token pop exch pop
- dup 0 get /highcode exch def
- exch chars 3 1 roll put
- }
- { pop
- }
- ifelse
- }
- { pop
- }
- ifelse
- }
- loop closefile
- } bind def
-
-% Write out the final font.
-/writepfa
- { 4 string highcode 16#1000 add 16 2 index cvrs 0 (.r) putinterval
- FontBase exch concatstrings /fullname exch def
- UniqueID 20000000 eq { /UniqueID 4990000 highcode add def } if
- /encoding CustomEncMode
- { KanjiSubEncoding }
- { StdEncMode { StandardEncoding } { ISOLatin1Encoding } ifelse }
- ifelse def
-
- /Font 30 dict def
- Font begin
- /FontInfo 20 dict def
- FontInfo begin
-
- % Write the clear text part.
-
- /CreationDate (%Calendar%) currentdevparams
- dup /Weekday get {(Sun )(Mon )(Tue )(Wed )(Thu )(Fri )(Sat )} exch get
- 1 index /Month get 1 sub
- {(Jan)(Feb)(Mar)(Apr)(May)(Jun)(Jul)(Aug)(Sep)(Oct)(Nov)(Dec)} exch get
- concatstrings
- {{/Day ( )} {/Hour ( )} {/Minute (:)} {/Second (:)} {/Year ( )}}
- { dup 1 get 3 -1 roll exch concatstrings exch
- 0 get 2 index exch get
- dup 10 lt { =string cvs (0) exch concatstrings } { =string cvs } ifelse
- concatstrings
- }
- forall exch pop readonly def
- /VMusage 100000 def
- /version version readonly def
- /Notice (No copyright on this font. Original available from moe.ipl.t.u-tokyo.ac.jp:/Font. Converted by wftopfa.ps (Artifex Software Inc).) readonly def
- /FullName fullname readonly def
- /FamilyName FontBase readonly def
- /Weight (Regular) readonly def
- /ItalicAngle 0 def
- /isFixedPitch true def
- /UnderlinePosition 0 def
- /UnderlineThickness 0 def
-
- end % FontInfo
-
- /FontName fullname cvn def
- /Encoding encoding def
- /PaintType 0 def
- /FontType 1 def
- /FontMatrix [.001 0 0 .001 0 -0.16] readonly def
- /UniqueID UniqueID def
- /FontBBox [0 0 1000 1000] readonly def
-
- /Private 20 dict def
- Private begin
-
- /-| {string currentfile exch readstring pop} readonly def
- /|- {readonly def} readonly def
- /| {readonly put} readonly def
- /BlueValues [] readonly def
- /OtherBlues [] readonly def
- /MinFeature {16 16} readonly def
- /StdHW StdHW def
- /StdVW StdVW def
- /ForceBold false def
- /password 5839 def
- /UniqueID UniqueID def
- /OtherSubrs [] readonly def
- /Subrs [
- (\020\2771p|\020\024\020=-\223D\\\342R) readonly
- (\020\2771py\274\366Uz) readonly
- (\020\2771py\275\304\236i) readonly
- (\020\2771p\371) readonly
- (\020\2771p~\266+6\034\3446z) readonly
- ] readonly def
-
- end % Private
-
- /CharStrings 256 dict def
- chars
- { exch =string cvs
- dup 0 get highcode eq
- { 1 get encoding exch get exch CharStrings 3 1 roll put }
- { pop pop }
- ifelse
- }
- forall
-
- end % Font
-
- Font /FontName get Font definefont setfont
- (%stdout) (w) file writefont
- } bind def
-
-% Scan the command line and process files.
-/options mark
- /version { 2 copy get /version exch def 1 add } bind
- /StdHW { 2 copy get cvx exec /StdHW exch def 1 add } bind
- /StdVW { 2 copy get cvx exec /StdVW exch def 1 add } bind
- /UniqueId { 2 copy get cvi /UniqueID exch def 1 add } bind
- /UniqueID 1 index
- /FontBase { 2 copy get /FontBase exch def 1 add } bind
- /StdEnc { /StdEncMode true def } bind
- /CustomEnc { /CustomEncMode true def } bind
- /Binary { /Binary true def } bind
- /noEncrypt { /Encrypt false def } bind
-.dicttomark def
-/wftopfa % [(arg1) ...] wftopfa -
- { init dup 0
- { dup 2 index length ge { exit } if
- 2 copy get exch 1 add exch
- options 1 index .knownget { exch pop exec } { readdefs } ifelse
- }
- loop pop pop
- wrfont_dict /binary_CharStrings Binary put
- wrfont_dict /eexec_encrypt Encrypt put
- wrfont_dict /name_all_Encodings CustomEncMode put
- writepfa
- } bind def
-
-end % wftopfa_dict
-
-/wftopfa
- { mark exch wftopfa_dict begin /saved save def { wftopfa } exec false%stopped
- { cleartomark true } { cleartomark false } ifelse
- saved end restore { stop } if
- } bind def
-
-[ shellarguments
- { ] wftopfa }
- { pop }
-ifelse
-
-% ---------------- Root font ---------------- %
-
-% Define the Encoding for the root font.
-/wfrootencoding
-% \x00-\x3F
- 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
- 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
- 0 1 2 3 4 5 6 7 8 0 0 0 0 0 0 0
- 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
-% \x40-\x7F
- 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
- 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
- 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
- 73 74 75 76 77 0 0 0 0 0 0 0 0 0 0 0
-% \x80-\xFF
-128 copy
-256 packedarray def
-
-% Define the template for the root font dictionary.
-/wfrootfontdict mark
- /FontType 0
- /FontMatrix [1 0 0 1 0 0]
- /FMapType 2
- /Encoding wfrootencoding
-.dicttomark def
-
-% Define a dummy (placeholder) Type 1 font for the FDepVector.
-/type1dummyfont % <fontname> type1dummyfont <font>
- { mark /FontName 3 -1 roll
- /FontType 1
- /FontMatrix [.001 0 0 .001 0 0]
- /FontBBox [0 0 1000 1000]
- /Encoding /KanjiSubEncoding findencoding
- /CharStrings 0 dict
- /Private mark /BlueValues [] /password 5839 .dicttomark
- .dicttomark dup /FontName get exch definefont
- } bind def
-
-% Write a root font. Again, wrfont.ps does most of the work.
-/makerootfont % <rootname> makerootfont <font>
- { wfrootfontdict dup length 4 add % FontName, FDepVector, PrefEnc, FID
- dict copy begin
- cvlit /FontName exch def
- 4 dict begin
- /len FontName length def
- /str len 4 add string def
- FontName str cvs pop
- str len (.r) putinterval
- /FDepVector [ 16#21 1 16#74
- { dup wfrootencoding exch get 0 eq
- { pop
- }
- { 16 str len 2 add 2 getinterval cvrs pop
- str cvn type1dummyfont
- }
- ifelse
- }
- for end counttomark -1 roll dup counttomark 2 roll
- ] def
- FontName currentdict end definefont
- } bind def
-/writerootfont % <rootname> writerootfont -
- { save exch makerootfont setfont (%stdout) (w) file writefont restore
- } bind def
-
-% ---------------- Converting entire fonts ---------------- %
-
-% Define the directory where the Wadalab fonts are stored.
-/wfdir (/home/ghost/kanji/w) def
-
-% Convert an entire Wadalab font.
-/writeentirefont % <fontname> <template*> writeentirefont -
- { 2 dict begin
- /templates exch def
- /fontname exch def
- [ templates
- { wfdir (/) concatstrings exch concatstrings { copystring }
- 8192 string filenameforall
- }
- forall
- wfdir (/wadalab-sym/*.ps) concatstrings { copystring }
- 8192 string filenameforall
- ]
- (%!\n) print
- { /currentuserparams where
- { pop currentuserparams /VMReclaim get -2 vmreclaim { vmreclaim } }
- { { } }
- ifelse
- } == (exec\n) print
- (/KanjiSubEncoding ) print /KanjiSubEncoding findencoding ==
- (readonly def\n) print
- { (%stderr) (w) file dup 2 index write== flushfile
- mark exch (CustomEnc) (Binary) (noEncrypt)
- (FontBase) fontname counttomark -1 roll ] wftopfa
- }
- forall
- fontname cvn writerootfont
- (exec\n) print
- end
- } def % don't bind, so we can print the procedure
-
-% Convert the Wadalab JIS 1&2 SaiMincho font.
-% To invoke this from the command line,
-% gs -dNODISPLAY -q wftopfa.ps -c writeSaiMincho0 flush quit >wmin0.ps
-% To make the resulting font loadable on demand, add to the Fontmap file:
-% /Wadalab-SaiMincho (wmin0.ps) ;
-/writeSaiMincho0
- { (Wadalab-SaiMincho) [ (wadalab-mincho-0-8/*.ps) ] writeentirefont
- } bind def
diff --git a/Master/tlpkg/tlgs/lib/wrfont.ps b/Master/tlpkg/tlgs/lib/wrfont.ps
deleted file mode 100644
index eeab341ac28..00000000000
--- a/Master/tlpkg/tlgs/lib/wrfont.ps
+++ /dev/null
@@ -1,664 +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.
-%
-
-% wrfont.ps
-% Write out a Type 1 font in readable, reloadable form.
-% Note that this does NOT work on protected fonts, such as Adobe fonts
-% (unless you have loaded unprot.ps first, in which case you may be
-% violating the Adobe license).
-
-% ****** NOTE: This file must be kept consistent with gs_pfile.ps.
-
-/wrfont_dict 100 dict def
-wrfont_dict begin
-
-% ------ Options ------ %
-
-% Define whether to use eexec encryption for the font.
-% eexec encryption is only useful for compatibility with Adobe Type Manager
-% and other programs; it only slows Ghostscript down.
- /eexec_encrypt false def
-
-% Define whether to write out the CharStrings in binary or in hex.
-% Binary takes less space on the file, but isn't guaranteed portable.
- /binary_CharStrings false def
-
-% Define whether to use binary token encodings when possible.
-% Binary tokens are smaller and load faster, but are a Level 2 feature.
- /binary_tokens false def
-
-% Define whether to encrypt the CharStrings on the file. (CharStrings
-% are always encrypted in memory.) Unencrypted CharStrings load about
-% 20% slower, but make the files compress much better for transport.
- /encrypt_CharStrings true def
-
-% Define whether the font must provide standard PostScript language
-% equivalents for any facilities it uses that are provided in Ghostscript
-% but are not part of the standard PostScript language.
- /standard_only true def
-
-% Define the value of lenIV to use in writing out the font.
-% use_lenIV = 0 produces the smallest output, but this may not be
-% compatible with old Adobe interpreters. use_lenIV = -1 means
-% use the value of lenIV from the font.
- /use_lenIV -1 def
-
-% Define whether to produce the smallest possible output, relying
-% as much as possible on Ghostscript-specific support code.
-% Taking full advantage of this requires the following settings:
-% binary_CharStrings = true, binary_tokens = true, standard_only = false.
- /smallest_output false def
-
-% Define whether to write out all currently known Encodings by name,
-% or only StandardEncoding and ISOLatin1Encoding.
- /name_all_Encodings false def
-
-% ---------------- Runtime support ---------------- %
-
-/.packedfilefilter where
- { pop }
- { (gs_pfile.ps) runlibfile }
-ifelse
-
-% ------ Output utilities ------ %
-
-% By convention, the output file is named psfile.
-
-% Define some utilities for writing the output file.
- /wtstring 2000 string def
- /wb {psfile exch write} bind def
- /wnb {/wb load repeat} bind def
- /w1 {psfile exch write} bind def
- /ws {psfile exch writestring} bind def
- /wl {ws (\n) ws} bind def
- /wt {wtstring cvs ws ( ) ws} bind def
- /wd % Write a dictionary.
- { dup length wo {dict dup begin} wol { we } forall
- {end} wol
- } bind def
- /wld % Write a large dictionary more efficiently.
- % Ignore the readonly attributes.
- { dup length wo {dict dup begin} wol
- 0 exch
- { exch wo wo () wl
- 1 add dup 200 eq
- { wo ({def} repeat) wl 0 }
- if
- }
- forall
- dup 0 ne
- { wo ({def} repeat) wl }
- { pop }
- ifelse
- (end) ws
- } bind def
- /we % Write a dictionary entry.
- { exch wo wo /def cvx wo (\n) ws
- } bind def
- /wcs % Write a CharString (or Subrs entry)
- { dup type /stringtype eq
- { 4330 exch changelenIV 0 ge
- { % Add some leading garbage bytes.
- wtstring changelenIV 2 index length getinterval
- .type1decrypt exch pop
- wtstring exch 0 exch length changelenIV add getinterval
- }
- { % Drop some leading garbage bytes.
- wtstring .type1decrypt exch pop
- changelenIV neg 1 index length 1 index sub getinterval
- }
- ifelse
- binary_tokens encrypt_CharStrings and
- { % Suppress recognizing the readonly status of the string.
- 4330 exch dup .type1encrypt exch pop wo
- }
- { encrypt_CharStrings
- { 4330 exch dup .type1encrypt exch pop
- } if
- smallest_output
- { wo
- }
- { readonly dup length wo
- binary_tokens not { ( ) ws } if
- readproc ws wx
- }
- ifelse
- }
- ifelse
- }
- { wo % PostScript procedure
- }
- ifelse
- } bind def
-
-% Construct the inversion of the system name table.
- (\210\001) token pop exch pop 1 eq { % i.e., do we have binary tokens?
- /snit 256 dict def
- 0 1 255 {
- (\221 ) dup 1 3 index put
- { token } stopped {
- pop pop
- } {
- % Stack: char () token true
- pop exch pop exch snit 3 1 roll put
- } ifelse
- } for
- } {
- /snit 1 dict def
- } ifelse
-
-% Write an object, using binary tokens if requested and possible.
- /woa % write in ascii
- { psfile exch write==only
- } bind def
-
- % Lookup table for ASCII output.
-
- /intbytes % int nbytes -> byte*
- { { dup 255 and exch -8 bitshift } repeat pop
- } bind def
- /wotta 10 dict dup begin
- { /booleantype /integertype }
- { { ( ) ws woa } def }
- forall
- % Iterate over arrays so we can print operators.
- /arraytype
- { dup xcheck {(}) ({)} {(]) ([)} ifelse ws exch dup wol exch ws wop
- } bind def
- /dicttype
- { ( ) ws wd } def
- /nametype
- { dup xcheck { ( ) ws } if woa
- } bind def
- % Map back operators to their names,
- % so we can write procedures.
- /nulltype
- { pop ( null) ws
- } bind def
- /operatortype
- { wtstring cvs cvn cvx wo
- } bind def
- % Convert reals to integers if possible.
- /realtype
- { dup cvi 1 index eq { cvi wo } { ( ) ws woa } ifelse
- } bind def
- % == truncates strings longer than 200 characters!
- /stringtype
- { (\() ws dup
- { dup dup 32 lt exch 127 ge or
- { (\\) ws dup -6 bitshift 48 add w1
- dup -3 bitshift 7 and 48 add w1
- 7 and 48 add
- }
- { dup dup -2 and 40 eq exch 92 eq or {(\\) ws} if
- }
- ifelse w1
- }
- forall
- (\)) ws wop
- } bind def
- /packedarraytype
- { ([) ws dup { wo } forall
- encodingnames 1 index known
- % This is an encoding, but not one of the standard ones.
- % Use the built-in encoding only if it is available.
- { encodingnames exch get wo
- ({findencoding}stopped{pop) ws
- (}{counttomark 1 add 1 roll cleartomark}ifelse)
- }
- { pop ()
- }
- ifelse
- (/packedarray where{pop counttomark packedarray exch pop}{]readonly}ifelse) ws
- wl
- }
- def
- end def
-
- % Lookup table for binary output.
-
- /wottb 8 dict dup begin
- wotta currentdict copy pop
- /integertype
- { dup dup 127 le exch -128 ge and
- { 136 wb 255 and wb }
- { dup dup 32767 le exch -32768 ge and
- { 134 wb 2 intbytes wb wb }
- { 132 wb 4 intbytes wb wb wb wb }
- ifelse
- }
- ifelse
- } bind def
- /nametype
- { dup snit exch known
- { dup xcheck { 146 } { 145 } ifelse wb
- snit exch get wb
- }
- { wotta /nametype get exec
- }
- ifelse
- } bind def
- /stringtype
- { dup dup length dup 255 le { 142 2 } { 2 intbytes 143 3 } ifelse wnb
- ws wop
- } bind def
- end def
-
- /wop % Write object protection
- { wcheck not { /readonly cvx wo } if
- } bind def
- /wo % Write an object.
- { dup type binary_tokens { wottb } { wotta } ifelse
- exch get exec
- } bind def
- /wol % Write a list of objects.
- { { wo } forall
- } bind def
-
-% Write a hex string for Subrs or CharStrings.
- /wx % string ->
- { binary_CharStrings
- { ws
- }
- { % Some systems choke on very long lines, so
- % we break up the hexstring into chunks of 50 characters.
- { dup length 25 le {exit} if
- dup 0 25 getinterval psfile exch writehexstring (\n) ws
- dup length 25 sub 25 exch getinterval
- } loop
- psfile exch writehexstring
- } ifelse
- } bind def
-
-% ------ CharString encryption utilities ------ %
-
-/enc_dict 20 dict def
-1 dict begin
-/bind { } def % make sure we can print out the procedures
-enc_dict begin
-
-(type1enc.ps) runlibfile
-enc_dict /.type1decrypt undef % we don't need this
-
-end end
-
-enc_dict { 1 index where { pop pop pop } { def } ifelse } forall
-
-% ------ Other utilities ------ %
-
-% Test whether two values are equal (for default dictionary entries).
- /valueeq % <obj1> <obj2> valueeq <bool>
- { 2 copy eq
- { pop pop true }
- { % Special hack for comparing FontMatrix values
- dup type /arraytype eq 2 index type /arraytype eq and
- { dup length 2 index length eq
- { true 0 1 3 index length 1 sub
- { % Stack: arr1 arr2 true index
- 3 index 1 index get 3 index 3 -1 roll get eq not
- { pop false exit }
- if
- }
- for 3 1 roll pop pop
- }
- { pop pop false
- }
- ifelse
- }
- { pop pop false
- }
- ifelse
- }
- ifelse
- } bind def
-
-% ------ The main program ------ %
-
-% Define the dictionary of keys to skip because they are treated specially.
-/.fontskipkeys mark
- /CharStrings dup
- /Encoding dup
- /FDepVector dup
- /FID dup
- /FontInfo dup
- /Metrics dup
- /Metrics2 dup
- /Private dup
-.dicttomark def
-/.minfontskipkeys mark
- .fontskipkeys { } forall
- /FontName dup
- /UniqueID dup
-.dicttomark def
-/.privateskipkeys mark
- /ND dup
- /NP dup
- /RD dup
- /Subrs dup
-.dicttomark def
-/.minprivateskipkeys mark
- .privateskipkeys { } forall
- /MinFeature dup
- /Password dup
- /UniqueID dup
-.dicttomark def
-
-% Define the procedures for the Private dictionary.
-% These must be defined without `bind',
-% for the sake of the DISKFONTS feature.
-4 dict begin
- /-! {string currentfile exch readhexstring pop} def
- /-| {string currentfile exch readstring pop} def
- /|- {readonly def} def
- /| {readonly put} def
-currentdict end /encrypted_procs exch def
-4 dict begin
- /-! {string currentfile exch readhexstring pop
- 4330 exch dup .type1encrypt exch pop} def
- /-| {string currentfile exch readstring pop
- 4330 exch dup .type1encrypt exch pop} def
- /|- {readonly def} def
- /| {readonly put} def
-currentdict end /unencrypted_procs exch def
-
-% Construct an inverse dictionary of encodings.
-/encodingnames mark
- StandardEncoding /StandardEncoding
- ISOLatin1Encoding /ISOLatin1Encoding
- SymbolEncoding /SymbolEncoding
- DingbatsEncoding /DingbatsEncoding
- /resourceforall where
- { pop (*) { cvn dup findencoding exch } 100 string /Encoding resourceforall }
- if
-.dicttomark def
-
-% Invert the standard encodings.
-.knownEncodings length 256 mul dict begin
- 0 .knownEncodings
- { { currentdict 1 index known { pop } { 1 index def } ifelse
- 1 add
- }
- forall
- }
- forall pop
-currentdict end /inverseencodings exch def
-
-/writefont % <psfile> writefont - (writes the current font)
- { /psfile exch def
- /Font currentfont def
- /FontInfo Font /FontInfo .knownget not { 0 dict } if def
- /FontType Font /FontType get def
- /hasPrivate Font /Private known def
- /Private hasPrivate { Font /Private get } { 0 dict } ifelse def
- /readproc binary_CharStrings { (-| ) } { (-! ) } ifelse def
- /privateprocs
- encrypt_CharStrings binary_tokens not and
- { encrypted_procs } { unencrypted_procs } ifelse
- def
- /addlenIV false def
- /changelenIV use_lenIV 0 lt
- { 0 }
- { use_lenIV Private /lenIV .knownget not
- { 4 /addlenIV use_lenIV 4 ne def } if sub }
- ifelse def
- /minimize
- smallest_output
- FontType 1 eq and
- Font /UniqueID known and
- def
- (%!FontType) ws FontType wtstring cvs ws (-1.0: ) ws
- currentfont /FontName get wt
- FontInfo /version .knownget not { (001.001) } if wl
- FontInfo /CreationDate .knownget { (%%Creation Date: ) ws wl } if
- FontInfo /VMusage .knownget
- { (%%VMusage: ) ws dup wt wtstring cvs wl }
- if
- (systemdict begin) wl
-
-% If we're going to use eexec, create the filters now.
- /realpsfile psfile def
- eexec_encrypt
- { /eexecfilter psfile binary_CharStrings not
- { pop /bxstring 35 string def
- { pop dup length 0 ne
- { realpsfile exch writehexstring realpsfile (\n) writestring }
- { pop }
- ifelse bxstring
- }
- /NullEncode filter dup /hexfilter exch def
- }
- if 55665 /eexecEncode filter def
- }
- if
-
-% Turn on binary tokens if relevant.
- binary_tokens { (currentobjectformat 1 setobjectformat) wl } if
-
-% If the file has a UniqueID, write out a check against loading it twice.
- minimize
- { Font /FontName get wo
- Font /UniqueID get wo
- Private length addlenIV { 1 add } if wo
- Font length 1 add wo % +1 for FontFile
- ( .checkexistingfont) wl
- }
- { Font /UniqueID known
- { ({} FontDirectory) ws Font /FontName get dup wo ( known) wl
- ( {) ws wo ( findfont dup /UniqueID known) wl
- ( { dup /UniqueID get) ws Font /UniqueID get wo ( eq exch /FontType get 1 eq and }) wl
- ( { pop false } ifelse) wl
- ( { pop save /restore load } if) wl
- ( } if) wl
- }
- if
- }
- ifelse
-
-% If we are writing unencrypted CharStrings for a standard environment,
-% write out the encryption procedures.
- privateprocs unencrypted_procs eq standard_only and
- { (systemdict /.type1encrypt known) wl
- ( { save /restore load } { { } } ifelse) wl
- (userdict begin) wl
- enc_dict { we } forall
- (end exec) wl
- }
- if
-
-% Write out the creation of the font dictionary and FontInfo.
- minimize not
- { Font length 1 add wo {dict begin} wol % +1 for FontFile
- }
- if
- (/FontInfo ) ws FontInfo wd {readonly def} wol
-
-% Write out the other fixed entries in the font dictionary.
- Font begin
- Font
- { minimize
- { .minfontskipkeys 2 index known
- { pop pop
- }
- { //.compactfontdefault 2 index .knownget
- { 1 index valueeq { pop pop } { we } ifelse }
- { we }
- ifelse
- }
- ifelse
- }
- { .fontskipkeys 2 index known { pop pop } { we } ifelse
- }
- ifelse
- } forall
- /Encoding
- encodingnames Encoding known
- name_all_Encodings
- Encoding StandardEncoding eq or
- Encoding ISOLatin1Encoding eq or and
- { encodingnames Encoding get cvx }
- { Encoding }
- ifelse
- dup /StandardEncoding cvx eq minimize and
- { pop pop }
- { we }
- ifelse
-
-% Write the FDepVector, if any.
- Font /FDepVector .knownget
- { {/FDepVector [} wol
- { /FontName get wo {findfont} wol () wl } forall
- {] readonly def} wol
- }
- if
-
-% Write out the Metrics, if any.
- Font /Metrics .knownget
- { (/Metrics ) ws wld {readonly def} wol
- }
- if
- Font /Metrics2 .knownget
- { (/Metrics2 ) ws wld {readonly def} wol
- }
- if
-
-% Start the eexec-encrypted section, if applicable.
- eexec_encrypt
- { {currentdict currentfile eexec} wol () wl
- /psfile eexecfilter store
- (\000\000\000\000) ws {begin} wol
- }
- if
-
-% Create and initialize the Private dictionary, if any.
- hasPrivate
-{
- Private
- minimize
- { begin {Private dup begin}
- }
- { dup length privateprocs length add dict copy begin
- privateprocs { readonly def } forall
- /Private wo
- currentdict length 1 add wo {dict dup begin}
- }
- ifelse wol () wl
- currentdict
- { 1 index minimize { .minprivateskipkeys } { .privateskipkeys } ifelse
- exch known
- { pop pop }
- { 1 index /lenIV eq use_lenIV 0 ge and { pop use_lenIV } if we }
- ifelse
- } forall
- addlenIV { /lenIV use_lenIV we } if
-}
-if
-
-% Write the Subrs entries, if any.
- currentdict /Subrs known
- { (/Subrs[) wl
- Subrs
- { dup null ne
- { wcs minimize not { () wl } if }
- { pop /null cvx wo }
- ifelse
- } forall
- {] dup {readonly pop} forall readonly def} wol () wl
- }
- if
-
-% Wrap up the Private dictionary.
- hasPrivate
- { end % Private
- minimize
- { {end readonly pop} } % Private
- { {end readonly def} } % Private in font
- ifelse wol
- }
- if
-
-% Write the CharStrings entries.
-% Detect identical (eq) entries, which bdftops produces.
- currentdict /CharStrings known
-{
- /CharStrings wo CharStrings length wo
- minimize
- { encrypt_CharStrings not wo ( .readCharStrings) wl
- CharStrings length dict
- CharStrings
- { exch inverseencodings 1 index .knownget not { dup } if wo
- % Stack: vdict value key
- 3 copy pop .knownget { wo pop pop } { 3 copy put pop wcs } ifelse
- } forall
- }
- { {dict dup Private begin begin} wol () wl
- CharStrings length dict
- CharStrings
- { 2 index 1 index known
- { exch wo 1 index exch get wo {load def} wol () wl
- }
- { 2 index 1 index 3 index put
- exch wo wcs ( |-) wl
- }
- ifelse
- } forall
- {end end} wol
- }
- ifelse
- pop
- { readonly def } % CharStrings in font
- wol
-}
-if
-
-% Terminate the output.
- end % Font
- eexec_encrypt
- { {end mark currentfile closefile} wol () wl
- eexecfilter dup flushfile closefile % psfile is eexecfilter
- binary_CharStrings not { hexfilter dup flushfile closefile } if
- /psfile realpsfile store
- 8
- { (0000000000000000000000000000000000000000000000000000000000000000)
- wl
- }
- repeat {cleartomark} wol
- }
- if
- { FontName currentdict end definefont pop
- }
- wol
- Font /UniqueID known { /exec cvx wo } if
- binary_tokens { /setobjectformat cvx wo } if
- ( end) wl % systemdict
-
- } bind def
-
-% ------ Other utilities ------ %
-
-% Prune garbage characters and OtherSubrs out of the current font,
-% if the relevant dictionaries are writable.
-/prunefont
- { currentfont /CharStrings get wcheck
- { currentfont /CharStrings get dup [ exch
- { pop dup (S????00?) .stringmatch not { pop } if
- } forall
- ] { 2 copy undef pop } forall pop
- }
- if
- } bind def
-
-end % wrfont_dict
-
-/writefont { wrfont_dict begin writefont end } def