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

Skip to content

Commit 9443f7d

Browse files
committed
Remove Fonts.{set_canvas_size,width,height,descent,get_results}.
We can just inline the calls directly to the backend itself at the sole use site (in _parse_cached). The width, height, and depth attributes on Fonts are never used either.
1 parent 36ee213 commit 9443f7d

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,6 @@ def get_metrics(self, font, font_class, sym, fontsize, dpi, math=True):
140140
info = self._get_info(font, font_class, sym, fontsize, dpi, math)
141141
return info.metrics
142142

143-
def set_canvas_size(self, w, h, d):
144-
"""
145-
Set the size of the buffer used to render the math expression.
146-
Only really necessary for the bitmap backends.
147-
"""
148-
self.width, self.height, self.depth = np.ceil([w, h, d])
149-
self.mathtext_backend.set_canvas_size(
150-
self.width, self.height, self.depth)
151-
152143
@_api.rename_parameter("3.4", "facename", "font")
153144
def render_glyph(self, ox, oy, font, font_class, sym, fontsize, dpi):
154145
"""
@@ -185,15 +176,6 @@ def get_used_characters(self):
185176
"""
186177
return self.used_characters
187178

188-
def get_results(self, box):
189-
"""
190-
Get the data needed by the backend to render the math
191-
expression. The return value is backend-specific.
192-
"""
193-
result = self.mathtext_backend.get_results(
194-
box, self.get_used_characters())
195-
return result
196-
197179
def get_sized_alternatives_for_symbol(self, fontname, sym):
198180
"""
199181
Override if your font provides multiple sizes of the same

lib/matplotlib/mathtext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ def _parse_cached(self, s, dpi, prop):
256256
self.__class__._parser = _mathtext.Parser()
257257

258258
box = self._parser.parse(s, font_output, fontsize, dpi)
259-
font_output.set_canvas_size(box.width, box.height, box.depth)
260-
return font_output.get_results(box)
259+
backend.set_canvas_size(*np.ceil([box.width, box.height, box.depth]))
260+
return backend.get_results(box)
261261

262262

263263
def math_to_image(s, filename_or_obj, prop=None, dpi=None, format=None,

0 commit comments

Comments
 (0)