Skip to content

Commit 88e1b53

Browse files
Yuyaanntzer
Yuya
authored andcommitted
Added test encoding issue in SVG backend
1 parent 2c0f5ec commit 88e1b53

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/matplotlib/tests/test_backend_svg.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,24 @@ def psfont(*args, **kwargs):
184184
ax.text(0.5, 0.5, 'hello')
185185
with tempfile.TemporaryFile() as tmpfile, pytest.raises(ValueError):
186186
fig.savefig(tmpfile, format='svg')
187+
188+
189+
@needs_tex
190+
def test_unicode_won():
191+
from pylab import rcParams, plot, ylabel, savefig
192+
rcParams.update({'text.usetex': True, 'text.latex.unicode': True})
193+
194+
plot(1, 1)
195+
ylabel(r'\textwon')
196+
197+
fd = BytesIO()
198+
savefig(fd, format='svg')
199+
fd.seek(0)
200+
buf = fd.read().decode()
201+
fd.close()
202+
203+
won_id = 'Computer_Modern_Sans_Serif-142'
204+
def_regex = re.compile(r'<path d=(.|\s)*?id="{0}"/>'.format(won_id))
205+
use_regex = re.compile(r'<use[^/>]*? xlink:href="#{0}"/>'.format(won_id))
206+
assertTrue(bool(def_regex.search(buf)))
207+
assertTrue(bool(use_regex.search(buf)))

0 commit comments

Comments
 (0)