Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit65d2464

Browse files
authored
Merge pull request#29907 from QuLogic/text-caching
Ensure text metric calculation always uses the text cache
2 parents5c90c35 +1840d9b commit65d2464

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
returnself._offset
795795

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

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

‎lib/matplotlib/text.py

Lines 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
returnmath.ceil(w)
702702

703703
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
ifnotlabel.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
returnwhd_list
595596

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp