Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e3e78be

Browse filesBrowse files
committed
FIX: always decode byte strings from AFM files as utf8
closes #9196
1 parent c7107cd commit e3e78be
Copy full SHA for e3e78be

File tree

Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed

‎lib/matplotlib/afm.py

Copy file name to clipboardExpand all lines: lib/matplotlib/afm.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ def _parse_char_metrics(fh):
189189
ascii_d = {}
190190
name_d = {}
191191
for line in fh:
192-
line = line.rstrip().decode('ascii') # Convert from byte-literal
192+
# We are defensively letting values be utf8. The spec requires
193+
# ascii, but there are non-compliant fonts in circulation
194+
line = _to_str(line.rstrip()) # Convert from byte-literal
193195
if line.startswith('EndCharMetrics'):
194196
return ascii_d, name_d
195197
# Split the metric line into a dictionary, keyed by metric identifiers
@@ -392,7 +394,7 @@ def get_str_bbox_and_descent(self, s):
392394
maxy = 0
393395
left = 0
394396
if not isinstance(s, six.text_type):
395-
s = s.decode('ascii')
397+
s = _to_str(s)
396398
for c in s:
397399
if c == '\n':
398400
continue

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.