lout-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Version 3.32 - embedded Lout files


From: Jeff Kingston
Subject: Re: Version 3.32 - embedded Lout files
Date: Wed, 01 Nov 2006 07:15:59 +1100

I've worked out why Lout's PostScript fails when an EPS file is
included in an EPS file which is then included in an ordinary file.
Here is a detailed description of what goes wrong.

Following Adobe's sample code, Lout prepares for an EPS file inclusion
by counting the number of dictionaries on the stack and storing the
result in a variable called "dict_stack".  When an outer-level file
is preparing for an EPS inclusion, this variable is computed and stored
in the standard "userdict" dictionary, which all PostScript files start
out with.  When an included EPS file is preparing for an EPS inclusion,
this variable is stored in the fresh dictionary that Lout now pushes at
the start of the EPS file and pops at the end.  So it doesn't matter
how deeply EPS files are nested, there will be one distinct "dict_stack"
variable defined for each EPS file currently being read.  So far so good.

Adobe also recommends that a copy of "userdict" be pushed onto the
stack before including an EPS file.  Lout's PostScript does this,
giving the following sequence of events.  Let's say that OUTER is the
main PostScript file, EPS1 is the EPS file included in OUTER, and
EPS2 is the EPS file included in EPS1.

   OUTER prepares for EPS1:
       defines "dict_stack" = 3 (say) in "userdict"
       pushes "userdict"
   EPS1 pushes fresh dictionary, let's call it "dict1"
   EPS1 prepares for EPS2:
       defines "dict_stack" = 5 (say) in "dict1"
       pushes "userdict"
   EPS2 pushes fresh dictionary, let's call it "dict2"
   EPS2 completes, and pops "dict2"
   EPS1 cleans up after EPS2:
       retrieves "dict_stack" and naturally gets value 3, not 5,
       because "userdict" is in front of "dict1", causing too
       many dictionaries to be popped off the stack

Taking everything into consideration, I think the right solution
here is to push a fresh dictionary during preparation for EPS
file inclusion, not "userdict".  This dictionary is only there
to catch definitions made by the EPS file, if the EPS file does
not push its own, according to Adobe; so there is no reason why
it has to be "userdict".  This seems to be an improvement on
Adobe's recommended code even when EPS files are not nested:
surely the intent is to give the included EPS file a fresh
scope to play in, and "userdict" is not fresh.

You can test my proposed fix now by replacing "userdict begin" in
LoutStartEPSF in the PostScrit output by "20 dict begin".  Comments
and suggestions welcome.  I will put out another release with a
fix for this problem when others are happy with it.

Jeff


reply via email to

[Prev in Thread] Current Thread [Next in Thread]