Discussion:
[Matplotlib-users] TrueType font is missing table
Neal Becker
2015-07-06 12:26:02 UTC
Permalink
Using mpl 1.4.3 on Fedora 22, I'm trying to use stix font (so I can render
the unicode lambda label on the x-axis). I have every fedora package
related to 'stix', I think. It displays ok in qtagg4, but if I try to save
to pdf if fails with

RuntimeError Traceback (most recent call last)
<ipython-input-2-7dee58c07264> in <module>()
----> 1 exec(open(r'/usr/tmp/python-8710q1Y.py').read()) # PYTHON-MODE

<string> in <module>()

/usr/lib64/python3.4/site-packages/matplotlib/pyplot.py in savefig(*args,
**kwargs)
575 def savefig(*args, **kwargs):
576 fig = gcf()
--> 577 res = fig.savefig(*args, **kwargs)
578 draw() # need this if 'transparent=True' to reset colors
579 return res

/usr/lib64/python3.4/site-packages/matplotlib/figure.py in savefig(self,
*args, **kwargs)
1474 self.set_frameon(frameon)
1475
-> 1476 self.canvas.print_figure(*args, **kwargs)
1477
1478 if frameon:

/usr/lib64/python3.4/site-packages/matplotlib/backend_bases.py in
print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format,
**kwargs)
2209 orientation=orientation,
2210 bbox_inches_restore=_bbox_inches_restore,
-> 2211 **kwargs)
2212 finally:
2213 if bbox_inches and restore_bbox:

/usr/lib64/python3.4/site-packages/matplotlib/backends/backend_pdf.py in
print_pdf(self, filename, **kwargs)
2489 file.endStream()
2490 else: # we opened the file above; now finish
it off
-> 2491 file.close()
2492
2493

/usr/lib64/python3.4/site-packages/matplotlib/backends/backend_pdf.py in
close(self)
523 self.endStream()
524 # Write out the various deferred objects
--> 525 self.writeFonts()
526 self.writeObject(self.alphaStateObject,
527 dict([(val[0], val[1])

/usr/lib64/python3.4/site-packages/matplotlib/backends/backend_pdf.py in
writeFonts(self)
626 chars = self.used_characters.get(stat_key)
627 if chars is not None and len(chars[1]):
--> 628 fonts[Fx] = self.embedTTF(realpath, chars[1])
629 self.writeObject(self.fontObject, fonts)
630

/usr/lib64/python3.4/site-packages/matplotlib/backends/backend_pdf.py in
embedTTF(self, filename, characters)
1101
1102 if fonttype == 3:
-> 1103 return embedTTFType3(font, characters, descriptor)
1104 elif fonttype == 42:
1105 return embedTTFType42(font, characters, descriptor)

/usr/lib64/python3.4/site-packages/matplotlib/backends/backend_pdf.py in
embedTTFType3(font, characters, descriptor)
887 # actual outlines)
888 rawcharprocs = ttconv.get_pdf_charprocs(
--> 889 filename.encode(sys.getfilesystemencoding()),
glyph_ids)
890 charprocs = {}
891 for charname, stream in six.iteritems(rawcharprocs):

RuntimeError: TrueType font is missing table
Neal Becker
2015-07-06 12:41:57 UTC
Permalink
Post by Neal Becker
Using mpl 1.4.3 on Fedora 22, I'm trying to use stix font (so I can render
the unicode lambda label on the x-axis). I have every fedora package
related to 'stix', I think. It displays ok in qtagg4, but if I try to save
to pdf if fails with
RuntimeError Traceback (most recent call
last) <ipython-input-2-7dee58c07264> in <module>()
----> 1 exec(open(r'/usr/tmp/python-8710q1Y.py').read()) # PYTHON-MODE
<string> in <module>()
/usr/lib64/python3.4/site-packages/matplotlib/pyplot.py in savefig(*args,
**kwargs)
576 fig = gcf()
--> 577 res = fig.savefig(*args, **kwargs)
578 draw() # need this if 'transparent=True' to reset colors
579 return res
/usr/lib64/python3.4/site-packages/matplotlib/figure.py in savefig(self,
*args, **kwargs)
1474 self.set_frameon(frameon)
1475
-> 1476 self.canvas.print_figure(*args, **kwargs)
1477
/usr/lib64/python3.4/site-packages/matplotlib/backend_bases.py in
print_figure(self, filename, dpi, facecolor, edgecolor, orientation,
format, **kwargs)
2209 orientation=orientation,
2210 bbox_inches_restore=_bbox_inches_restore,
-> 2211 **kwargs)
/usr/lib64/python3.4/site-packages/matplotlib/backends/backend_pdf.py in
print_pdf(self, filename, **kwargs)
2489 file.endStream()
2490 else: # we opened the file above; now finish
it off
-> 2491 file.close()
2492
2493
/usr/lib64/python3.4/site-packages/matplotlib/backends/backend_pdf.py in
close(self)
523 self.endStream()
524 # Write out the various deferred objects
--> 525 self.writeFonts()
526 self.writeObject(self.alphaStateObject,
527 dict([(val[0], val[1])
/usr/lib64/python3.4/site-packages/matplotlib/backends/backend_pdf.py in
writeFonts(self)
626 chars = self.used_characters.get(stat_key)
--> 628 fonts[Fx] = self.embedTTF(realpath, chars[1])
629 self.writeObject(self.fontObject, fonts)
630
/usr/lib64/python3.4/site-packages/matplotlib/backends/backend_pdf.py in
embedTTF(self, filename, characters)
1101
-> 1103 return embedTTFType3(font, characters, descriptor)
1105 return embedTTFType42(font, characters, descriptor)
/usr/lib64/python3.4/site-packages/matplotlib/backends/backend_pdf.py in
embedTTFType3(font, characters, descriptor)
887 # actual outlines)
888 rawcharprocs = ttconv.get_pdf_charprocs(
--> 889 filename.encode(sys.getfilesystemencoding()),
glyph_ids)
890 charprocs = {}
RuntimeError: TrueType font is missing table
forgot to attach the code.


#!/usr/bin/python
# -*- coding: utf-8 -*-
data='''carriers,lambda,per
1,7,1.3e-4
1,8,3.0e-4
1,9,.0014
8,7,4.8e-4
8,8,1.3e-3
8,9,.0075
'''

import pandas as pd
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
df = pd.read_csv (StringIO (data))
g = df.groupby ('carriers')
import matplotlib.pyplot as plt

import matplotlib as mpl
#mpl.rcParams['font.family'] = 'stix'
mpl.rc('font', family='DejaVu Sans')
#mpl.rc('font', family='stix')

import itertools
markers = itertools.cycle(['o','s','v'])

fig = plt.figure()
ax = fig.add_subplot(111)
for c, stuff in g:
plt.semilogy (stuff['lambda'].values, stuff['per'].values,
label='carriers=%s'%c, marker=next(markers))

plt.legend (loc='best')
ax.set_xlabel (' ')
ax.set_ylabel ('per')
plt.grid(which='major', linestyle='solid')
plt.grid(which='minor', linestyle='dashed')
plt.savefig ('per_vs_lambda.pdf')

Continue reading on narkive:
Loading...