groff
[Top][All Lists]
Advanced

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

Re: [Groff] How to embed PS char into groff input


From: Tadziu Hoffmann
Subject: Re: [Groff] How to embed PS char into groff input
Date: Tue, 11 Dec 2001 13:16:16 +0100

> 1. Put the PS code into a file "rose2.ps". NB that this code
> MUST include a suitable "%%BoundingBox:" comment line.

Actually, the file does NOT need the BoundingBox comment,
since it isn't evaluated by anybody.  However, the numbers
in the "import" device control have to be correct.


Anyhow, here's a different version that does the same thing
(but is perhaps easier to understand):

Add the following rose definition to the grops dictionary in
the PostScript prolog file ($GROFF_FONT_PATH/devps/prologue):
(You can use a "ps: def" device control in your manuscript
instead.)

/wedge
{ newpath
  % rgbR rgbG rgbB setrgbcolor
  0 0 moveto
  1 0 translate
  15 rotate
  0 15 sin translate
  0 0 15 sin -90 90 arc
  closepath }
def

/rose
{ gsave
  currentpoint translate
  2000 1.2 mul div dup scale
  1.2 -1.2 translate
  0.02 setlinewidth
  1 1 12
  { 12 div setgray
    gsave wedge gsave fill grestore 0 setgray stroke grestore
    30 rotate }
  for
  grestore }
def

This defines a PostScript procedure "rose" (taking one argument,
the desired size of the rose) which we can have executed by a
"ps: exec" device control:

.char \[rose] \X'ps: exec \\n[.ps] rose'\h'1m'

This character definition tells PostScript to draw the rose in a
size proportional to the current troff font size (any additional
scaling is done by PostScript within the rose procedure) and also
tells troff the width of the character (in this case, 1 em).

Now we can use the rose character as in Ted's example:

A Rose \[rose]\s+8 A Rose \[rose]\s0 A Rose \[rose]
.sp 1
rose\[rose]\*{rose\[rose]\*{rose\[rose]\*}\*}rose
.sp 1
\(->\[rose]\(<-


(By the way: the \*{, \*} definitions in the groff-1.17.1 version
of gs.tmac do not allow nesting, because the size is restored
with \s0 which can only go back one size change.)


Have fun!
Tadziu

reply via email to

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