Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3b50d5c

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

File tree

4 files changed

+11
-9
lines changed
Filter options

4 files changed

+11
-9
lines changed

‎lib/matplotlib/offsetbox.py

Copy file name to clipboardExpand all lines: lib/matplotlib/offsetbox.py
+4-3Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/text.py
+4-4Lines 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

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/axis_artist.py
+3-2Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.