Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1660

Re: Named Resources

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date Fri, 27 Sep 2013 10:44:03 -0500
From John Deubert <john@acumentraining.com>
Organization Acumen Training
Newsgroups comp.lang.postscript
Date Fri, 27 Sep 2013 08:44:03 -0700
Message-ID <20130927084403903-john@acumentrainingcom> (permalink)
References <ad8a9d89-952f-4e17-8ff8-2fbd8ce6e26e@googlegroups.com>
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding 8bit
Subject Re: Named Resources
User-Agent Unison/2.1.10
Lines 204
X-Usenet-Provider http://www.giganews.com
X-Trace sv3-HxJ6WgTnCKWVKNmPAQuOoos8dMTZHufGUmUHFCeao2M53h0DGe+cFcSqm+kIfdyN08zyPjhlAT8vPkm!dyMAT9CQQHtr/tMWcdk/sccPB/m38Jjg18eIlrdRs0uVJoSMCxA2fo9Sy/Jer/8+
X-Complaints-To abuse@giganews.com
X-DMCA-Notifications http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 7652
Xref csiph.com comp.lang.postscript:1660

Show key headers only | View raw


On 2013-09-24 22:19:43 +0000, luser- -droog said:

> I've spent the last few weeks trying to wrap my head
> around how to implement Named Resources. I'm just going
> to talk about what I think I know. Please correct any
> mistakes!
> 
> Named Resources exist in up to 3 places at any given time
> while "part of the system".
> 
>   * in a filesystem directory
>   * in a data structure in local vm
>   * in a data structure in global vm
> 
> So, I'm going to create 2 data structures,
> as a rough start:
> 
> true setglobal
> globaldict begin
> /globalresourcedict <<
>     /Category <<
>     >>
>     /Generic <<
>     >>
>     /ProcSet <<
>     >>
>>> def
> end
> 
> false setglobal
> userdict begin
> /localresourcedict <<
>     /Encoding <<
>         /StandardEncoding [ ]
>         /ISOLatin1Encoding [ ]
>     >>
>>> def
> end
> 
> I still don't understand Category and Generic. :(

	X-Received:	by 10.66.145.7 with SMTP id 
sq7mr2745294pab.43.1380292315848; Fri, 27 Sep 2013 07:31:55 -0700 (PDT)
	Path: 
border1.nntp.dca3.giganews.com!Xl.tags.giganews.com!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!border1.nntp.hkg.giganews.com!news.netfront.net!news.glorb.com!z6no27972927pbz.1!news-out.google.com!z6ni74626pbu.0!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail 

	NNTP-Posting-Date:	Fri, 27 Sep 2013 09:31:55 -0500
	From:	John Deubert <john@acumentraining.com>
	Organization:	Acumen Training
	Newsgroups:	comp.lang.postscript
	Date:	Fri, 27 Sep 2013 07:31:55 -0700
	Message-ID:	<2013092707315563519-john@acumentrainingcom>
	References:	<ad8a9d89-952f-4e17-8ff8-2fbd8ce6e26e@googlegroups.com>
	MIME-Version:	1.0
	Subject:	Re: Named Resources
	User-Agent:	Unison/2.1.10
	Lines:	120
	X-Usenet-Provider:	http://www.giganews.com
	X-Trace: 
sv3-ezYP0wfR3Cu/Bz3fBd/WLu0tLHKnRFHiQljeVduelQWqfXMpSAZGc5fcvYlCKa9ShgBlWC1Cq9kte29!FY94CF6efQpZyIiXTWXyiDhRJSZ2SC8tz5DMhDa4TmYKu47Xi/XcsTVIjB8JuIE5msk= 

	X-Complaints-To:	abuse@giganews.com
	X-DMCA-Notifications:	http://www.giganews.com/info/dmca.html
	X-Abuse-and-DMCA-Info:	Please be sure to forward a copy of ALL headers
	X-Abuse-and-DMCA-Info:	Otherwise we will be unable to process your 
complaint properly
	X-Postfilter:	1.3.40
	X-Original-Bytes:	5354
	Content-Type:	text/plain; charset=utf-8; format=flowed
	Content-Transfer-Encoding:	8bit
	Bytes:	5406
	Xref:	number.nntp.dca.giganews.com comp.lang.postscript:73766

On 2013-09-24 22:19:43 +0000, luser- -droog said:

> I've spent the last few weeks trying to wrap my head
> around how to implement Named Resources. I'm just going
> to talk about what I think I know. Please correct any
> mistakes!
> 
> Named Resources exist in up to 3 places at any given time
> while "part of the system".
> 
> * in a filesystem directory
> * in a data structure in local vm
> * in a data structure in global vm
> 
> So, I'm going to create 2 data structures,
> as a rough start:
> 
> true setglobal
> globaldict begin
> /globalresourcedict <<
> /Category <<
>>> 
> /Generic <<
>>> 
> /ProcSet <<
>>> 
>>> def
> end
> 
> false setglobal
> userdict begin
> /localresourcedict <<
> /Encoding <<
> /StandardEncoding [ ]
> /ISOLatin1Encoding [ ]
>>> 
>>> def
> end
> 
> I still don't understand Category and Generic. :(


[[ Sorry if this is a repeat post; I'm trying out a new newsreader and 
the first attempt didn't seem to take.]]

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	% Get the appropriate Category resource dictionary
	/FindResource get		% Get the FindResource procedure out of that dict
	exec					% execute it

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

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Named Resources luser- -droog <mijoryx@yahoo.com> - 2013-09-24 15:19 -0700
  Re: Named Resources John Deubert <john@acumentraining.com> - 2013-09-27 07:31 -0700
    Re: Named Resources luser- -droog <mijoryx@yahoo.com> - 2013-09-29 22:32 -0700
  Re: Named Resources John Deubert <john@acumentraining.com> - 2013-09-27 07:44 -0700
  Re: Named Resources John Deubert <john@acumentraining.com> - 2013-09-27 07:49 -0700
  Re: Named Resources John Deubert <john@acumentraining.com> - 2013-09-27 08:44 -0700
  Re: Named Resources wst wst <wouter_staelens@hotmail.com> - 2017-08-29 02:02 -0700
    Re: Named Resources luser droog <luser.droog@gmail.com> - 2017-08-29 19:25 -0700
    Re: Named Resources Carlos <carlos@cvkm.cz> - 2017-08-30 19:24 +0200

csiph-web