Advice sought on ps module

Markus von Ehr markus.vonehr at ipm.fhg.de
Thu Jun 20 07:35:51 EDT 2002


Hi,

do you know the PSDraw Module in the PIL?
http://www.pythonware.com/library/pil/handbook/psdraw.htm
Maybe this is a solution for you.

Markus


Hans-Joachim Widmaier schrieb:

> 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