Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0122faf

Browse files
authored
Merge pull request #2 from Sunakujira1/patch-3
Added test encoding issue in SVG backend
2 parents 6b4827a + 3fad38d commit 0122faf

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
@@ -208,3 +208,24 @@ def psfont(*args, **kwargs):
208208
ax.text(0.5, 0.5, 'hello')
209209
with tempfile.TemporaryFile() as tmpfile, pytest.raises(ValueError):
210210
fig.savefig(tmpfile, format='svg')
211+
212+
213+
@needs_tex
214+
def test_unicode_won():
215+
from pylab import rcParams, plot, ylabel, savefig
216+
rcParams.update({'text.usetex': True, 'text.latex.unicode': True})
217+
218+
plot(1, 1)
219+
ylabel(r'\textwon')
220+
221+
fd = BytesIO()
222+
savefig(fd, format='svg')
223+
fd.seek(0)
224+
buf = fd.read().decode()
225+
fd.close()
226+
227+
won_id = 'Computer_Modern_Sans_Serif-142'
228+
def_regex = re.compile(r'<path d=(.|\s)*?id="{0}"/>'.format(won_id))
229+
use_regex = re.compile(r'<use[^/>]*? xlink:href="#{0}"/>'.format(won_id))
230+
assertTrue(bool(def_regex.search(buf)))
231+
assertTrue(bool(use_regex.search(buf)))

0 commit comments

Comments
 (0)