Advice sought on ps module

Hans-Joachim Widmaier hjwidmaier at web.de
Fri Jun 21 03:56:04 EDT 2002


eddie at holyrood.ed.ac.uk (Eddie Corns) wrote in message news:<aesoqg$kc9$1 at scotsman.ed.ac.uk>...

> I'm not sure that I understand completely what you're trying to do so maybe
> I'm barking up the wrong gum tree here but ...

I admit that my writing wasn't very clear ...
 
> Surely you want to use postscript itself to do all the work.  PS already has
> an operator called stringwidth and a complete set of programming constructs so
> the trick usually is to generate the appropriate PS commands.

That's how I do it today. Well, I should have given a more concrete
example. I've written a program that creates good looking timing
diagrams for documentation purposes. These consist of a drawing part
and signal names to the left. While the python program knows exactly
how large the drawing itself is, it has no way of knowing how far the
signal names extend to the left, making it all but impossible to give
a valid boundig box for the whole thing -- which is required, as it's
going to be an EPS file. Sure, I can get at the BBox by piping the
finished file through one of the ps utils programs, but this is kinda
cumbersome. And it still doesn't allow me to adjust the right-hand
drawing width so the combined width is of some fixed size.

> As an example,
> to draw a border around some arbitrary text I guess you could generate code to
> do something like:  save current position, for each string you draw calculate
> the bounding box and remember the highest X value and at the end use the new
> position along with the saved position and highest X value to define the four
> corners of a rectangle.  It does require a fair degree of competence in PS but
> you wouldn't tackle such a project without it (or a desire to achieve it)
> would you :)

Another example: In my CD cover/inlay generator I have to do insert
line breaks if the Title+Singer+Time line doesn't fit. I do this in
PostScript, as I don't know the width in the Python program. This has
the drawback that the height of the title list changes and my careful
layout (not to be taken too seriously) is disrupted. And no, I do
*not* want to write a layout engine in PostScript.

Despite having read most of the PostScript Reference Manual, the AFM
spec, the DSC specs, etc., ... and having written a bunch of programs
that output PostScript, I still consider myself a novice (at best!).
This reverse notation thing with all those stacks gives me the creeps.
;-)

Hope these explanations make the misery I'm in somewhat more clear.

Hans-Joachim



More information about the Python-list mailing list