Professional Documents
Culture Documents
%
% This software is provided AS-IS with no warranty, either express or
% implied.
%
% This software is distributed under license and may not be copied,
% modified or distributed except as expressly authorized under the terms
% of the license contained in the file LICENSE in this distribution.
%
% For more information about licensing, please refer to
% http://www.ghostscript.com/licensing/. For information on
% commercial licensing, go to http://www.artifex.com/licensing/ or
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
% San Rafael, CA 94903, U.S.A., +1(415)492-9861.
% Public entries :
languagelevel 2 .setlanguagelevel
currentglobal true setglobal
% When this procedure is called from ResourceForAll, the category is the current
dictionary.
% We remove it from the dictionary stack before performing the enumeration
% to provide the <proc> to write to the underlying dictionary,
% and put it back after the enumeration is completed.
end
{
0 1 2 {
en_local_dict exch /status exch put
InstancesStatus {
en_local_dict /status get eq {
scr cvs % ... (Font)
proc exec %
} {
pop
} ifelse % ...
} forall
} for % ...
} stopped
Category begin
{ stop } if
} bind def
setpacking
% Since the resourceforall procedure may leave values on the operand stack,
% we cannot simply store the enumerator's local data on the stack.
% We also cannot use a static dictionary to store local variables,
% because of possible recursion in the resourceforall procedure.
% To work around this, we create a copy of the enumeration procedure and
% bind it dynamically with a temporary dictionary, which contains
% local variables for the currently executing instance of resourceforall.
currentdict % Category
6 dict begin % the temporary dictionary
/Category exch def %
/InstancesStatus exch def
/scr exch def
/proc exch def
/en_local_dict currentdict def
//InstanceEnumeratorPattern //BindWithCurrentdict exec % Enumerator
/status 0 def % variable for the current status to enumerate - do not bind with
it !
end
} bind def
% Procedures in this dictionary really are patterns for new category methods.
% The following names will be replaced with specific objects during
BindWithCurrentdict :
% .map - the map dictionary;
% DefineResource, ResourceStatus, ResourceFileName, FindResource,
ResourceForAll
% - procedures from the original resource category.
begin % OptionsDict
CategoryName /Category findresource /OldCategory exch def
OldCategory /.IsRedefinedWithMap known {
% Already redefined with map - don't redefine, but enhance the map.
OldCategory /NewCategory exch def
} {
% Redefine with a new category instance.
OldCategory dup length dict
dup /.PreprocessRecord 4 dict put
copy /NewCategory exch def
} ifelse
% Preprocess entries :
dup NewCategory /.PreprocessRecord get % <<map>> <<map>> <<pr>>
3 1 roll { % <<pr>> <<map>> /Name raw_record
false 3 1 roll % <<pr>> <<map>> false /Name
raw_record
4 index { % <<pr>> <<map>> false /Name
raw_record i {pr}
exch pop % <<pr>> <<map>> false /Name
raw_record {pr}
exec { % <<pr>> <<map>> false /Name record
3 -1 roll pop true 3 1 roll % <<pr>> <<map>> true /Name record
exit
} if % <<pr>> <<map>> false /Name
raw_record
} forall
3 2 roll { % <<pr>> <<map>> /Name record
2 index 3 1 roll put % <<pr>> <<map>>
} {
exch % <<pr>> <<map>> raw_record /Name
(Incorrect record ) print =string cvs print ( of the map file ) print
MapFileName =string cvs print (.) =
end % Pops OptionsDict from dstack.
pop pop pop %
/Redefine cvx /undefinedresource signalerror
} ifelse
} forall % <<pr>> <<map>>
exch pop % <<map>>
currentdict end
/ProcSet defineresource pop
setglobal .setlanguagelevel