Font issue while trying to save PS/EPS/SVG but not PDF #2067

Closed
klonuo opened this Issue May 26, 2013 · 3 comments

Comments

Projects
None yet
3 participants
Contributor

klonuo commented May 26, 2013

If I try to save plot to PDF, MPL saves it fine, but if I try PS or EPS or SVG it fails.
So I wonder how can MPL output PDF but can't output PS/EPS, let aside SVG.

Here is full trace from IPython:

KeyError                                  Traceback (most recent call last)
<ipython-input-63-6bec7f50eb05> in <module>()
----> 1 savefig('test.eps')

C:\Python27\lib\site-packages\matplotlib\pyplot.pyc in savefig(*args, **kwargs)
    470 def savefig(*args, **kwargs):
    471     fig = gcf()
--> 472     return fig.savefig(*args, **kwargs)
    473 
    474 @docstring.copy_dedent(Figure.ginput)

C:\Python27\lib\site-packages\matplotlib\figure.pyc in savefig(self, *args, **kwargs)
   1368             kwargs.setdefault('edgecolor', rcParams['savefig.edgecolor'])
   1369 
-> 1370         self.canvas.print_figure(*args, **kwargs)
   1371 
   1372         if transparent:

C:\Python27\lib\site-packages\matplotlib\backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2094                 orientation=orientation,
   2095                 bbox_inches_restore=_bbox_inches_restore,
-> 2096                 **kwargs)
   2097         finally:
   2098             if bbox_inches and restore_bbox:

C:\Python27\lib\site-packages\matplotlib\backend_bases.pyc in print_eps(self, *args, **kwargs)
   1841         from backends.backend_ps import FigureCanvasPS # lazy import
   1842         ps = self.switch_backends(FigureCanvasPS)
-> 1843         return ps.print_eps(*args, **kwargs)
   1844 
   1845     def print_pdf(self, *args, **kwargs):

C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in print_eps(self, outfile, *args, **kwargs)
    972 
    973     def print_eps(self, outfile, *args, **kwargs):
--> 974         return self._print_ps(outfile, 'eps', *args, **kwargs)
    975 
    976 

C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in _print_ps(self, outfile, format, *args, **kwargs)
   1005             self._print_figure(outfile, format, imagedpi, facecolor, edgecolor,
   1006                                orientation, isLandscape, papertype,
-> 1007                                **kwargs)
   1008 
   1009     def _print_figure(self, outfile, format, dpi=72, facecolor='w', edgecolor='w',

C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in _print_figure(self, outfile, format, dpi, facecolor, edgecolor, orientation, isLandscape, papertype, **kwargs)
   1098             bbox_inches_restore=_bbox_inches_restore)
   1099 
-> 1100         self.figure.draw(renderer)
   1101 
   1102         if dryrun: # return immediately if dryrun (tightbbox=True)

C:\Python27\lib\site-packages\matplotlib\artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     52     def draw_wrapper(artist, renderer, *args, **kwargs):
     53         before(artist, renderer)
---> 54         draw(artist, renderer, *args, **kwargs)
     55         after(artist, renderer)
     56 

C:\Python27\lib\site-packages\matplotlib\figure.pyc in draw(self, renderer)
   1004         dsu.sort(key=itemgetter(0))
   1005         for zorder, a, func, args in dsu:
-> 1006             func(*args)
   1007 
   1008         renderer.close_group('figure')

C:\Python27\lib\site-packages\matplotlib\artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     52     def draw_wrapper(artist, renderer, *args, **kwargs):
     53         before(artist, renderer)
---> 54         draw(artist, renderer, *args, **kwargs)
     55         after(artist, renderer)
     56 

C:\Python27\lib\site-packages\matplotlib\axes.pyc in draw(self, renderer, inframe)
   2084 
   2085         for zorder, a in dsu:
-> 2086             a.draw(renderer)
   2087 
   2088         renderer.close_group('axes')

C:\Python27\lib\site-packages\matplotlib\artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     52     def draw_wrapper(artist, renderer, *args, **kwargs):
     53         before(artist, renderer)
---> 54         draw(artist, renderer, *args, **kwargs)
     55         after(artist, renderer)
     56 

C:\Python27\lib\site-packages\matplotlib\axis.pyc in draw(self, renderer, *args, **kwargs)
   1053 
   1054         for tick in ticks_to_draw:
-> 1055             tick.draw(renderer)
   1056 
   1057         # scale up the axis label box to also find the neighbors, not

C:\Python27\lib\site-packages\matplotlib\artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     52     def draw_wrapper(artist, renderer, *args, **kwargs):
     53         before(artist, renderer)
---> 54         draw(artist, renderer, *args, **kwargs)
     55         after(artist, renderer)
     56 

C:\Python27\lib\site-packages\matplotlib\axis.pyc in draw(self, renderer)
    238 
    239         if self.label1On:
--> 240             self.label1.draw(renderer)
    241         if self.label2On:
    242             self.label2.draw(renderer)

C:\Python27\lib\site-packages\matplotlib\artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
     52     def draw_wrapper(artist, renderer, *args, **kwargs):
     53         before(artist, renderer)
---> 54         draw(artist, renderer, *args, **kwargs)
     55         after(artist, renderer)
     56 

C:\Python27\lib\site-packages\matplotlib\text.pyc in draw(self, renderer)
    594                     renderer.draw_text(gc, x, y, clean_line,
    595                                        self._fontproperties, angle,
--> 596                                        ismath=ismath)
    597 
    598         gc.restore()

C:\Python27\lib\site-packages\matplotlib\backends\backend_ps.pyc in draw_text(self, gc, x, y, s, prop, angle, ismath)
    749 
    750             self.set_color(*gc.get_rgb())
--> 751             self.set_font(font.get_sfnt()[(1,0,0,6)], prop.get_size_in_points())
    752 
    753             cmap = font.get_charmap()

KeyError: (1, 0, 0, 6)
Member

pelson commented May 28, 2013

Please see http://matplotlib.org/faq/troubleshooting_faq.html#getting-help for details on what information is needed.
Whilst this may very well be a bug with matplotlib, the best way to get support is through the matplotlib-users mailing list. If it turns out that this really is a bug, we can open an issue which is very specific to the bug in question. On that basis, I'll close this issue, but I do encourage you to ask on matplotlib-users.

Cheers,

pelson closed this May 28, 2013

Owner

mdboom commented May 28, 2013

Turns out you are on to a legitimate bug when using certain TrueType fonts. The solution is rather complex, so it's not going to be a quick fix. See #2071.

Contributor

klonuo commented May 29, 2013

Yep, already saw it
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment