Skip to content

Commit de1a328

Browse files
authored
Merge pull request matplotlib#19900 from QuLogic/remove-text-deprecations
Remove 3.3 text deprecations
2 parents 8b9890e + e3fdaac commit de1a328

File tree

10 files changed

+36
-108
lines changed

10 files changed

+36
-108
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
The ``TTFPATH`` and ``AFMPATH`` environment variables
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
Support for the (undocumented) ``TTFPATH`` and ``AFMPATH`` environment
4+
variables has been removed. Register additional fonts using
5+
``matplotlib.font_manager.fontManager.addfont()``.
6+
7+
mathtext ``Glue`` classes
8+
~~~~~~~~~~~~~~~~~~~~~~~~~
9+
The following have been removed from `matplotlib.mathtext`:
10+
11+
* *copy* parameter of ``mathtext.Glue``
12+
* ``mathtext.Glue.glue_subtype``
13+
* ``mathtext.GlueSpec``
14+
* ``Fil``, ``Fill``, ``Filll``, ``NegFil``, ``NegFill``, ``NegFilll``, and
15+
``SsGlue``; directly construct glue instances with ``Glue("fil")``, etc.
16+
17+
*ismath* parameter of ``draw_tex``
18+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19+
The *ismath* parameter of the ``draw_tex`` method of all renderer classes has
20+
been removed (as a call to ``draw_tex`` -- not to be confused with
21+
``draw_text``! -- means that the entire string should be passed to the
22+
``usetex`` machinery anyways). Likewise, the text machinery will no longer pass
23+
the *ismath* parameter when calling ``draw_tex`` (this should only matter for
24+
backend implementers).
25+
26+
Passing ``ismath="TeX!"`` to `.RendererAgg.get_text_width_height_descent` is no
27+
longer supported; pass ``ismath="TeX"`` instead,

lib/matplotlib/_mathtext.py

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,10 +1546,7 @@ class Glue(Node):
15461546
it's easier to stick to what TeX does.)
15471547
"""
15481548

1549-
glue_subtype = _api.deprecated("3.3")(property(lambda self: "normal"))
1550-
1551-
@_api.delete_parameter("3.3", "copy")
1552-
def __init__(self, glue_type, copy=False):
1549+
def __init__(self, glue_type):
15531550
super().__init__()
15541551
if isinstance(glue_type, str):
15551552
glue_spec = _GlueSpec._named[glue_type]
@@ -1571,51 +1568,6 @@ def grow(self):
15711568
self.glue_spec = g._replace(width=g.width * GROW_FACTOR)
15721569

15731570

1574-
# Some convenient ways to get common kinds of glue
1575-
1576-
1577-
@_api.deprecated("3.3", alternative="Glue('fil')")
1578-
class Fil(Glue):
1579-
def __init__(self):
1580-
super().__init__('fil')
1581-
1582-
1583-
@_api.deprecated("3.3", alternative="Glue('fill')")
1584-
class Fill(Glue):
1585-
def __init__(self):
1586-
super().__init__('fill')
1587-
1588-
1589-
@_api.deprecated("3.3", alternative="Glue('filll')")
1590-
class Filll(Glue):
1591-
def __init__(self):
1592-
super().__init__('filll')
1593-
1594-
1595-
@_api.deprecated("3.3", alternative="Glue('neg_fil')")
1596-
class NegFil(Glue):
1597-
def __init__(self):
1598-
super().__init__('neg_fil')
1599-
1600-
1601-
@_api.deprecated("3.3", alternative="Glue('neg_fill')")
1602-
class NegFill(Glue):
1603-
def __init__(self):
1604-
super().__init__('neg_fill')
1605-
1606-
1607-
@_api.deprecated("3.3", alternative="Glue('neg_filll')")
1608-
class NegFilll(Glue):
1609-
def __init__(self):
1610-
super().__init__('neg_filll')
1611-
1612-
1613-
@_api.deprecated("3.3", alternative="Glue('ss')")
1614-
class SsGlue(Glue):
1615-
def __init__(self):
1616-
super().__init__('ss')
1617-
1618-
16191571
class HCentered(Hlist):
16201572
"""
16211573
A convenience class to create an `Hlist` whose contents are

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,7 @@ def option_scale_image(self):
522522
"""
523523
return False
524524

525-
@_api.delete_parameter("3.3", "ismath")
526-
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
525+
def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
527526
"""
528527
"""
529528
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")

lib/matplotlib/backends/backend_agg.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,8 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
217217
def get_text_width_height_descent(self, s, prop, ismath):
218218
# docstring inherited
219219

220-
if ismath in ["TeX", "TeX!"]:
221-
if ismath == "TeX!":
222-
_api.warn_deprecated(
223-
"3.3", message="Support for ismath='TeX!' is deprecated "
224-
"since %(since)s and will be removed %(removal)s; use "
225-
"ismath='TeX' instead.")
220+
_api.check_in_list(["TeX", True, False], ismath=ismath)
221+
if ismath == "TeX":
226222
# todo: handle props
227223
texmanager = self.get_texmanager()
228224
fontsize = prop.get_size_in_points()

lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,8 +2156,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
21562156
# Pop off the global transformation
21572157
self.file.output(Op.grestore)
21582158

2159-
@_api.delete_parameter("3.3", "ismath")
2160-
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
2159+
def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
21612160
# docstring inherited
21622161
texmanager = self.get_texmanager()
21632162
fontsize = prop.get_size_in_points()

lib/matplotlib/backends/backend_pgf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def draw_image(self, gc, x, y, im, transform=None):
668668
interp, w, h, fname_img))
669669
writeln(self.fh, r"\end{pgfscope}")
670670

671-
def draw_tex(self, gc, x, y, s, prop, angle, ismath="TeX!", mtext=None):
671+
def draw_tex(self, gc, x, y, s, prop, angle, ismath="TeX", mtext=None):
672672
# docstring inherited
673673
self.draw_text(gc, x, y, s, prop, angle, ismath, mtext)
674674

lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
548548

549549
self._path_collection_id += 1
550550

551-
@_api.delete_parameter("3.3", "ismath")
552-
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
551+
def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
553552
# docstring inherited
554553
if not hasattr(self, "psfrag"):
555554
_log.warning(

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
12171217

12181218
writer.end('g')
12191219

1220-
@_api.delete_parameter("3.3", "ismath")
1221-
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
1220+
def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
12221221
# docstring inherited
12231222
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")
12241223

lib/matplotlib/font_manager.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,23 +1027,10 @@ def __init__(self, size=None, weight='normal'):
10271027
self.__default_weight = weight
10281028
self.default_size = size
10291029

1030+
# Create list of font paths.
10301031
paths = [cbook._get_data_path('fonts', subdir)
10311032
for subdir in ['ttf', 'afm', 'pdfcorefonts']]
1032-
# Create list of font paths
1033-
for pathname in ['TTFPATH', 'AFMPATH']:
1034-
if pathname in os.environ:
1035-
ttfpath = os.environ[pathname]
1036-
if ttfpath.find(';') >= 0: # win32 style
1037-
paths.extend(ttfpath.split(';'))
1038-
elif ttfpath.find(':') >= 0: # unix style
1039-
paths.extend(ttfpath.split(':'))
1040-
else:
1041-
paths.append(ttfpath)
1042-
_api.warn_deprecated(
1043-
"3.3", name=pathname, obj_type="environment variable",
1044-
alternative="FontManager.addfont()")
10451033
_log.debug('font search path %s', str(paths))
1046-
# Load TrueType fonts and create font dictionary.
10471034

10481035
self.defaultFamily = {
10491036
'ttf': 'DejaVu Sans',

lib/matplotlib/mathtext.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -359,36 +359,6 @@ class MathTextWarning(Warning):
359359
pass
360360

361361

362-
@_api.deprecated("3.3")
363-
class GlueSpec:
364-
"""See `Glue`."""
365-
366-
def __init__(self, width=0., stretch=0., stretch_order=0,
367-
shrink=0., shrink_order=0):
368-
self.width = width
369-
self.stretch = stretch
370-
self.stretch_order = stretch_order
371-
self.shrink = shrink
372-
self.shrink_order = shrink_order
373-
374-
def copy(self):
375-
return GlueSpec(
376-
self.width,
377-
self.stretch,
378-
self.stretch_order,
379-
self.shrink,
380-
self.shrink_order)
381-
382-
@classmethod
383-
def factory(cls, glue_type):
384-
return cls._types[glue_type]
385-
386-
387-
with _api.suppress_matplotlib_deprecation_warning():
388-
GlueSpec._types = {k: GlueSpec(**v._asdict())
389-
for k, v in _mathtext._GlueSpec._named.items()}
390-
391-
392362
@_api.deprecated("3.4")
393363
def ship(ox, oy, box):
394364
_mathtext.ship(ox, oy, box)

0 commit comments

Comments
 (0)