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

Skip to content

Commit ca54adb

Browse files
committed
Expire mathttext-related deprecations
1 parent 68d6b79 commit ca54adb

File tree

8 files changed

+63
-357
lines changed

8 files changed

+63
-357
lines changed

doc/api/mathtext_api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@
99
:members:
1010
:undoc-members:
1111
:show-inheritance:
12-
:exclude-members: Box, Char, ComputerModernFontConstants, DejaVuSansFontConstants, DejaVuSerifFontConstants, FontConstantsBase, Fonts, Glue, Kern, Node, Parser, STIXFontConstants, STIXSansFontConstants, Ship, StandardPsFonts, TruetypeFonts
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Removal of deprecated ``mathtext`` APIs
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The following :mod:`.mathtext` APIs have been removed:
5+
``MathtextBackendBitmap``,
6+
``MathtextBackendPs``,
7+
``MathtextBackendPdf``,
8+
``MathtextBackendSvg``,
9+
``MathtextBackendCairo``,
10+
``ship``,
11+
``Fonts``,
12+
``TruetypeFonts``,
13+
``StandardPsFonts``,
14+
``FontConstantsBase``,
15+
``ComputerModernFontConstants``,
16+
``STIXFontConstants``,
17+
``STIXSansFontConstants``,
18+
``DejaVuSerifFontConstants``,
19+
``DejaVuSansFontConstants``,
20+
``FontConstantsBase``,
21+
``Node``,
22+
``Box``,
23+
``Char``,
24+
``Glue``,
25+
``Kern``,
26+
``Ship``,
27+
``Parser``,
28+
``SHRINK_FACTOR``,
29+
``GROW_FACTOR``,
30+
``NUM_SIZE_LEVELS``,
31+
``latex_to_bakoma``,
32+
``latex_to_cmex``,
33+
``latex_to_standard``,
34+
``stix_virtual_fonts``, and
35+
``tex2uni``
36+
37+
The methods ``to_mask``, ``to_rgba``, ``to_png``, and ``get_depth`` to
38+
``MathTextParser`` have been removed. Use ``mathtext.math_to_image`` instead.
39+
40+
The named keyword argument ``_force_standard_ps_fonts`` to
41+
``MathTextParser.parse`` has been removed.
42+
43+
The following :mod:.`_mathtext` APIs have been removed:
44+
``Fonts.destroy()``, ``TruetypeFonts.destroy()``, and ``StandardPsFonts.pswriter()``

doc/sphinxext/math_symbol_table.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from docutils.parsers.rst import Directive
22

3-
from matplotlib import mathtext
3+
from matplotlib import _mathtext, _mathtext_data
44

55

66
symbols = [
@@ -103,9 +103,9 @@ def run(state_machine):
103103
def render_symbol(sym):
104104
if sym.startswith("\\"):
105105
sym = sym[1:]
106-
if sym not in {*mathtext.Parser._overunder_functions,
107-
*mathtext.Parser._function_names}:
108-
sym = chr(mathtext.tex2uni[sym])
106+
if sym not in (_mathtext.Parser._overunder_functions |
107+
{*_mathtext.Parser._function_names}):
108+
sym = chr(_mathtext_data.tex2uni[sym])
109109
return f'\\{sym}' if sym in ('\\', '|') else sym
110110

111111
lines = []
@@ -149,7 +149,6 @@ def setup(app):
149149

150150
if __name__ == "__main__":
151151
# Do some verification of the tables
152-
from matplotlib import _mathtext_data
153152

154153
print("SYMBOLS NOT IN STIX:")
155154
all_symbols = {}

lib/matplotlib/_mathtext.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from collections import namedtuple
66
import enum
77
import functools
8-
from io import StringIO
98
import logging
109
import os
1110
import types
@@ -92,14 +91,6 @@ def __init__(self, default_font_prop, mathtext_backend):
9291
self.mathtext_backend = mathtext_backend
9392
self.used_characters = {}
9493

95-
@_api.deprecated("3.4")
96-
def destroy(self):
97-
"""
98-
Fix any cyclical references before the object is about
99-
to be destroyed.
100-
"""
101-
self.used_characters = None
102-
10394
def get_kern(self, font1, fontclass1, sym1, fontsize1,
10495
font2, fontclass2, sym2, fontsize2, dpi):
10596
"""
@@ -203,11 +194,6 @@ def get_results(self, box):
203194
"""
204195
result = self.mathtext_backend.get_results(
205196
box, self.get_used_characters())
206-
if self.destroy != TruetypeFonts.destroy.__get__(self):
207-
destroy = _api.deprecate_method_override(
208-
__class__.destroy, self, since="3.4")
209-
if destroy:
210-
destroy()
211197
return result
212198

213199
def get_sized_alternatives_for_symbol(self, fontname, sym):
@@ -235,11 +221,6 @@ def __init__(self, default_font_prop, mathtext_backend):
235221
self._fonts['default'] = default_font
236222
self._fonts['regular'] = default_font
237223

238-
@_api.deprecated("3.4")
239-
def destroy(self):
240-
self.glyphd = None
241-
super().destroy()
242-
243224
def _get_font(self, font):
244225
if font in self.fontmap:
245226
basename = self.fontmap[font]
@@ -803,8 +784,6 @@ def __init__(self, default_font_prop, mathtext_backend=None):
803784
self.fonts['default'] = default_font
804785
self.fonts['regular'] = default_font
805786

806-
pswriter = _api.deprecated("3.4")(property(lambda self: StringIO()))
807-
808787
def _get_font(self, font):
809788
if font in self.fontmap:
810789
basename = self.fontmap[font]

lib/matplotlib/backends/_backend_pdf_ps.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
104104
s, fontsize, renderer=self)
105105
return w, h, d
106106
elif ismath:
107-
# Circular import.
108-
from matplotlib.backends.backend_ps import RendererPS
109-
parse = self._text2path.mathtext_parser.parse(
110-
s, 72, prop,
111-
_force_standard_ps_fonts=(isinstance(self, RendererPS)
112-
and mpl.rcParams["ps.useafm"]))
107+
parse = self._text2path.mathtext_parser.parse(s, 72, prop)
113108
return parse.width, parse.height, parse.depth
114109
elif mpl.rcParams[self._use_afm_rc_name]:
115110
font = self._get_font_afm(prop)

lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
689689
def draw_mathtext(self, gc, x, y, s, prop, angle):
690690
"""Draw the math text using matplotlib.mathtext."""
691691
width, height, descent, glyphs, rects = \
692-
self._text2path.mathtext_parser.parse(
693-
s, 72, prop,
694-
_force_standard_ps_fonts=mpl.rcParams["ps.useafm"])
692+
self._text2path.mathtext_parser.parse(s, 72, prop)
695693
self.set_color(*gc.get_rgb())
696694
self._pswriter.write(
697695
f"gsave\n"

0 commit comments

Comments
 (0)