@@ -245,7 +245,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
245245
246246 ctx .save ()
247247 ctx .select_font_face (* _cairo_font_args_from_font_prop (prop ))
248- ctx .set_font_size (prop .get_size_in_points () * self . dpi / 72 )
248+ ctx .set_font_size (self . points_to_pixels ( prop .get_size_in_points ()) )
249249 opts = cairo .FontOptions ()
250250 opts .set_antialias (
251251 cairo .ANTIALIAS_DEFAULT if mpl .rcParams ["text.antialiased" ]
@@ -271,7 +271,7 @@ def _draw_mathtext(self, gc, x, y, s, prop, angle):
271271 ctx .move_to (ox , - oy )
272272 ctx .select_font_face (
273273 * _cairo_font_args_from_font_prop (ttfFontProperty (font )))
274- ctx .set_font_size (fontsize * self .dpi / 72 )
274+ ctx .set_font_size (self .points_to_pixels ( fontsize ) )
275275 ctx .show_text (chr (idx ))
276276
277277 for ox , oy , w , h in rects :
@@ -303,9 +303,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
303303 # save/restore prevents the problem
304304 ctx .save ()
305305 ctx .select_font_face (* _cairo_font_args_from_font_prop (prop ))
306- # Cairo (says it) uses 1/96 inch user space units, ref: cairo_gstate.c
307- # but if /96.0 is used the font is too small
308- ctx .set_font_size (prop .get_size_in_points () * self .dpi / 72 )
306+ ctx .set_font_size (self .points_to_pixels (prop .get_size_in_points ()))
309307
310308 y_bearing , w , h = ctx .text_extents (s )[1 :4 ]
311309 ctx .restore ()
0 commit comments