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

PDF Embedded fonts with python3 mpl reported as 'Unknown' by pdffonts and pdf readers #3049

Closed
jclevesque opened this issue May 7, 2014 · 8 comments · Fixed by #3203
Closed

Comments

@jclevesque
Copy link
Contributor

Say I want to save a PDF figure with a simple script :

import matplotlib.pyplot as plt
f = plt.figure()
ax = f.add_subplot(111)
ax.plot([1,2,3], [4,5,6])
ax.set_title('fonts')
f.savefig('test.pdf')

If I run this script with python2, then the output of pdffonts test.pdf is the following :

name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
NimbusSanL-Regu                      Type 1            yes no  no      17  0
CMMI12                               Type 1            yes no  no      13  0
CMR12                                Type 1            yes no  no      21  0

However, if I run the script with python3, then the output of pdffonts test.pdf becomes :

name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
Unknown                              Type 1            yes no  no      21  0
Unknown                              Type 1            yes no  no      17  0
Unknown                              Type 1            yes no  no      13  0

Both figures are visually identical. This is a problem for me because I'm trying to make sure my PDFs contain only the allowed font types for a conference paper submission.

This is with matplotlib 1.3 for both python 2.7.3 and python 3.2.3.

@audurand
Copy link

audurand commented May 7, 2014

This is also an issue for me.

@tacaswell tacaswell added the text label May 7, 2014
@pelson
Copy link
Member

pelson commented Jun 18, 2014

@jkseppan - any ideas on this?

@jkseppan
Copy link
Member

@jclevesque - can you make the offending pdf file available at some web address? I'd like to peek inside. My guess is that because of Python 3's unicode-vs-bytes differentiation the font name gets encoded in a different encoding than before (e.g. UCS-2 vs ASCII) but I don't have a Python 3 installation handy to test on.

@audurand
Copy link

I attached an example of offending pdf along with the Python3 script used
to produce it.

2014-06-18 7:20 GMT-04:00 Jouni K. Seppänen notifications@github.com:

@jclevesque https://github.com/jclevesque - can you make the offending
pdf file available at some web address? I'd like to peek inside. My guess
is that because of Python 3's unicode-vs-bytes differentiation the font
name gets encoded in a different encoding than before (e.g. UCS-2 vs ASCII)
but I don't have a Python 3 installation handy to test on.


Reply to this email directly or view it on GitHub
#3049 (comment)
.

@jkseppan
Copy link
Member

jkseppan commented Jul 9, 2014

@audurand - Sorry, I can't see the pdf file linked from this github issue. Could you either put it up on Dropbox or similar, or email it directly to me at jks@iki.fi?

@audurand
Copy link

audurand commented Jul 9, 2014

Here is an example of offending pdf along with the Python3 script used to
produce it. If you cannot see the files I will upload them on Dropbox,

2014-07-09 2:15 GMT-04:00 Jouni K. Seppänen notifications@github.com:

@audurand https://github.com/audurand - Sorry, I can't see the pdf file
linked from this github issue. Could you either put it up on Dropbox or
similar, or email it directly to me at jks@iki.fi?


Reply to this email directly or view it on GitHub
#3049 (comment)
.

@jenshnielsen
Copy link
Member

I can reproduce this issue. But only with usetex=True

@jkseppan
Copy link
Member

jkseppan commented Jul 9, 2014

Yes, it seems to be related to the AFM parsing in type1font.py.

jkseppan added a commit to jkseppan/matplotlib that referenced this issue Jul 9, 2014
Communicate token types as objects instead of strings from the
tokenizer to the parser. Use proper Unicode strings for string-like
data in the font properties. Fix the handling of delimiters.

Resolves matplotlib#3049.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants