8000 FIX: fix bad string handling in type1font by tacaswell · Pull Request #4472 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: fix bad string handling in type1font #4472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
FIX: fix bad string handling in type1font
Do not try to encode a bytestring in python 3.

closes #4470
  • Loading branch information
tacaswell committed May 25, 2015
commit 8a3731d90bd1f4f1ab6fa24f20e4c5f11cf71cc3
Binary file not shown.
10 changes: 10 additions & 0 deletions lib/matplotlib/tests/test_backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,13 @@ def test_multipage_keep_empty():
pdf.savefig()
assert os.path.exists(filename)
os.remove(filename)


@image_comparison(baseline_images=['test_type1font_encoding'],
extensions=['pdf'])
def test_type1font_encoding():
# This doesn't work
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to leave this comment here? It's baffling.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a typo from modifying the bug report example to be a test, should have been removed.

rcParams['font.serif'] = "Times, serif"
rcParams['text.usetex'] = "true"
fig, ax = plt.subplots()
ax.set_xlabel("$\gamma$")
3 changes: 2 additions & 1 deletion lib/matplotlib/type1font.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ def transform(self, effects):
extend=effects.get('extend', 1.0)):
if six.PY3 and isinstance(value, int):
value = chr(value)
value = value.encode('latin-1')
if isinstance(value, six.text_type):
value = value.encode('latin-1')
buffer.write(value)
result = buffer.getvalue()
finally:
Expand Down
0