groff
[Top][All Lists]
Advanced

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

Re: [groff] Fonts, PDF images, groff vs. heirloom troff


From: Boss Hog
Subject: Re: [groff] Fonts, PDF images, groff vs. heirloom troff
Date: Sun, 27 Jan 2019 15:29:48 -0500
User-agent: NeoMutt/20170113 (1.7.2)

On Sat, Jan 26, 2019 at 07:02:52AM -0800, Mircea Hossu wrote:
> If the text "GROFF and Friends" was initially a standalone image which
> was stacked on top of another image, it seems like it's exactly the
> goal. Would it be possible to share how you achieved this, i.e. how to
> "wrap a bitmap in custom Postscript code"? Even if it's manually
> tedious, it would be ok. Also, if it uses any kind of non-standard
> operators, it would be useful to know what the limitations are, for
> example, if you have to use specifically the GhostScript program to
> convert PS->PDF, etc.
> 
> Thank you.
> 
I apologise for the delay, the relevant code was disorganised. I also
discovered a less tiresome method.
These are all standard operators and will work for PostScript and PDF output.
My orignal method required converting the bitmap file into hex and building
a custom image dictionary for each image and running ghostscript with the
-dNOSAFER option. This new method using sam2p does the tedious work and
leaves us with an easy editing task without the need for the dreaded
NOSAFER option. You may "distill" groff's output to a lower level PostScript
code using ps2ps or perform a pdf conversion with ps2pdf. I have not tested
against other PostScript environments.

You will need the sam2p utility. I had to search the debain linux site and
install it manually using dpkg. The link for debian:
https://packages.debian.org/jessie/amd64/sam2p/download

Invoke sam2p as:
sam2p -p:3 your_bitmap_file postscript_file.ps

Edit postscript_file.ps with vi or other editor. Search for the string:
/ImageType 1 and replace with: /ImageType 4
This tells the postscript interpreter to use chroma-key masking.
Next, after /ImageType 4 add the string /MaskColor [0 0 0] to turn
every occurance of black, transparent. You may specify a range of colors,
use /MaskColor [0 30 0 30 0 30] to turn black through dark grey,
transparent. The matrix [0 0 0] represents the RGB color space with 
values [0 0 0] black to [255 255 255] white. The CMYK color space is 
specified by [0 0 0 0] white to [255 255 255 255] black

To include this in your groff document you may use .PSPIC or the
\X'ps:import ...' escape sequence. the \X'ps:import ...' offers greater 
flexibilty in positioning. Both methods may be positioned using .sp, \h'..'
and \v'..' escapes.

As an example:
.\" Run as: groff -mom filename > filename.ps
.\" This uses the mom macro package.
.PRINTSTYLE TYPESET
.SIZE 150                                                                       
.LS 100p
\f[TR]                                                                         
GROFF                                                                           
.br                                                                             
and                                                                             
.br                                                                             
Friends                                                                         
.br                                                                             
\s0                                                                             
.RLD .5i                                                                        
.CENTER                                                                         
.\" Move upward 3 inches and load our file.
.\" man grops describes the \X'ps:import ..,' escape's requirements.
\h'-3i'\X'ps:import /full/path/postscript_file.ps 340 340 2400 2400 210000'



reply via email to

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