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

Skip to content

Commit 7514e3e

Browse files
committed
Merge pull request #494 from mdboom/font_tables_ttf_bug
Non-ascii 8-bit string handling
2 parents 0c7f83d + df428f0 commit 7514e3e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

examples/pylab_examples/font_table_ttf.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
for ccode, glyphind in codes:
3333
if ccode>=256: continue
3434
r,c = divmod(ccode,16)
35-
s = chr(ccode)
35+
s = unichr(ccode)
3636
chars[r][c] = s
3737

3838

lib/matplotlib/cbook.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,11 @@ def __call__(self, key):
18201820
def is_math_text(s):
18211821
# Did we find an even number of non-escaped dollar signs?
18221822
# If so, treat is as math text.
1823-
s = unicode(s)
1823+
try:
1824+
s = unicode(s)
1825+
except UnicodeDecodeError:
1826+
raise ValueError(
1827+
"matplotlib display text must have all code points < 128 or use Unicode strings")
18241828

18251829
dollar_count = s.count(r'$') - s.count(r'\$')
18261830
even_dollars = (dollar_count > 0 and dollar_count % 2 == 0)

0 commit comments

Comments
 (0)