groff
[Top][All Lists]
Advanced

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

Re: [Groff] Include PostScript


From: Ted Harding
Subject: Re: [Groff] Include PostScript
Date: Sun, 07 Nov 2010 18:27:46 -0000 (GMT)

On 07-Nov-10 17:11:24, manday wrote:
> I'm sorry. It looks like I have underestimated the clean and precise
> structure of groff again. I found out that the pspic macro package
> provides this macro and is included by groff by default. The macro in
> turns includes the picture using the native groff requests which are to
> complicated to be used manually by any human being :)
> 
> Consider the issue closed. Thanks.

Don't give up too quickly on those "native groff requests"!

The key to importing an EPS file is the escape sequence

  \X'ps: import filename.eps llx lly urx ury deswid desht

where "filename.eps" is the name of the EPS file, and
llx, lly, urx, ury are the coordinates (in points) of the
lower left (llx,lly) and upper right (urx,ury) corners of
the BoundingBox as defined in the "%%BoundingBox:" line
of the EPS file, and deswid, desht (the latter optional)
are the desired width and height of the resulting graphic
in the document expressed in "device units" which, for the
PS device, is point/1000 (so a width of 345 points would
have deswid = 345000). [1 point = 1/72 inch]

A typical "%%BoundingBox:" line in the EPS file looks like

  %%BoundingBox: 2 12 612 561

so here llx=2, lly=12, urx=612, ury=561.

The command ".psbb" will extract the BoundingBox coordinates
and set registers named "llx", "lly", "urx", "ury" to the
corresponding values.

The effect of the "\X'ps: import ..." above will be:

1. The graphic defined by the EPS file will be placed with
   its lower-left corner at the current position on the page.

2. It will be horizontally scaled so that its width on the page
   will be deswid/1000 points (which may have a fractional part).

3. If "desht" is absent, it will be vertically scaled so as to
   preserve the original vertical/horizontal proportion.

   If desht is present, it will be vertically rescaled so that
   its height on the page will be desht/1000 points (regardles
   of the horizontal width).

4. After the graphic has been placed, the current position on
   the page will be restored to what it was before (i.e. to
   what is now the lower left corner of the graphic). Therefore
   you next need to move the current position to where you want
   the next mark on the page to be placed (which will probably
   be the first letter of some text). Do this using "\h'...'"
   and "\v'...'" escape sequences.

5. If you do not want the lower left corner to be at the
   current position (e.g. you want the top of the graphic to
   be level with the current position) then first move the
   current point. It may be useful to enclose this, and
   the rest of the import mechanism) in "\Z'...'" which
   will restore the current position regardless of what "..." does.

The above description underlies the operation of the ".PSPIC"
macro. Clearly, using ".PSPIC" is a painless way of doing it.

However, it is really straightforward enough to be used "raw"
for things which ".PSPIC" was not designed to handle. For example,
you can use it to create a character glyph which can be used
just like any character in a standard font. Here is an example
(note use of "\" at end of line to continue long lines).

First, choose an EPS file (say "myfile.eps") that you want to use
to define a character glyph "\[mychar]".
Then, before you will use \[mychar], put the following:

.psbb mychar.eps \"sets registers \n[llx], \n[lly], \n[urx], \n[ury]
.char \[mychar] \R'msize \w'N''\
\X'ps: import myfile.eps \\n[llx] \\n[lly] \\n[urx] \\n[ury] \\n[msize]'\
\h'\\n[msize]u'

Then you can enter text on the lines of:
----------------------------------------
The symbol \[mychar] denotes a peculiar idea of mine, so I
will use it like: \[lq]I have had 2 \[mychar]s this morning,
and I expect to have a big \s[+10]\[mychar\]\s0 this afternoon\[rq].
----------------------------------------

The only bit about the above that needs further explanation is
the "\R'msize \w'N''" bit. This sets the user-defined register
\n[msize] to be the width (in device units) of the character "N"
in the current font and in the current point size. This is then
used as the "deswid" of the new character \[mychar] in whatever
context this occurs. Thus \[mychar] will always scale to have
the same width as "N" in the current context. You can of course
use some other specification for \n[msize] in "\R'msize ...'".

And you may need to also include something to make sure that
enough vertical space is allowed (so that it doesn't overlap
the line above, say). For this, the "\x'...'" sequence can be
used (and even included in the definition of \[mychar]).

Hoping this helps -- and ecourages!
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 07-Nov-10                                       Time: 18:27:43
------------------------------ XFMail ------------------------------



reply via email to

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