I got it figured out, that is, how to make enscript right justify the
margin.

It was really "easy", after I learned a little bit of postscript. I spent a
lot of time puzzling over fonts and transformation matrices. Wasted time.

The command ashow was the key, as in,

x 0 (My line of text) ashow

with x being an addition to the width of each glyph (To us PostScript experts
that is one character.) This command adds x PostScript points (72/inch) to each
character width. One beautiful part is this can be a decimal number or a negative
number. This allows for precise definition of the right margin with each
line of text. No approximations here!

So, it was straightforward.  Use stringwidth to get the width of the
string in the current font, use the length command to get how many
characters are on this line, figure out how many points need
to be added to the line to justify it, divide that by the number of
characters on the line, and ashow the line. To avoid justifying things you
shouldn't, I made one (1) the largest correction applicable to each glyph (1
gt). If the correction was over that, no correction was made.  I suppose
that could be adjusted. One more option to use with enscript, as if it
doesn't have enough already.

I edited the enscript.pro file in /usr/share/enscript and replaced their
redefination of the show command with mine:

/s {show} bind def
/s {
/RM d_page_w def 
/LM 0 def
mark exch dup length exch dup stringwidth pop
RM
exch sub 3 2 roll div dup
1 gt
{LM 3 2 roll show }
{LM 3 2 roll ashow }
ifelse
cleartomark
} def                            

To get this all to work right on some text file from vi or other simple text
editor, I run the file through a sed script which strips out all nl except
blank lines (as paragraph markers), which allows enscript to make the line
breaks, followed by the justification.


Ahhh... Something worked for a change.

Thanks for the suggestions. Although I didn't follow them exactly, they
helped me by providing fresh approaches to a problem.

Joel


_______________________________________________
Linux-users mailing list - http://linux-sxs.org/mailman/listinfo/linux-users
Subscribe/Unsubscribe info, Archives,and Digests are located at the above URL.

Reply via email to