>>>>> "Paul" == Paul Barrett <ba...@st...> writes:
Paul> This was an easy change to the font manager. You should see
Paul> it in CVS later today.
Great.
An unrelated bug I found in testing with one of my apps
In the font_manager
def get_size_in_points(self, parent_size=None):
"""Convert text to point size"""
if isinstance(self.__size, str):
if self.__size == 'larger':
size = int(self.__parent_size*1.2)
elif self.__size == 'smaller':
size = int(self.__parent_size/1.2)
else:
defsize = fontManager.get_default_size()
size = defsize*font_scalings[self.__size]
return size
else:
return self.__size
I sometimes get key error on font_scalings[self.__size] when
self.__size is a number, eg 10. From the code, it looks like you
intend self.__size to always be a relative size. I did a temporary
workaround along the lines of
else:
try: size = float(self.__size)
except ValueError:
defsize = fontManager.get_default_size()
size = defsize*font_scalings[self.__size]
return size
but this hack may be masking another bug so I thought you'd want to
look into it.
Paul> On a related issue, I noticed that the sizes of PS plots are
Paul> different depending on which backend is used first. If I
Paul> send a plot directly to the PS backend, I get a nice plot
Paul> (see the attachment simple_plot_PS.ps). Whereas, if I first
Paul> display the plot using TkAgg and then save it to PS, I get a
Paul> plot that is much larger than the display area (see the
Paul> attachment simple_plot.ps). The text size in both plots
Paul> appears to be the same size, this would indicate an
Paul> incorrect scaling factor somewhere.
backend_tkagg needs to override FigureCanvasTkAgg.print_figure
following the lead of backend_gtkagg. The critical point is that dpi
must be set to 72 for backend_ps. Even though ps doesn't use DPI,
this value is used by the figure to compute the canvas size as
width*dpi and height*dpi, and this does affect backend_ps.
In FigureCanvaseGTKAgg.print_figure I save the orig dpi, set the
figure dpi to 72, print the figure, and then reset. I do the same
with other figure properties (eg, background color, so you can have a
different color background for printing and GUI).
It should be mostly a cut and paste from backend_gtkagg.
JDH
|