Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bcaa26b

Browse files
committed
Sync Cairo's usetex measurement with base class.
1 parent d85adce commit bcaa26b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/matplotlib/backends/backend_cairo.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,18 @@ def get_canvas_width_height(self):
286286
def get_text_width_height_descent(self, s, prop, ismath):
287287
# docstring inherited
288288

289+
if ismath == 'TeX':
290+
# todo: handle props
291+
texmanager = self._text2path.get_texmanager()
292+
fontsize = prop.get_size_in_points()
293+
w, h, d = texmanager.get_text_width_height_descent(
294+
s, fontsize, renderer=self)
295+
return w, h, d
296+
297+
dpi = self.points_to_pixels(72)
289298
if ismath:
290-
width, height, descent, fonts, used_characters = \
291-
self.mathtext_parser.parse(s, self.dpi, prop)
292-
return width, height, descent
299+
dims = self._text2path.mathtext_parser.parse(s, dpi, prop)
300+
return dims[0:3] # return width, height, descent
293301

294302
ctx = self.text_ctx
295303
# problem - scale remembers last setting and font can become

0 commit comments

Comments
 (0)