Skip to content
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

Unicode issue in EPS output when using custom font #2523

Merged
merged 1 commit into from Oct 18, 2013

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Oct 16, 2013

If I do:

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

plt.rcParams['font.family'] = 'Georgia'

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.scatter([1,2,3],[1,2,3])
fig.savefig('test.eps')

I get:

Traceback (most recent call last):
  File "test_helvetica.py", line 10, in <module>
    fig.savefig('test.eps')
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.8-x86_64.egg/matplotlib/figure.py", line 1439, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.8-x86_64.egg/matplotlib/backend_bases.py", line 2228, in print_figure
    **kwargs)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.8-x86_64.egg/matplotlib/backend_bases.py", line 1953, in print_eps
    return ps.print_eps(*args, **kwargs)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.8-x86_64.egg/matplotlib/backends/backend_ps.py", line 982, in print_eps
    return self._print_ps(outfile, 'eps', *args, **kwargs)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.8-x86_64.egg/matplotlib/backends/backend_ps.py", line 1010, in _print_ps
    **kwargs)
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.8-x86_64.egg/matplotlib/backends/backend_ps.py", line 1208, in _print_figure
    print_figure_impl()
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/matplotlib-1.4.x-py2.7-macosx-10.8-x86_64.egg/matplotlib/backends/backend_ps.py", line 1159, in print_figure_impl
    fh, fonttype, glyph_ids)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa9 in position 13: invalid start byte

This is using the latest developer version of Matplotlib (a3d2992 at the time of writing). I can save it to PDF and convert to PS with pdf2ps but it would be nice to be able to save to EPS directly.

@mdboom
Copy link
Member

mdboom commented Oct 16, 2013

I can't reproduce this. Are you using the Georgia that comes with MS Windows 7 or later (as opposed to the one from earlier versions of Windows)? This is probably related to Microsoft removing the Macintosh extensions on the recent versions of their fonts. There are possibly workarounds, but I'll need the font file to reproduce.

@astrofrog
Copy link
Contributor Author

I'll email you the font.

@mdboom
Copy link
Member

mdboom commented Oct 16, 2013

Let's see what Travis thinks of this.

@pelson
Copy link
Member

pelson commented Oct 18, 2013

👍 for merge, though I've not tested they fix the original problem.

mdboom added a commit that referenced this pull request Oct 18, 2013
Unicode issue in EPS output when using custom font
@mdboom mdboom merged commit f9c62d2 into matplotlib:master Oct 18, 2013
@mdboom mdboom deleted the ps-unicode-error branch August 7, 2014 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants