I am trying to scale my pango fonts with a DPI parameter for my
plotting library.  I have two parameters, figsize (tuple in inches)
and DPI (int) and my figure size is a tuple in pixels given by the
product of these, ie, (figsize[0]*dpi, figsize[1]*dpi)

When I increase the DPI for hardcopy (rendering to a pixmap and then
saving as PNG) I want the fonts to scale with the rest of the lines,
rectangles, arcs, etc....

I tried experimenting with the set_size parameter of the
FontDescription and the various pango scales, but there is not a wide
enough range of scales to go from screen displays to, say, hardcopy
resolutions of 600 dpi.

I create the font description as

    # fontsize in points
    font = pango.FontDescription('%s %d' % (fontname, fontsize))

and would like to be able to scale the fontsize by an arbitrary scale,
something like
    
    scale = outputDPI/screenDPI
    font.set_size(int(scale*fontsize*pango.SCALE))

But this will cause X crashes for large values of scale.  If I use the
pango SCALE constants for scale aboce, as in 

    font.set_size(int(pango.SCALE_XX_LARGE*fontsize*pango.SCALE))

I don't get the crashes but I can't get my fonts large enough --
SCALE_XX_LARGE is only 1.2.

Any ideas on how to scale fonts?  Is this possible with pango?  

Alternatively, is there any true type font support that can be used
with pygtk?

Thanks for any help,
John Hunter

X crash with an arbitrary, large, scale factor:

The program 'histogram_demo.py' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadMatch (invalid parameter attributes)'.
  (Details: serial 381 error_code 8 request_code 73 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to