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 65d2464

Browse filesBrowse files
authored
Merge pull request #29907 from QuLogic/text-caching
Ensure text metric calculation always uses the text cache
2 parents 5c90c35 + 1840d9b commit 65d2464
Copy full SHA for 65d2464

File tree

Expand file treeCollapse file tree

4 files changed

+11
-9
lines changed
Filter options
Expand file treeCollapse file tree

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
@@ -694,10 +694,10 @@ def _get_rendered_text_width(self, text):
694694
Return the width of a given text string, in pixels.
695695
"""
696696

697-
w, h, d = self._renderer.get_text_width_height_descent(
698-
text,
699-
self.get_fontproperties(),
700-
cbook.is_math_text(text))
697+
w, h, d = _get_text_metrics_with_cache(
698+
self._renderer, text, self.get_fontproperties(),
699+
cbook.is_math_text(text),
700+
self.get_figure(root=True).dpi)
701701
return math.ceil(w)
702702

703703
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.