From e9a812036d84bd08f650ad2651a4b77795dfee85 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 15 May 2018 02:11:47 -0700 Subject: [PATCH] Deprecate text.latex.unicode. It is 2018 and Python3 is ruling the world; it is high time for usetex to default to unicode support as well. (If ``\usepackage[utf8]{inputenc}`` is irremediably breaking some users' setup we can always revisit this decision.) --- doc/api/next_api_changes/2018-02-15-AL-deprecations.rst | 1 + doc/api/next_api_changes/2018-05-15-AL.rst | 8 ++++++++ examples/text_labels_and_annotations/tex_demo.py | 1 - .../text_labels_and_annotations/usetex_baseline_test.py | 1 - lib/matplotlib/__init__.py | 3 ++- lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle | 2 -- lib/matplotlib/mpl-data/stylelib/classic.mplstyle | 2 -- lib/matplotlib/rcsetup.py | 2 +- lib/matplotlib/tests/test_backend_ps.py | 4 ++-- lib/matplotlib/tests/test_rcparams.py | 2 +- lib/matplotlib/texmanager.py | 6 ++---- matplotlibrc.template | 2 -- 12 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 doc/api/next_api_changes/2018-05-15-AL.rst diff --git a/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst b/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst index 51198eef7a4e..ad6991df404b 100644 --- a/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst +++ b/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst @@ -37,3 +37,4 @@ The following classes, methods, functions, and attributes are deprecated: The following rcParams are deprecated: - ``pgf.debug`` (the pgf backend relies on logging), +- ``text.latex.unicode``, diff --git a/doc/api/next_api_changes/2018-05-15-AL.rst b/doc/api/next_api_changes/2018-05-15-AL.rst new file mode 100644 index 000000000000..82422ec5500e --- /dev/null +++ b/doc/api/next_api_changes/2018-05-15-AL.rst @@ -0,0 +1,8 @@ +Changes regarding the text.latex.unicode rcParam +```````````````````````````````````````````````` + +The rcParam now defaults to True and is deprecated (i.e., in future versions +of Maplotlib, unicode input will always be supported). + +Moreover, the underlying implementation now uses ``\usepackage[utf8]{inputenc}`` +instead of ``\usepackage{ucs}\usepackage[utf8x]{inputenc}``. diff --git a/examples/text_labels_and_annotations/tex_demo.py b/examples/text_labels_and_annotations/tex_demo.py index 01ba41b433be..4d0bc4f37ca6 100644 --- a/examples/text_labels_and_annotations/tex_demo.py +++ b/examples/text_labels_and_annotations/tex_demo.py @@ -17,7 +17,6 @@ import numpy as np import matplotlib matplotlib.rcParams['text.usetex'] = True -matplotlib.rcParams['text.latex.unicode'] = True import matplotlib.pyplot as plt diff --git a/examples/text_labels_and_annotations/usetex_baseline_test.py b/examples/text_labels_and_annotations/usetex_baseline_test.py index 6d8b79177d17..0a72afab63e2 100644 --- a/examples/text_labels_and_annotations/usetex_baseline_test.py +++ b/examples/text_labels_and_annotations/usetex_baseline_test.py @@ -11,7 +11,6 @@ from matplotlib import rcParams rcParams['text.usetex'] = True -rcParams['text.latex.unicode'] = True class Axes(maxes.Axes): diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 09856d9e1cfc..e97bda744c32 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -820,7 +820,8 @@ def gen_candidates(): # do NOT include in _all_deprecated _deprecated_set = {'axes.hold', 'backend.qt4', - 'backend.qt5'} + 'backend.qt5', + 'text.latex.unicode'} _all_deprecated = set(itertools.chain( _deprecated_ignore_map, _deprecated_map, _obsolete_set)) diff --git a/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle b/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle index c42222ad8f19..853b3481e4c7 100644 --- a/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle @@ -109,8 +109,6 @@ text.usetex : False # use latex for all text handling. The following fo # If another font is desired which can loaded using the # LaTeX \usepackage command, please inquire at the # matplotlib mailing list -text.latex.unicode : False # use "ucs" and "inputenc" LaTeX packages for handling - # unicode strings. text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES # AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP # IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO. diff --git a/lib/matplotlib/mpl-data/stylelib/classic.mplstyle b/lib/matplotlib/mpl-data/stylelib/classic.mplstyle index 94ae5bf7a4f3..6da7b07b27dd 100644 --- a/lib/matplotlib/mpl-data/stylelib/classic.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/classic.mplstyle @@ -111,8 +111,6 @@ text.usetex : False # use latex for all text handling. The following fo # If another font is desired which can loaded using the # LaTeX \usepackage command, please inquire at the # matplotlib mailing list -text.latex.unicode : False # use "ucs" and "inputenc" LaTeX packages for handling - # unicode strings. text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES # AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP # IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO. diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 99c643edcf6c..acb5aa440849 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -1115,7 +1115,7 @@ def _validate_linestyle(ls): # text props 'text.color': ['black', validate_color], 'text.usetex': [False, validate_bool], - 'text.latex.unicode': [False, validate_bool], + 'text.latex.unicode': [True, validate_bool], 'text.latex.preamble': [[''], validate_stringlist], 'text.latex.preview': [False, validate_bool], 'text.dvipnghack': [None, validate_bool_maybe_none], diff --git a/lib/matplotlib/tests/test_backend_ps.py b/lib/matplotlib/tests/test_backend_ps.py index fd0d192c3e38..ca6b53346308 100644 --- a/lib/matplotlib/tests/test_backend_ps.py +++ b/lib/matplotlib/tests/test_backend_ps.py @@ -32,11 +32,11 @@ needs_ghostscript( ('ps', False, {'ps.usedistiller': 'ghostscript'})), needs_usetex(needs_ghostscript( - ('ps', False, {'text.latex.unicode': True, 'text.usetex': True}))), + ('ps', False, {'text.usetex': True}))), ('eps', False, {}), ('eps', True, {'ps.useafm': True}), needs_usetex(needs_ghostscript( - ('eps', False, {'text.latex.unicode': True, 'text.usetex': True}))), + ('eps', False, {'text.usetex': True}))), ], ids=[ 'ps', 'ps with distiller', diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py index 14b589780c0a..c7e70d59882b 100644 --- a/lib/matplotlib/tests/test_rcparams.py +++ b/lib/matplotlib/tests/test_rcparams.py @@ -476,7 +476,7 @@ def test_if_rctemplate_is_up_to_date(): continue if k in deprecated: continue - if "verbose" in k: + if k.startswith(("text.latex.unicode", "verbose.")): continue found = False for line in rclines: diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index 085a65f49e9a..aed767da0e76 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -203,8 +203,7 @@ def make_tex(self, tex, fontsize): if rcParams['text.latex.unicode']: unicode_preamble = r""" -\usepackage{ucs} -\usepackage[utf8x]{inputenc}""" +\usepackage[utf8]{inputenc}""" else: unicode_preamble = '' @@ -255,8 +254,7 @@ def make_tex_preview(self, tex, fontsize): if rcParams['text.latex.unicode']: unicode_preamble = r""" -\usepackage{ucs} -\usepackage[utf8x]{inputenc}""" +\usepackage[utf8]{inputenc}""" else: unicode_preamble = '' diff --git a/matplotlibrc.template b/matplotlibrc.template index 6d8654d05eeb..7ae28dfb494a 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -225,8 +225,6 @@ backend : $TEMPLATE_BACKEND ## If another font is desired which can loaded using the ## LaTeX \usepackage command, please inquire at the ## matplotlib mailing list -#text.latex.unicode : False ## use "ucs" and "inputenc" LaTeX packages for handling - ## unicode strings. #text.latex.preamble : ## IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES ## AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP ## IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO.