FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Error with greek letters in pdf export when using usetex=True and mathptmx · Issue #16087 · matplotlib/matplotlib · GitHub

Repository navigation

Error with greek letters in pdf export when using usetex=True and mathptmx #16087

Closed

Description

When I export a pdf with savefig I have errors in the greek letters, but only in the pdf the png export is fine. I use the option "usetex=True" and the package "mathptmx".

import matplotlib.pyplot as plt
from matplotlib import rc
import matplotlib

rc('text', usetex=True)
rc('text.latex',preamble= [
                           r"\usepackage{mathptmx}",
                           ])

x = range(10)

plt.figure()
plt.plot(x, label = r'$\varphi$')
plt.legend()
plt.xlabel('abcdefgh')

name = matplotlib.__version__
plt.savefig('mpl_'+name+'.pdf')
plt.savefig('mpl_'+name+'.png')

plt.show()

With the provided code you will get a png and a pdf file. In the pdf file the \varphi symbol in the legend is only a long line. With version 2.2.4 and 1.5.3 this happens. With Version 1.4.3 the pdf and the png is fine.

Matplotlib version

  • Operating system: MacOS 10.12.6
  • Matplotlib version: 2.2.4, 1.5.3 and 1.4.3 tested
  • Matplotlib backend: MacOSX
  • Python version: 2.7.17

All instalations done via macports.

Attached the output files:

Version 1.4.3
mpl_1.4.3.pdf

Version 1.5.3
mpl_1.5.3.pdf

Version 2.2.4
mpl_2.2.4.pdf

Screenshot of error in pdf

Activity

  1. tacaswell commented on Jan 4, 2020

    Member

    Can you try with different pdf viewers? If I download your pdfs and look at them in chrome or okular (or docview in emacs) the look correct.

    If I squint, I could believe that the line is a very distorted version of phi.

    I took a quick look at the API and release notes for 1.5.0 and nothing jumped out at me as being related.

  2. markushartmann commented on Jan 4, 2020

    Author

    With Adobe reader another error is displayed. The reader message is that the font "StandardSymL_Slant_167" could not be extracted (attached Screenshot).

    For me it sounds simmilar to issue #11259

  3. markushartmann commented on Jan 10, 2020

    Author

    Any ideas how to debug this problem a little bit more?

    #9139 seams to be very similar

  4. anntzer commented on Mar 24, 2020

    Contributor

    attn @arm2arm from #16894 as well.

    If anyone has access to Acrobat Pro, can you try running preflight (https://helpx.adobe.com/acrobat/using/analyzing-documents-preflight-tool-acrobat.html) on one of the "bad" pdf docs and see what comes out?

  5. arm2arm commented on Mar 25, 2020

  6. anntzer commented on Mar 25, 2020

    Contributor

    So Adobe is just complaining about some bad glyph widths. This can be fixed manually, as I've done in the attached file here: test.1.pdf

    But locally Acrobat DC still fails to open the new file. Is that also the case for you?

    I'm also confused that apparently preflight does extract the glyphs just fine, but for some reason the pdf viewer refuses to display them.

  7. arm2arm commented on Mar 27, 2020

    So same failure, but the MS Edge can preview that as before.

  8. anntzer commented on Mar 27, 2020

    Contributor

    Well, that's annoying because we can't even know why Acrobat complains about that file (as you mention, edge is happy with it; on linux, poppler and mupdf-based readers are fine too, as is chromium). Any chance you could contact Adobe to ask them what's wrong with the file, or whether it's something on their side?

  9. jkseppan commented on Jul 27, 2020

    Member

    This was a weird one! I compared to the output of pdftex, and the only major differences in the embedded font I saw were:

    /ItalicAngle -9.48090361795083 def
    /FontMatrix [0.001 0.0 0.00016700000000000002 0.001 0.0 0.0] readonly def
    

    vs. pdftex's

    /ItalicAngle -9.4809 def
    /FontMatrix [0.001 0 0.000167 0.001 0 0 ] readonly def
    

    Because Type 1 is a subset of PostScript and PostScript interpreters typically only support single-precision floating point, I suspect that their parsers return some bogus value for 0.00016700000000000002. Reducing the precision on these numbers seems to help at least with Preview.app.

    I'm preparing a patch, but in the meanwhile people with other pdf readers could see if the attached file works better.

    issue16087.pdf

  10. added a commit that references this issue on Jul 27, 2020
    013d508
  11. added this to the v3.4.0 milestone on Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL