8000 Backport PR #29907: Ensure text metric calculation always uses the te… · matplotlib/matplotlib@3b50d5c · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b50d5c

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR #29907: Ensure text metric calculation always uses the text cache
1 parent acb7361 commit 3b50d5c

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,9 +794,10 @@ def get_offset(self):
794794
return self._offset
795795

796796
def get_bbox(self, renderer):
797-
_, h_, d_ = renderer.get_text_width_height_descent(
798-
"lp", self._text._fontproperties,
799-
ismath="TeX" if self._text.get_usetex() else False)
797+
_, h_, d_ = mtext._get_text_metrics_with_cache(
798+
renderer, "lp", self._text._fontproperties,
799+
ismath="TeX" if self._text.get_usetex() else False,
800+
dpi=self.get_figure(root=True).dpi)
800801

801802
bbox, info, yd = self._text._get_layout(renderer)
802803
w, h = bbox.size
Loading

lib/matplotlib/text.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,10 @@ def _get_rendered_text_width(self, text):
678678
Return the width of a given text string, in pixels.
679679
"""
680680

681-
w, h, d = self._renderer.get_text_width_height_descent(
682-
text,
683-
self.get_fontproperties(),
684-
cbook.is_math_text(text))
681+
w, h, d = _get_text_metrics_with_cache(
682+
self._renderer, text, self.get_fontproperties(),
683+
cbook.is_math_text(text),
684+
self.get_figure(root=True).dpi)
685685
return math.ceil(w)
686686

687687
def _get_wrapped_text(self):

lib/mpl_toolkits/axisartist/axis_artist.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,9 @@ def get_texts_widths_heights_descents(self, renderer):
588588
if not label.strip():
589589
continue
590590
clean_line, ismath = self._preprocess_math(label)
591-
whd = renderer.get_text_width_height_descent(
592-
clean_line, self._fontproperties, ismath=ismath)
591+
whd = mtext._get_text_metrics_with_cache(
592+
renderer, clean_line, self._fontproperties, ismath=ismath,
593+
dpi=self.get_figure(root=True).dpi)
593594
whd_list.append(whd)
594595
return whd_list
595596

0 commit comments

Comments
 (0)
0