Advice sought on ps module

Hans-Joachim Widmaier hjwidmaier at web.de
Thu Jun 20 07:25:53 EDT 2002


About 2 years ago I wrote a primitive PostScript module to help me
create various things like CD inlays or diagrams. It served that
purpose quite well, despite its primitiveness.
Since long I wanted to rewrite the whole thing from scratch and do it
(at least kind of) "right." But I'm still not so sure as which way to
go. At one time I thought I might employ ghostscript, which would have
enabled me to, e. g. get the string width for some text, so I can make
adjustments (not only to the text). Apart from that I couldn't get a
sensible communication with gs through popen2, the PostScript output
is created somewhat nonlinear, making it harder to ensure that the gs
context is correct (in that query case).
I'm convinced that's the wrong way, but the alternative doesn't look
too good either. If you want to do some optimizations, you have to
double some functionality of the ps interpreter.

Examples:
  - To calculate the with of a string, you have to read the AFM file,
add the character widths, aplly kerning, transform it with the CTM and
the fonts TM.
  - To know whether a font must be reset or is already the current
font you have to keep track of all the save/restore, gsave/grestore
and the like.

I do not want to write a "do all, end all" PostScript module. I do not
even want to give it away (I'd be simply too embarrassed).

Still I hope that some of you might give me some good advice on how to
best do it.

Thanks for any suggestion!
Hans-Joachim



More information about the Python-list mailing list