@@ -245,7 +245,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
245
245
246
246
ctx .save ()
247
247
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 ()) )
249
249
opts = cairo .FontOptions ()
250
250
opts .set_antialias (
251
251
cairo .ANTIALIAS_DEFAULT if mpl .rcParams ["text.antialiased" ]
@@ -271,7 +271,7 @@ def _draw_mathtext(self, gc, x, y, s, prop, angle):
271
271
ctx .move_to (ox , - oy )
272
272
ctx .select_font_face (
273
273
* _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 ) )
275
275
ctx .show_text (chr (idx ))
276
276
277
277
for ox , oy , w , h in rects :
@@ -303,9 +303,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
303
303
# save/restore prevents the problem
304
304
ctx .save ()
305
305
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 ()))
309
307
310
308
y_bearing , w , h = ctx .text_extents (s )[1 :4 ]
311
309
ctx .restore ()
0 commit comments