]> git.lizzy.rs Git - plan9front.git/blob - sys/lib/ghostscript/gs_ciddc.ps
etherbcm: handle 64-bit host addresses, use PCIWADDR() instead of PADDR()
[plan9front.git] / sys / lib / ghostscript / gs_ciddc.ps
1 %    Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000 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_ciddc.ps,v 1.14 2005/01/20 00:26:06 ray Exp $
17 % Define Decoding and CIDDecoding resource categories and related procsets.
18
19 languagelevel 2 .setlanguagelevel
20 currentglobal true setglobal
21
22 %----------------ParseDecoding procset----------------------------
23
24 /ParseDecoding <<
25
26 /Parse    % <resource_name> <num_tokens> Parse -
27 { dict begin                                  % /ResName
28   0                                           % /ResName nCode
29   { currentfile token not {
30       exit
31     } if                                      % /ResName nCode token
32     dup type /integertype eq {                % /ResName nCode
33        exch pop
34     } {
35       1 index def                             % /ResName nCode
36     } ifelse
37   } loop                                      % /ResName nCode
38   pop                                         % /ResName
39   currentdict end /Decoding                   % /ResName <<inst>> /Decoding
40   defineresource pop
41 } bind
42
43 >> /ProcSet defineresource pop
44
45 %----------------Decoding category----------------------------
46
47 /Generic /Category findresource dup length dict copy
48 dup /InstanceType /dicttype put
49 /Decoding exch /Category defineresource pop
50
51 %----------------ParseCMap_Inverse procset----------------------------
52
53 /ParseCMap_Inverse <<
54   /findresource { pop } bind
55   /defineresource { pop pop } bind
56   /dict {}
57   /def { pop pop } bind
58   /dup null
59   /begin { pop } bind
60   /end {}
61   /currentdict null
62   /CMapName null
63   /usecmap { pop } bind
64   /begincmap {}
65   /endcmap {}
66   /begincodespacerange { pop mark } bind
67   /endcodespacerange { cleartomark } bind
68   /beginnotdefrange { pop mark } bind
69   /endnotdefrange { cleartomark } bind
70   /beginbfchar { pop mark } bind
71   /endbfchar { pop mark } bind
72   /beginbfrange { begincidrange }
73   /endbfrange { endcidrange }
74   /begincidchar { beginbfchar }
75   /endcidchar { endbfchar }
76   /begincidrange { pop mark } bind
77   /endcidrange  { cleartomark } bind
78 >>  % Just keep it on stack for a while.
79
80 % Now we define another dict for local binding, than merge it with the previous one :
81 dup length 5 add dict begin
82
83   /.Ranges 40 dict def % Key = CID/256, value = array of 256 integer codes.
84   //.Ranges /CIDCount 0 put
85
86   /.StringToInt     % <string> .StringToInt <integer>
87   { 0 exch { exch 8 bitshift add } forall
88   } bind def
89
90   /.SetCouple    % <I> <b> .SetCouple -
91   { exch                                    % b I
92     dup 256 idiv                            % b I I0
93     dup //.Ranges exch known not {
94       dup //.Ranges exch 256 array put
95     } if                                    % b I I0
96     //.Ranges exch get                      % b I [Range]
97     exch 256 mod                            % b [Range] I1
98     3 2 roll put                            %
99   } bind def
100
101   /endcidrange
102   { % Writes the inversed CMap to .Ranges
103     counttomark 3 idiv {                    % (b) (e) I
104       exch .StringToInt                     % (b) I e
105       3 2 roll .StringToInt                 % I e b
106       % Note : this code does't handle multidimentional CID ranges.
107       % fixme : optimize below.
108       dup 3 2 roll exch sub 1 add           % I b d
109       { 2 copy //.SetCouple exec            % I b
110         1 add exch 1 add exch
111       } repeat                              % I b
112       pop                                   % I
113       dup //.Ranges /CIDCount get gt {      % I
114         dup //.Ranges exch /CIDCount exch put
115       } if                                  % I
116       pop
117     } repeat
118     pop % mark
119   } bind def
120
121   /.GetCIDDecoding         % - .GetCIDDEcoding <dict>
122   { //.Ranges dup length dict copy
123     //.Ranges //.PurgeDict exec
124     //.Ranges /CIDCount 0 put
125   } bind def
126
127 currentdict end
128 exch copy % Merge the dicts - see above.
129 /ProcSet defineresource pop
130
131 %----------------CIDDecoding category----------------------------
132 % Note that we put all instances in global memory - see FindResource.
133
134 /Generic /Category findresource dup length dict copy
135 begin
136   /Category /CIDDecoding def
137   /InstanceType /dicttype def
138
139   /.CMapChooser <<
140     % This lists CMaps to inverse and unite for creating a CIDDecoding.
141     % Choose by FAPIcidfmap.Registry concatenated with TrueType encoding ID.
142     % Font renderer must provide the glyph substitution internally.
143
144     /CNS1.Big5       [ /ETen-B5-H /ETen-B5-V ]
145     /CNS1.Unicode    [ /UniCNS-UCS2-H /UniCNS-UCS2-V]
146     /GB1.GB2312      [ /GBK-EUC-H /GBK-EUC-V ]
147     /GB1.Unicode     [ /UniGB-UCS2-H /UniGB-UCS2-V ]
148     /Japan1.ShiftJIS [ /90ms-RKSJ-H /90ms-RKSJ-V ]
149     /Japan1.Unicode  [ /UniJIS-UCS2-H  /UniJIS-UCS2-V]
150     /Japan2.ShiftJIS [ /90ms-RKSJ-H /90ms-RKSJ-V ]
151     /Japan2.Unicode  [ /UniHojo-UCS2-H ]
152     /Korea1.Johab    [ /KSC-Johab-V /KSC-Johab-H ]
153     /Korea1.Wansung  [ /KSCms-UHC-V /KSCms-UHC-H ]
154     /Korea1.Unicode  [ /UniKS-UCS2-H /UniKS-UCS2-V ]
155     /Identity.Symbol [ /Identity-H /Identity-V ]
156   >> def
157
158   /.MakeInstance    % <name> .MakeInstance <inst>
159   { dup                                              % /Name /Name
160     //.CMapChooser exch .knownget not {
161       (Can't build /) print =string cvs print ( /CIDDecoding resource. See gs_ciddc.ps . ) =
162       /findresource cvx /undefinedresource signalerror
163     } if                                             % /Name [CMaps]
164     exch pop                                         % [CMaps]
165     /CMap /Category findresource                     % [CMaps] <CMapCategory>
166     /ParseCMap_Inverse /ProcSet findresource         % [CMaps] <CMapCategory> <PCI>
167     3 2 roll {                                       % <CMapCategory> <PCI> /CMapName
168       3 2 roll begin                                 % <PCI> /CMapName
169       dup .ResourceFile not {
170         (Can't find CMap ) print =string cvs print ( building a CIDDecoding resource. ) =
171         /findresource cvx /undefinedresource signalerror
172       } if
173       currentdict end exch                           % <PCI> /CMapName <CMapCategory> file
174
175       3 index begin
176       cvx exec                                       % <PCI> /CMapName <CMapCategory>
177       end
178       exch pop exch                                  % <CMapCategory> <PCI>
179     } forall
180     exch pop begin                                   %
181     .GetCIDDecoding
182     end
183   } bind def
184
185   /FindResource      % <name> FindResource <dict>
186   { currentglobal exch                               % bGlobal /InstName
187     true setglobal
188     dup //.MakeInstance exec                         % bGlobal /InstName <Inst>
189     DefineResource                                   % bGlobal <Inst>
190     exch setglobal                                   % <Inst>
191   } bind def
192
193 currentdict end
194 /CIDDecoding exch /Category defineresource pop
195
196 setglobal
197 .setlanguagelevel