From 972b815c596792c0f40a3a368f44e5b8eada3b26 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 15 Jul 2022 16:47:55 +0200 Subject: [PATCH 1/3] Directly support ^% in pgf. Support for `^` is inspired from the support for `_` as implemented in underscore.sty, but much simpler because 1) we don't care about hyphenation, 2) we don't care about substituting a real underscore by a rule box when the current font lacks an underscore (there's no real way out if the font has no caret, anyways), and 3) we don't care about the active character ending up in tex `\commands` because the character is only made active in the context of matplotlib-provided strings, not globally. --- lib/matplotlib/backends/backend_pgf.py | 29 ++++++++++++++---------- lib/matplotlib/tests/test_backend_pgf.py | 11 +++++---- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index a5c93136829d..94ab547f3b47 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -85,9 +85,6 @@ def _get_preamble(): _NO_ESCAPE = r"(? Date: Fri, 15 Jul 2022 17:23:44 +0200 Subject: [PATCH 2/3] Also handle `\displaystyle` and `\mathdefault` at the TeX level. Note that tex_escape is still being tested by test_minus_signs_with_tex, which explicitly checks support for unicode minus. --- lib/matplotlib/backends/backend_pgf.py | 37 ++++++++---------------- lib/matplotlib/tests/test_backend_pgf.py | 9 +----- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/lib/matplotlib/backends/backend_pgf.py b/lib/matplotlib/backends/backend_pgf.py index 94ab547f3b47..77cbc899c16b 100644 --- a/lib/matplotlib/backends/backend_pgf.py +++ b/lib/matplotlib/backends/backend_pgf.py @@ -38,9 +38,9 @@ @_api.caching_module_getattr class __getattr__: NO_ESCAPE = _api.deprecated("3.6", obj_type="")( - property(lambda self: _NO_ESCAPE)) + property(lambda self: r"(? Date: Tue, 19 Jul 2022 22:23:15 +0200 Subject: [PATCH 3/3] Bump test tolerance by 1-per-thousand on old ghostscripts. --- lib/matplotlib/tests/test_backend_pgf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_backend_pgf.py b/lib/matplotlib/tests/test_backend_pgf.py index 5cd58963e4cf..5b2f1a5c43fa 100644 --- a/lib/matplotlib/tests/test_backend_pgf.py +++ b/lib/matplotlib/tests/test_backend_pgf.py @@ -95,7 +95,7 @@ def test_xelatex(): @pytest.mark.skipif(not _has_tex_package('ucs'), reason='needs ucs.sty') @pytest.mark.backend('pgf') @image_comparison(['pgf_pdflatex.pdf'], style='default', - tol=11.7 if _old_gs_version else 0) + tol=11.71 if _old_gs_version else 0) def test_pdflatex(): if os.environ.get('APPVEYOR'): pytest.xfail("pdflatex test does not work on appveyor due to missing "