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

Skip to content

Commit 9bc7667

Browse files
committed
Remove Fonts.set_canvas_size and Fonts.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 725c4dc commit 9bc7667

File tree

3 files changed

+2
-17
lines changed

3 files changed

+2
-17
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +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.mathtext_backend.set_canvas_size(*map(math.ceil, [w, h, d]))
149-
150-
@_api.rename_parameter("3.4", "facename", "font")
151143
def render_glyph(self, ox, oy, font, font_class, sym, fontsize, dpi):
152144
"""
153145
At position (*ox*, *oy*), draw the glyph specified by the remaining
@@ -175,13 +167,6 @@ def get_underline_thickness(self, font, fontsize, dpi):
175167
"""
176168
raise NotImplementedError()
177169

178-
def get_results(self, box):
179-
"""
180-
Get the data needed by the backend to render the math
181-
expression. The return value is backend-specific.
182-
"""
183-
return self.mathtext_backend.get_results(box)
184-
185170
def get_sized_alternatives_for_symbol(self, fontname, sym):
186171
"""
187172
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)