[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] How to embed PS char into groff input
From: |
Amitava Dutta |
Subject: |
Re: [Groff] How to embed PS char into groff input |
Date: |
Wed, 9 Jan 2002 18:40:22 -0500 |
Thanks to all, esp Ted and Tadziu for the help.
I had been following Ted's original example
and it is working fine.
Now I have a set of input which requires
the mm macro (groff -mm) and when I use
this macro, I get error
warning: numeric expression expected (got a special character)
How do I modify the character definition to survive the macro ?
Thanks
Amitava
----- Original Message -----
From: "Ted Harding" <address@hidden>
To: "Amitava Dutta" <address@hidden>
Cc: <address@hidden>
Sent: Saturday, December 08, 2001 4:45 AM
Subject: RE: [Groff] How to embed PS char into groff input
> On 07-Dec-01 Amitava Dutta wrote:
> > I have
> > (a) a PostScript code fragment
> > (i.e. gsave .... grestore)
> > which draws a piece of graphic.
> > This is to be used as the character XY
> > in a groff input (below).
> >
> > (b) a set of groff (rather troff) input files
> > that has the sequence
> > \(XY
> > and each such occurance has to use the
> > graphic (above) as the character XY.
> >
> > How do I print these to a PostScript printer ?
>
> Sorry about the length of this response. The following
> is from a groff demo talk of mine, using PS code from
> "PostScript Language Tutorial and Cookbook" (the "Blue Book"),
> page 133 ("Program 1 / Repeated Shapes"). First the PS code
> for the graphic, then the details for making this into a groff
> character, finally a demo of how it can be used.
>
> 1. Put the PS code into a file "rose2.ps". NB that this code
> MUST include a suitable "%%BoundingBox:" comment line.
> ====================
> %!PS-Adobe-3.0
> %%BoundingBox: 172 173 259 260
> /inch {72 mul} def
>
> /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
>
> gsave
> 3 inch 3 inch translate
> 0.5 inch 0.5 inch scale
> 0.02 setlinewidth
> 1 1 12
> { 12 div setgray
> gsave
> wedge
> gsave fill grestore
> 0 setgray stroke
> grestore
> 30 rotate
> } for
> grestore
>
> showpage
> ===================
>
> 2. Define the character "\[rose]" using the groff ".char"
> request, which uses the "\X'ps: import" function to pull in
> the code from the file (Note the explicit citation of the
> "%%BoundingBox:" coordinates from the graphic file):
>
> .char \[rose] \Z'\h'+\\n[.ps]u*1u/40u'\v'\\n[.ps]u*10u/42u'\
> \X'ps: import rose2.ps \
> 172 173 259 260 \\n[.ps]''\&\h'\\n[.ps]u'
>
> ====================
>
> 3. Use it:
>
> A Rose \[rose]\s+8 A Rose \[rose]\s0 A Rose \[rose]
> .sp 1
> \[rose]\*{\[rose]\*{\[rose]\*}\*}
>
> (This uses the ms macros where "\*{" raises the following
> text as a superscript with reduced font size, and "\*}"
> restores the normal printing on the line).
>
> ====================
>
> I hope this is a sufficient model for you to adapt it to
> your own requirements. Use \(XY or \[XY] instead of \[rose],
> your own PS file instead of "rose2.ps", and watch out for
> that "%%BoundingBox:"!
>
> This should work on any version of groff. You don't need
> to interfere with any of the font files in ..../devps,
> since it is all done "in-line".
>
> Good luck!
>
> Ted.
>
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <address@hidden>
> Fax-to-email: +44 (0)870 167 1972
> Date: 08-Dec-01 Time: 09:45:31
> ------------------------------ XFMail ------------------------------
>
- Re: [Groff] How to embed PS char into groff input,
Amitava Dutta <=