File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -44,3 +44,7 @@ def setup():
44
44
# are not necessarily the default values as specified in rcsetup.py.
45
45
set_font_settings_for_testing ()
46
46
set_reproducibility_for_testing ()
47
+
48
+
49
+ def _has_tex_package (package ):
50
+ return bool (mpl .dviread .find_tex_file (f"{ package } .sty" ))
Original file line number Diff line number Diff line change 11
11
12
12
import matplotlib as mpl
13
13
import matplotlib .pyplot as plt
14
+ from matplotlib .testing import _has_tex_package
14
15
from matplotlib .testing .compare import compare_images , ImageComparisonFailure
15
16
from matplotlib .backends .backend_pgf import PdfPages , common_texification
16
17
from matplotlib .testing .decorators import (_image_directories ,
@@ -51,10 +52,6 @@ def check_for(texsystem):
51
52
reason = "This test needs a ghostscript installation" )
52
53
53
54
54
- def _has_tex_package (package ):
55
- return bool (mpl .dviread .find_tex_file (f"{ package } .sty" ))
56
-
57
-
58
55
def compare_figure (fname , savefig_kwargs = {}, tol = 0 ):
59
56
actual = os .path .join (result_dir , fname )
60
57
plt .savefig (actual , ** savefig_kwargs )
Original file line number Diff line number Diff line change 2
2
import pytest
3
3
4
4
import matplotlib as mpl
5
+ from matplotlib .testing import _has_tex_package
5
6
from matplotlib .testing .decorators import check_figures_equal , image_comparison
6
7
import matplotlib .pyplot as plt
7
8
@@ -80,6 +81,23 @@ def test_minus_no_descent(fontsize):
80
81
assert len ({* heights .values ()}) == 1
81
82
82
83
84
+ @pytest .mark .skipif (not _has_tex_package ('xcolor' ),
85
+ reason = 'xcolor is not available' )
86
+ def test_usetex_xcolor ():
87
+ mpl .rcParams ['text.usetex' ] = True
88
+
89
+ fig = plt .figure ()
90
+ t = fig .text (0.5 , 0.5 , "Some text 0123456789" )
91
+ fig .canvas .draw ()
92
+ pos = t .get_window_extent ()
93
+
94
+ mpl .rcParams ['text.latex.preamble' ] = r'\usepackage[dvipsnames]{xcolor}'
95
+ fig = plt .figure ()
96
+ t = fig .text (0.5 , 0.5 , "Some text 0123456789" )
97
+ fig .canvas .draw ()
98
+ np .testing .assert_array_equal (t .get_window_extent (), pos )
99
+
100
+
83
101
def test_textcomp_full ():
84
102
plt .rcParams ["text.latex.preamble" ] = r"\usepackage[full]{textcomp}"
85
103
fig = plt .figure ()
You can’t perform that action at this time.
0 commit comments