1 % Copyright (C) 1994, 1995 Aladdin Enterprises. All rights reserved.
3 % This software is provided AS-IS with no warranty, either express or
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.
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.
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.
19 % ****** NOTE: This file must be kept consistent with
20 % ****** packfile.ps and wrfont.ps.
22 % ---------------- Packed file support ---------------- %
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
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
53 % Run a packed library file.
54 /.runpackedlibfile % <filename> <ostart> <olength> <istart> <ilength>
56 { 5 -1 roll findlibfile
57 { exch pop dup 6 2 roll .packedfilefilter
58 currentobjectformat exch 1 setobjectformat run
59 setobjectformat closefile
61 { 5 1 roll /findlibfile load /undefinedfilename signalerror
66 % ---------------- Compacted font support ---------------- %
68 % Compacted fonts written by wrfont.ps depend on the existence and
69 % specifications of the procedures and data in this section.
71 /.compactfontdefault mark
73 /FontMatrix [0.001 0 0 0.001 0 0] readonly
75 /Encoding StandardEncoding
76 .dicttomark readonly def
78 /.checkexistingfont % <fontname> <uid> <privatesize> <fontsize>
80 % {} (<font> on d-stack)
81 % <fontname> <uid> <privatesize> <fontsize>
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 }
93 { save /restore load 6 2 roll }
96 dict //.compactfontdefault exch .copydict begin
97 dict /Private exch def
99 /MinFeature {16 16} def
101 /UniqueID 1 index def
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
120 { % Stack: encrypt dict dict key value
121 4 index { 4330 exch dup .type1encrypt exch pop } if