2 |
- |
1 |
% Copyright (C) 1994, 1995 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
%
|
|
|
3 |
% This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
% implied.
|
|
|
5 |
%
|
|
|
6 |
% This software is distributed under license and may not be copied,
|
|
|
7 |
% modified or distributed except as expressly authorized under the terms
|
|
|
8 |
% of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
%
|
|
|
10 |
% For more information about licensing, please refer to
|
|
|
11 |
% http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
% commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
% San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
|
|
|
16 |
% $Id: gs_pfile.ps,v 1.5 2003/08/08 18:45:05 ray Exp $
|
|
|
17 |
% Runtime support for minimum-space fonts and packed files.
|
|
|
18 |
|
|
|
19 |
% ****** NOTE: This file must be kept consistent with
|
|
|
20 |
% ****** packfile.ps and wrfont.ps.
|
|
|
21 |
|
|
|
22 |
% ---------------- Packed file support ---------------- %
|
|
|
23 |
|
|
|
24 |
% A packed file is the concatenation of several file groups, each of which
|
|
|
25 |
% is the result of compressing several files concatenated together.
|
|
|
26 |
% The packed file begins with a procedure that creates an appropriate
|
|
|
27 |
% decoding filter for each file group, as follows:
|
|
|
28 |
% <group-subfile-filter> -proc- <group-decode-filter>
|
|
|
29 |
% Thus, accessing an individual file requires 4 parameters:
|
|
|
30 |
% the starting address and length of the outer compressed file,
|
|
|
31 |
% and the starting address and length of the inner file.
|
|
|
32 |
/.packedfilefilter % <file> <ostart> <olength> <istart> <ilength>
|
|
|
33 |
% .packedfilefilter <filter>
|
|
|
34 |
{ 4 index systemdict begin token pop end 6 1 roll
|
|
|
35 |
% Stack: fproc file ostart olength istart ilength
|
|
|
36 |
4 index 5 -1 roll setfileposition
|
|
|
37 |
% Stack: fproc file olength istart ilength
|
|
|
38 |
4 -2 roll () /SubFileDecode filter
|
|
|
39 |
% Stack: fproc istart ilength ofilter
|
|
|
40 |
4 -1 roll exec
|
|
|
41 |
% Filters don't support setfileposition, so we must skip data
|
|
|
42 |
% by reading it into a buffer. We rely on the fact that
|
|
|
43 |
% save/restore don't affect file positions.
|
|
|
44 |
% Stack: istart ilength dfilter
|
|
|
45 |
save exch 64000 string
|
|
|
46 |
% Stack: istart ilength save dfilter scratch
|
|
|
47 |
4 index 1 index length idiv { 2 copy readstring pop pop } repeat
|
|
|
48 |
2 copy 0 8 -1 roll 2 index length mod getinterval readstring pop pop pop
|
|
|
49 |
% Stack: ilength save dfilter
|
|
|
50 |
exch restore exch () /SubFileDecode filter
|
|
|
51 |
} bind def
|
|
|
52 |
|
|
|
53 |
% Run a packed library file.
|
|
|
54 |
/.runpackedlibfile % <filename> <ostart> <olength> <istart> <ilength>
|
|
|
55 |
% .runpackedlibfile
|
|
|
56 |
{ 5 -1 roll findlibfile
|
|
|
57 |
{ exch pop dup 6 2 roll .packedfilefilter
|
|
|
58 |
currentobjectformat exch 1 setobjectformat run
|
|
|
59 |
setobjectformat closefile
|
|
|
60 |
}
|
|
|
61 |
{ 5 1 roll /findlibfile load /undefinedfilename signalerror
|
|
|
62 |
}
|
|
|
63 |
ifelse
|
|
|
64 |
} bind def
|
|
|
65 |
|
|
|
66 |
% ---------------- Compacted font support ---------------- %
|
|
|
67 |
|
|
|
68 |
% Compacted fonts written by wrfont.ps depend on the existence and
|
|
|
69 |
% specifications of the procedures and data in this section.
|
|
|
70 |
|
|
|
71 |
/.compactfontdefault mark
|
|
|
72 |
/PaintType 0
|
|
|
73 |
/FontMatrix [0.001 0 0 0.001 0 0] readonly
|
|
|
74 |
/FontType 1
|
|
|
75 |
/Encoding StandardEncoding
|
|
|
76 |
.dicttomark readonly def
|
|
|
77 |
|
|
|
78 |
/.checkexistingfont % <fontname> <uid> <privatesize> <fontsize>
|
|
|
79 |
% .checkexistingfont
|
|
|
80 |
% {} (<font> on d-stack)
|
|
|
81 |
% <fontname> <uid> <privatesize> <fontsize>
|
|
|
82 |
% .checkexistingfont
|
|
|
83 |
% -save- --restore-- (<font> on d-stack)
|
|
|
84 |
{ FontDirectory 4 index .knownget
|
|
|
85 |
{ dup /UniqueID .knownget
|
|
|
86 |
{ 4 index eq exch /FontType get 1 eq and }
|
|
|
87 |
{ pop false }
|
|
|
88 |
ifelse
|
|
|
89 |
}
|
|
|
90 |
{ false
|
|
|
91 |
}
|
|
|
92 |
ifelse
|
|
|
93 |
{ save /restore load 6 2 roll }
|
|
|
94 |
{ {} 5 1 roll }
|
|
|
95 |
ifelse
|
|
|
96 |
dict //.compactfontdefault exch .copydict begin
|
|
|
97 |
dict /Private exch def
|
|
|
98 |
Private begin
|
|
|
99 |
/MinFeature {16 16} def
|
|
|
100 |
/Password 5839 def
|
|
|
101 |
/UniqueID 1 index def
|
|
|
102 |
end
|
|
|
103 |
/UniqueID exch def
|
|
|
104 |
/FontName exch def
|
|
|
105 |
} bind def
|
|
|
106 |
|
|
|
107 |
/.knownEncodings [
|
|
|
108 |
ISOLatin1Encoding
|
|
|
109 |
StandardEncoding
|
|
|
110 |
SymbolEncoding
|
|
|
111 |
] readonly def
|
|
|
112 |
|
|
|
113 |
/.readCharStrings % <count> <encrypt> .readCharStrings <dict>
|
|
|
114 |
{ exch dup dict dup 3 -1 roll
|
|
|
115 |
{ currentfile token pop dup type /integertype eq
|
|
|
116 |
{ dup -8 bitshift //.knownEncodings exch get exch 255 and get } if
|
|
|
117 |
currentfile token pop dup type /nametype eq
|
|
|
118 |
{ 2 index exch get
|
|
|
119 |
}
|
|
|
120 |
{ % Stack: encrypt dict dict key value
|
|
|
121 |
4 index { 4330 exch dup .type1encrypt exch pop } if
|
|
|
122 |
readonly
|
|
|
123 |
}
|
|
|
124 |
ifelse put dup
|
|
|
125 |
}
|
|
|
126 |
repeat pop exch pop
|
|
|
127 |
} bind def
|