Category is the resource category that keeps track of resource
categories. (That sentence was a paragon of clarity, no?)
The resources in the Category category have names like /Form, /Font,
/Pattern, /Encoding, etc. The resource data associated with each of
these names is a dictionary whose contents are mostly procedures with
names corresponding to the resource-related PostScript operators,
though capitalized differently: /FindResource, /DefineResource,
/ResourceForAll, etc. These are the procedures that implement the
operator activities for that particular resource category.
The findresource operator does the following:
/Category findresource /FindResource get exec
That is, if you do this:
/Helvetica /Font findresource
The findresource operator gets the Font Category resource dictionary,
fetches the FindResource procedure from that dictionary, and then
executes it. The other resource operators do similar things.
The Generic category is used when you want to create your own resource
Category. Creating your own category is simple, in principle: just
create a new Category resource:
/MyNewCategory
<<
/DefineResource { … }
/FindResource { … }
…
>> /Category defineresource
The Generic category exists so you don’t need to forever be coming up
with your own definitions for those operator-implementation procedures.
You can simply copy the procedures from the Generic category
dictionary. (The Generic procedures are parameterized based on the name
of the category.)
Thus, to create a BBox resource category (to use an example from my
Advanced PostScript class), you’d do this:
/BBox
/Generic /Category findresource % Get the Generic category dict
dup length dict % Create an identically-sized dict
copy % and copy Generic into the new dict
/Category defineresource pop % Then make it a resource.
% Now you can create BBox resources:
/Letter [ 0 0 612 792 ] /BBox defineresource pop
% And use them
/Letter /BBox findresource clip
Hope that helped some. Resources takes quite a while to get the hang
of; it’s a two-hour discussion in the Advanced PostScript class.
In particular, using resources aren’t extremely useful (for what I
usually do, anyway) unless you have external storage available to the
interpreter. In that case, you can arrange it so that findresource
looks on the disk if it doesn’t find the resource you want in memory;
all future programs sent to that interpreter can use BBox resources (or
whatever) with no initial work.
I hope some part of that was lucid.
- John
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com
Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html