8000 Merge pull request #17156 from anntzer/unpreview · matplotlib/matplotlib@0652132 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0652132

Browse files
authored
Merge pull request #17156 from anntzer/unpreview
Deprecate text.latex.preview rcParam.
2 parents 9575c76 + 96d7d05 commit 0652132

File tree

8 files changed

+18
-6
lines changed

8 files changed

+18
-6
lines changed

doc/api/api_changes_3.3/deprecations.rst

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

408+
``text.latex.preview`` rcParam
409+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
410+
This rcParam, which controlled the use of the preview.sty LaTeX package to
411+
align TeX string baselines, is deprecated, as Matplotlib's own dvi parser now
412+
computes baselines just as well as preview.sty.
413+
408414
``SubplotSpec.get_rows_columns``
409415
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
410416
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
@@ -481,7 +481,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
481481
tex = r'\color[rgb]{%s} %s' % (color, s)
482482

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

lib/matplotlib/dviread.py

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

217217
def _get_baseline(self, filename):
218-
if rcParams['text.latex.preview']:
218+
if dict.__getitem__(rcParams, 'text.latex.preview'):
219219
baseline = Path(filename).with_suffix(".baseline")
220220
if baseline.exists():
221221
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
@@ -221,6 +221,7 @@ def make_tex(self, tex, fontsize):
221221
_re_vbox = re.compile(
222222
r"MatplotlibBox:\(([\d.]+)pt\+([\d.]+)pt\)x([\d.]+)pt")
223223

224+
@cbook.deprecated("3.3")
224225
def make_tex_preview(self, tex, fontsize):
225226
"""
226227
Generate a tex file to render the tex string at a specific font size.
@@ -288,7 +289,7 @@ def make_dvi(self, tex, fontsize):
288289
Return the file name.
289290
"""
290291

291-
if rcParams['text.latex.preview']:
292+
if dict.__getitem__(rcParams, 'text.latex.preview'):
292293
return self.make_dvi_preview(tex, fontsize)
293294

294295
basefile = self.get_basefile(tex, fontsize)
@@ -308,6 +309,7 @@ def make_dvi(self, tex, fontsize):
308309

309310
return dvifile
310311

312+
@cbook.deprecated("3.3")
311313
def make_dvi_preview(self, tex, fontsize):
312314
"""
313315
Generate a dvi file containing latex's layout of tex string.
@@ -399,7 +401,7 @@ def get_text_width_height_descent(self, tex, fontsize, renderer=None):
399401

400402
dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
401403

402-
if rcParams['text.latex.preview']:
404+
if dict.__getitem__(rcParams, 'text.latex.preview'):
403405
# use preview.sty
404406
basefile = self.get_basefile(tex, fontsize)
405407
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)
0