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

Unable to use font "CMU Serif" #3206

Closed
benblamey opened this issue Jul 10, 2014 · 4 comments
Closed

Unable to use font "CMU Serif" #3206

benblamey opened this issue Jul 10, 2014 · 4 comments
Assignees
Labels
status: needs clarification Issues that need more information to resolve. status: needs confirmation
Milestone

Comments

@benblamey
Copy link

I am using matplotlib to create a figure as a PDF.
I get an error "TrueType font file contains a very long PostScript name" when attempting to use the font "CMU Serif" (this is the default LaTeX font)

I set up font like this:

import matplotlib
matplotlib.rcParams['font.family'] = 'serif'
matplotlib.rcParams['font.serif'] = 'CMU Serif, Times New Roman'

% Export my figure like this (it works fine with other fonts)

savefig("my_figure.pdf", dpi=600, figsize=(8, 6))

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_pdf(self, *args, **kwargs)
   1846         from backends.backend_pdf import FigureCanvasPdf # lazy import
   1847         pdf = self.switch_backends(FigureCanvasPdf)
-> 1848         return pdf.print_pdf(*args, **kwargs)
   1849 
   1850     def print_pgf(self, *args, **kwargs):

C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.pyc in print_pdf(self, filename, **kwargs)
   2305                 file.endStream()
   2306             else:            # we opened the file above; now finish it off
-> 2307                 file.close()
   2308 
   2309 class FigureManagerPdf(FigureManagerBase):

C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.pyc in close(self)
    505         self.endStream()
    506         # Write out the various deferred objects
--> 507         self.writeFonts()
    508         self.writeObject(self.alphaStateObject,
    509                          dict([(val[0], val[1])

C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.pyc in writeFonts(self)
    605                 chars = self.used_characters.get(stat_key)
    606                 if chars is not None and len(chars[1]):
--> 607                     fonts[Fx] = self.embedTTF(realpath, chars[1])
    608         self.writeObject(self.fontObject, fonts)
    609 

C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.pyc in embedTTF(self, filename, characters)
   1050 
   1051         if fonttype == 3:
-> 1052             return embedTTFType3(font, characters, descriptor)
   1053         elif fonttype == 42:
   1054             return embedTTFType42(font, characters, descriptor)

C:\Python27\lib\site-packages\matplotlib\backends\backend_pdf.pyc in embedTTFType3(font, characters, descriptor)
    842             # Make the charprocs array (using ttconv to generate the
    843             # actual outlines)
--> 844             rawcharprocs = ttconv.get_pdf_charprocs(filename, glyph_ids)
    845             charprocs = {}
    846             charprocsRef = {}

RuntimeError: TrueType font file contains a very long PostScript name

[edited by TAC to add mark up, adding tripple '`' around text makes it fontify]

@benblamey
Copy link
Author

Github blocks the upload of the font - but the files are available here:
http://sourceforge.net/projects/cm-unicode/

I used the font in the file: cmunrm.ttf

Might be an easy fix of making the buffer "temp" a bit longer (its currently set to 80 characters - seems to be used for the whole bag of strings for font - and hence too short)

@tacaswell
Copy link
Member

@jkseppan @mdboom Thoughts?

@tacaswell tacaswell added this to the v1.4.x milestone Jul 12, 2014
@jkseppan
Copy link
Member

Couldn't reproduce. A complete self-contained example would help. I tried using a FontProperties instance with fname='cmunrm.ttf' and got a pdf file with CMUSerif-Roman as the font.

@tacaswell tacaswell added status: needs clarification Issues that need more information to resolve. status: needs confirmation labels Nov 26, 2014
@tacaswell
Copy link
Member

Closing as we could not reproduce. If you have a SCCE, ping me to have this re-opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs clarification Issues that need more information to resolve. status: needs confirmation
Projects
None yet
Development

No branches or pull requests

4 participants