groff
[Top][All Lists]
Advanced

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

Re: [Groff] Re-using PSPIC insertions


From: Ted Harding
Subject: Re: [Groff] Re-using PSPIC insertions
Date: Wed, 02 Apr 2003 10:22:15 +0100 (BST)

On 02-Apr-03 Werner LEMBERG wrote:
>> [...]
>> However, if one were creating a document in "raw PostScript"
>> it would be possible to define once and for all a PS name
>> which would invoke the PS code for the graphic. In this way,
>> the code would only need to be embedded once in the document,
>> and could be called by name whenever wanted.
>> 
>> Does anyone have a good idea for how to do this in groff?
> 
> Does anyone have an idea how this can be coded in PS at all?  I tried
> but I always get a limitcheck error even for the smallest EPS files.
> What I exactly like to have is this:
> 
>   . Load an EPS file into the PS interpreter.
> 
>   . Assign the rasterized image to a variable for reuse.
> 
>> The only way which occurs to me is to create a PS file in the
>> first place which incorprates the code and defines a name for
>> it, and then include it once using .PSPIC or \X'ps: import ... ';
>> thereafter, it could perhaps be invoked using \X'ps: exec ... '.
> 
> Yes, something like that should work.

For what it's worth, below is a bit of test code in which I tried
playing with mixing raw PS and groff in order to give a graphic a
PS name for later use (but not importing any external EPS file,
which like Werner I could not get to work).

The code defines an "X" mark with PS name "xfig"; there is also a
macro ".rS" which allows its size to be set once and for all (but
only once -- the last invocation of several applies to the whole
document ... ), and a string def "XX" which can be used to place
the graphic anywhere in text. (It would also be possible to use
".char \[XX] ..." instead of ".ds XX ...")

Part of the problem seems to be that PS definitions in groff are
placed in a special PS dictionary "DEFS" which is output by grops
as part of the prologue, prior to emission of any of the PS code
for the document content. (This also accounts for the fact that
only the last use of ".rS" applies to the whole document, since
each successive use redefines the scaling factor rS within "DEFS"
prior to anything documentary taking place.)

So I suspect that embedding an EPS file once and for all, and giving
it a name for later re-use, would require it to be done so that the
definition went into the DEFS dictionary, and I'm not seeing just now
how to do that!

BEGIN CODE
==========
.de rS 
\X'ps: def /rS {\\$1 mul} def'\c
.nr rSsp \\$1
..
\X'ps: def /xfig \
  { gsave 1 rS -1 rS rlineto gsave stroke grestore \
    -1 rS 0 rS rmoveto 1 rS 1 rS rlineto stroke grestore \
  } def'
.ds XX \X'ps: exec xfig'\h'\\n[rSsp]p'
.LP 
We can include \(lqXfig\(rq whenever we like.
.LP 
For instance, just here:
.rS 9
\*[XX]
and now we continue \(el
.LP
And, dropped a bit, just here:
\v'2.3p'\*[XX]\v'-2.3p'
and now we continue \(el
========
END CODE

Best wishes to all,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 02-Apr-03                                       Time: 10:22:15
------------------------------ XFMail ------------------------------

reply via email to

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