[Image-SIG] Finding font sizes for PSDraw

Edward Loper edloper@seas.upenn.edu
02 May 2002 10:42:24 -0400


I have a program that uses the ImageDraw module to draw a picture, and
I'd like to be able to use the PSDraw module to draw the same pictures. 
It's just lines and text, so in principle it shouldn't be too hard.  

The only problem I'm having is that with ImageDraw, I can use
Font.getsize to find the dimensions of a string; but I don't have
anything equivalant to use with PSDraw.  The height is easy enough to
calculate: it's basically the font's point size times the number of
lines times a constant factor.  But the width is harder, because I'd
like to use non-monospaced fonts.  

Does anyone have any ideas for finding the width (in points) of a string
for a given Postscript font and font size (I'd be willing to limit
myself to just Times if I needed to)?

If worst came to worst, I could use a hard-coded table of character
widths (*shudder*), but I don't know where to get one, and I *really*
don't want to make one by hand.

Thanks for any help,

-Edward