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

Skip to content

Commit 96d7d05

Browse files
committed
Deprecate text.latex.preview rcParam.
It is now unneeded; see changelog note.
1 parent 53faed9 commit 96d7d05

8 files changed

Lines changed: 18 additions & 6 deletions

File tree

doc/api/api_changes_3.3/deprecations.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,12 @@ instead.
388388
The unused ``animation.html_args`` rcParam and ``animation.HTMLWriter.args_key``
389389
attribute are deprecated.
390390

391+
``text.latex.preview`` rcParam
392+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393+
This rcParam, which controlled the use of the preview.sty LaTeX package to
394+
align TeX string baselines, is deprecated, as Matplotlib's own dvi parser now
395+
computes baselines just as well as preview.sty.
396+
391397
``SubplotSpec.get_rows_columns``
392398
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
393399
This method is deprecated. Use the ``GridSpec.nrows``, ``GridSpec.ncols``,

examples/text_labels_and_annotations/usetex_baseline_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Usetex Baseline Test
44
====================
55
6+
A test for :rc:`text.latex.preview`, a deprecated feature which relied
7+
on the preview.sty LaTeX package to properly align TeX baselines. This
8+
feature has been deprecated as Matplotlib's dvi parser now computes baselines
9+
just as well as preview.sty; this example will be removed together with
10+
:rc:`text.latex.preview` after the deprecation elapses.
611
"""
712

813
import matplotlib.pyplot as plt

lib/matplotlib/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ def gen_candidates():
624624
'mathtext.fallback_to_cm': ('3.3',),
625625
'keymap.all_axes': ('3.3',),
626626
'savefig.jpeg_quality': ('3.3',),
627+
'text.latex.preview': ('3.3',),
627628
}
628629

629630

lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
477477
tex = r'\color[rgb]{%s} %s' % (color, s)
478478

479479
corr = 0 # w/2*(fontsize-10)/10
480-
if mpl.rcParams['text.latex.preview']:
480+
if dict.__getitem__(mpl.rcParams, 'text.latex.preview'):
481481
# use baseline alignment!
482482
pos = _nums_to_str(x-corr, y)
483483
self.psfrag.append(

lib/matplotlib/dviread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def __init__(self, filename, dpi):
214214
self.baseline = self._get_baseline(filename)
215215

216216
def _get_baseline(self, filename):
217-
if rcParams['text.latex.preview']:
217+
if dict.__getitem__(rcParams, 'text.latex.preview'):
218218
baseline = Path(filename).with_suffix(".baseline")
219219
if baseline.exists():
220220
height, depth, width = baseline.read_bytes().split()

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURE
122122
# beware of package collisions: color, geometry, graphicx,
123123
# type1cm, textcomp. Adobe Postscript (PSSNFS) font packages
124124
# may also be loaded, depending on your font settings
125-
text.latex.preview : False
126125

127126
text.hinting : auto # May be one of the following:
128127
# 'none': Perform no hinting

lib/matplotlib/texmanager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ def make_tex(self, tex, fontsize):
219219
_re_vbox = re.compile(
220220
r"MatplotlibBox:\(([\d.]+)pt\+([\d.]+)pt\)x([\d.]+)pt")
221221

222+
@cbook.deprecated("3.3")
222223
def make_tex_preview(self, tex, fontsize):
223224
"""
224225
Generate a tex file to render the tex string at a specific font size.
@@ -286,7 +287,7 @@ def make_dvi(self, tex, fontsize):
286287
Return the file name.
287288
"""
288289

289-
if rcParams['text.latex.preview']:
290+
if dict.__getitem__(rcParams, 'text.latex.preview'):
290291
return self.make_dvi_preview(tex, fontsize)
291292

292293
basefile = self.get_basefile(tex, fontsize)
@@ -306,6 +307,7 @@ def make_dvi(self, tex, fontsize):
306307

307308
return dvifile
308309

310+
@cbook.deprecated("3.3")
309311
def make_dvi_preview(self, tex, fontsize):
310312
"""
311313
Generate a dvi file containing latex's layout of tex string.
@@ -397,7 +399,7 @@ def get_text_width_height_descent(self, tex, fontsize, renderer=None):
397399

398400
dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
399401

400-
if rcParams['text.latex.preview']:
402+
if dict.__getitem__(rcParams, 'text.latex.preview'):
401403
# use preview.sty
402404
basefile = self.get_basefile(tex, fontsize)
403405
baselinefile = '%s.baseline' % basefile

matplotlibrc.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@
291291
# type1cm, textcomp.
292292
# Adobe Postscript (PSSNFS) font packages may also be
293293
# loaded, depending on your font settings.
294-
#text.latex.preview: False
295294

296295
#text.hinting: auto # May be one of the following:
297296
# - none: Perform no hinting

0 commit comments

Comments
 (0)