Skip to content

Commit db5ecdc

Browse files
Yuyaanntzer
Yuya
authored andcommitted
Added test encoding issue in SVG backend
1 parent d4b9701 commit db5ecdc

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
@@ -177,3 +177,24 @@ def psfont(*args, **kwargs):
177177
ax.text(0.5, 0.5, 'hello')
178178
with tempfile.TemporaryFile() as tmpfile, pytest.raises(ValueError):
179179
fig.savefig(tmpfile, format='svg')
180+
181+
182+
@needs_tex
183+
def test_unicode_won():
184+
from pylab import rcParams, plot, ylabel, savefig
185+
rcParams.update({'text.usetex': True, 'text.latex.unicode': True})
186+
187+
plot(1, 1)
188+
ylabel(r'\textwon')
189+
190+
fd = BytesIO()
191+
savefig(fd, format='svg')
192+
fd.seek(0)
193+
buf = fd.read().decode()
194+
fd.close()
195+
196+
won_id = 'Computer_Modern_Sans_Serif-142'
197+
def_regex = re.compile(r'<path d=(.|\s)*?id="{0}"/>'.format(won_id))
198+
use_regex = re.compile(r'<use[^/>]*? xlink:href="#{0}"/>'.format(won_id))
199+
assertTrue(bool(def_regex.search(buf)))
200+
assertTrue(bool(use_regex.search(buf)))

0 commit comments

Comments
 (0)