-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Setting rcParams ps.fonttype = 42 yields unreadable eps #9044
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
Comments
I was able to view demo-type42.eps using ghostscript 9.21 and Inkscape 0.92 and the Affinity Designer and Affinity Photo apps under macOS 10.12.6. ghostscript's ps2pdf utility was able to convert the file to a pdf but Apple's pstopdf utility failed. |
Thanks @selasley, believing this is a font issue I just tried import matplotlib.font_manager
matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf') But that didn't seem to solve the problem |
Have you tried clearing your font cache?
…On Wed, Aug 16, 2017 at 1:28 PM, Paul J. Durack ***@***.***> wrote:
Thanks @selasley <https://github.com/selasley>, believing this is a font
issue I just tried
import matplotlib.font_manager
matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')
But that didn't seem to solve the problem
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9044 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-HhIxfjjVFqDgLzZ-lzbUNsPlS9Sks5sYybSgaJpZM4O5HxS>
.
|
@WeatherGod any tips as to how I would do that? |
You can reboot with the shift key held down to clear various caches and boot into safe mode -https://support.apple.com/en-us/HT201262 sudo atsutil databases -remove demo-type42 and demo-type3 look identical in Affinity Designer. It's possible that ghostscript, Inkscape and the Affinity apps are substituting a different font for DejaVu when they open demo-type42. That may be the reason they work and Preview and pstopdf don't. According to Font Book, Bitstream Vera Sans, Bitstream Vera Sans Mono, and Bitstream Vera Serif are installed on my mac, so I tried matplotlib.rcParams['font.monospace'] = ['Bitstream Vera Sans Mono'] before running your script. Now pstopdf fails because BitstreamVeraSans-Roman is missing %%[ Error: invalidfont; OffendingCommand: definefont; ErrorInfo: .notdef --nostringval-- ]%% Stack: %%[ Flushing: rest of job (to end-of-file) will be ignored ]%% I'm using python 3.6.2 and matplotlib 2.0.2 |
@selasley it seems to me like those matplotlib.rcParams['font.monospace'] = ['Courier']
matplotlib.rcParams['font.san-serif'] = ['Courier']
matplotlib.rcParams['font.serif'] = ['Courier'] But the output (
|
No... gosh no. I was referring to matplotlib's font cache. I don't know
where it is for macs, but for linux, it is in ~/.matplotlib.
…On Wed, Aug 16, 2017 at 2:30 PM, Scott Lasley ***@***.***> wrote:
You can reboot with the shift key held down to clear various caches and
boot into safe mode -https://support.apple.com/en-us/HT201262
Or you can use the command line utility atsutil
sudo atsutil databases -remove
atsutil server –shutdown
atsutil server –ping
demo-type42 and demo-type3 look identical in Affinity Designer. It's
possible that ghostscript, Inkscape and the Affinity apps are substituting
a different font for DejaVu when they open demo-type42. That may be the
reason they work and Preview and pstopdf don't.
According to Font Book, Bitstream Vera Sans, Bitstream Vera Sans Mono, and
Bitstream Vera Serif are installed on my mac, so I tried
matplotlib.rcParams['font.monospace'] = ['Bitstream Vera Sans Mono']
matplotlib.rcParams['font.sans-serif'] = ['Bitstream Vera Sans']
matplotlib.rcParams['font.serif'] = ['Bitstream Vera Serif']
before running your script. Now pstopdf fails because
BitstreamVeraSans-Roman is missing
%%[ Error: invalidfont; OffendingCommand: definefont; ErrorInfo: .notdef
--nostringval-- ]%%
Stack:
/Font
-dict-
/BitstreamVeraSans-Roman
%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
%%[ Warning: PostScript error. No PDF file produced. ] %%
pstopdf failed on file demo-type42.eps with error code -31000
I'm using python 3.6.2 and matplotlib 2.0.2
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9044 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-O2a2TKDRFNt1QTQxbq6dCNiNm8Sks5sYzVEgaJpZM4O5HxS>
.
|
Also see |
The problem appears to be the definefont command in the eps files. I deleted the fontList cache files in my ~/.matplotlib directory and set the font.sans-serif rcParam to various fonts. In each case Preview was unable to open demo-type42.eps and the Apple utility pstopdf failed to convert it with the error %%[ Error: invalidfont; OffendingCommand: definefont; ErrorInfo: .notdef --nostringval-- ]%% The only place definefont appears in the eps files is in this line FontName currentdict end definefont pop Preview and pstopdf are able to open demo-type42.eps after changing the line to FontName currentdict end I don't know enough about postscript to know what ramifications removing "definefont pop" has, but it seems to work for Preview, MS Word, and a few other apps that failed to open the original eps file. |
@selasley Thanks for you work tracking this down! |
The attached files work fine for me with ghostscript and okular on linux :( |
It could be a macOS specific problem. pstopdf gives the same error under OS X 10.9 and 10.10. "unix-based" programs like ghoscscript, Inkscape and even TeXShop can open demo-type42.eps. "native" programs such as Preview, GraphicConverter, Microsoft Word, Intaglio and pstopdf have problems with it. Photoshop Elements 9 fails to open demo-type42 with the error message "Could not complete your request because the parser module cannot parse the file" Hopefully the OP can use one of the workarounds. |
After perusing a few sites it seems that % gs -sDevice=nullpage -dNOPAUSE -dBATCH /path/to/file/demo-type42.eps
GPL Ghostscript 9.19 (2016-03-23)
Copyright (C) 2016 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
%%BoundingBox: 89 251 522 541
%%HiResBoundingBox: 89.999997 251.999992 521.999984 540.017984 So it seems at least This discussion is also useful background |
Ok and after removing the offending % gs -sDevice=nullpage -dNOPAUSE -dBATCH /path/to/file/demo-type42-noDefinefont.eps
GPL Ghostscript 9.19 (2016-03-23)
Copyright (C) 2016 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Querying operating system for font files...
Can't find (or can't open) font file %rom%Resource/Font/DejaVuSans.
Can't find (or can't open) font file DejaVuSans.
Didn't find this font on the system!
Substituting font Courier for DejaVuSans.
Loading NimbusMono-Regular font from %rom%Resource/Font/NimbusMono-Regular... 4128764 2787962 4963028 2541805 2 done.
%%BoundingBox: 89 251 522 541
%%HiResBoundingBox: 89.999997 251.999992 521.999984 540.017984 So it seems on MacOS, |
Can you check if this works with earlier version of Matplotlib? |
@tacaswell is there a particular version that you'd recommend targeting? Your #9044 (comment) would suggest that it's been around since the dawn of matplotlib time |
At least against 1.5 and maybe 1.4 (if it is easy to install). |
After some more digging it looks like the error message from pstopdf "ErrorInfo: .notdef --nostringval--" means that there is no definition of .notdef in the eps file. Removing definefont pop from demo-tye42.eps masks the problem because the embedded DejaVu is no longer defined so it is not used. If I change this CharStrings block in demo-type42.eps located after the long block of /sfnts hex values from /CharStrings 7 dict dup begin to /CharStrings 8 dict dup begin Preview is able to open the modified demo-type42.eps file and does not complain about a missing DejaVu font. pstopdf converts the file without errors or messages about missing fonts. I'm not sure how to add a definition of .notdef to the CharStrings block. It looks like the block is written by the ttfont_CharStrings routine in ppdrvr_tt.cpp where it loops through glyph_ids. The glyph_ids come from ps_renderer.used_characters in backend_ps.py That's about as far as I can trace it. The BlueBook says .notdef is defined to print nothing. I found the "/.notdef 0 def" line in eps files from Inkscape so I presume defining .notdef as 0 is OK. |
…in eps files. See issue matplotlib#9044
Is this now fixed by #9059? |
I'll assume so in the absence of further activity. Feel free to request a reopen if necessary. |
@anntzer I can confirm using the demo script as contained in #9044 (comment) I no longer have the eps read issue on macOS 10.14.6, using matplotlib 3.1.3. There are an astounding number of differences in the output files between 2.0.2 and 3.1.3, I have included output files from each version for comparison in the attached archive |
I was just reading some notes in #5862, and it seems I'm hitting similar errors on MacOS/OS X (10.11.6) - in this case it doesn't appear that carriage returns are the issue. If I follow the guidance, and attempt to convert output to truetype fonts:
My file size increases from 19Kb to 1.2Mb, but no software (MacOS Preview, or Adobe Photoshop 2017) can read the file. For those interested I have attached both
*.eps
output files in the zip archive.matplotlib2-postscriptFontIssue.zip
The truetype file contains the following, and
DejaVu Sans
doesn't appear to be installed (checking the MacOS Font Book application):A demo script to reproduce the problem is below:
System config:
The text was updated successfully, but these errors were encountered: