Bug exporting mathtext to eps file in 0.91.2 on windows

I have confirmed that it is a bug in (at least the windows version) of mpl 0.91.2.
When saving eps files, and using mathtext, the cm fonts don’t get saved, and the
greek symbols (and others I presume) don’t show up in the eps file.

This works in mpl 0.90.1, where the eps file does store the fonts.
%%BeginFont: Cmmi10

When running the same problem with 0.91.2, the fonts are not stored.
Either using ps.fonttype 3 or 42.

Anybody who can fix this?

Thanks, Mark

···

On Wed, Mar 19, 2008 at 11:21 AM, Bernhard Voigt <Bernhard.Voigt@…1713…> wrote:

Hi Mark!

The problem seems to be that the computer modern font (cm) is not

included in the eps file. The snipped of the eps file I sent before

defines the font cmmi10:

%!PS-Adobe-3.0 Resource-Font

%%Title: cmmi10

%%Copyright: Copyright (C) 1994, Basil K. Malyshev. All Rights

Reserved.012BaKoMa Fonts Colle

ction, Level-B.

%%Creator: Converted from TrueType by PPR

/FontName /Cmmi10 def

And later, when the \chi glyph should be drawn, the font is changed to:

/Cmmi10 findfont

16.0 scalefont

setfont

0.000000 4.921875 moveto

/chi glyphshow

Which is the same in your file, but your file only contains the

Bitstreem Vera Sans font for the axis ticks. Cmmi10 is missing :frowning:

Your pdf, however, does contain the cmmi10 font, you can check via

file->properties->fonts.

You should have the following in your matplotlibrc file (well, you

said you have it, but let me repeat):

mathtext.fontset : cm

mathtext.fallback_to_cm : True

ps.useafm : False

ps.fonttype : 3

Check the settings using the interpreter prompt:

In [10]: p.rcParams[‘mathtext.fontset’]

Out[10]: ‘cm’

etc…

Well, if they are all correctly set, it’s probably a bug in the ps

backend not including the mathtext font.

A workaround would be to convert the pdf file to ps (either use

command line options of acroread or print to file), edit the ps file

to be a eps by changing the header to %!PS-Adobe-2.0 EPSF-2.0 and make

sure the bounding box is specified (see

http://www.postscript.org/FAQs/language/node82.html for details)

Bernhard

On Wed, Mar 19, 2008 at 10:22 AM, Mark Bakker <markbak@…287…> wrote:

Hello Mike -

Thanks for taking a look at this.

Easy example:

from pylab import *

plot([1,2,3])

text(1,1.5,r’\chi')

savefig(‘d:/temp/test.eps’)

There shoud now be a line and the symbol chi.

Works great in the pdf file, not in the eps file.

Both are attached.

Strangely enough at the end of the eps file there are statements:

0.000000 3.703125 moveto

/chi glyphshow

Which looks to me like writing chi.

I have now tried this on 4 windows machines, with different installations of gsview, but it doesn’t work on any.

It works fine under mpl vs. 0.90.1. That has the same statement for chi, but defines chi internally inside the eps file (which is much bigger).

Thanks, Mark

On Tue, Mar 18, 2008 at 7:09 PM, mdroe <mdroe@…86…> wrote:

It looks like it may be Windows-specific. I can create .eps files with

math on mpl-0.91.2, Python 2.5, gs-7.07 on Linux without problems.

Someone with a Windows installation may need to look at this.

Just so I can have a deeper look – can you please attach

a) the Python source of a minimal plot that causes this problem

b) your .eps file output (so I can compare it against mine).

Mike

Unfortunately, I'm still unable to reproduce the problem myself. Have you tried installing the CM fonts (copying them to C:\Windows\Fonts)? Maybe GS is trying to re-embed them and can't find them.

Cheers,
Mike

Mark Bakker wrote:

···

I have confirmed that it is a bug in (at least the windows version) of mpl 0.91.2.
When saving eps files, and using mathtext, the cm fonts don't get saved, and the
greek symbols (and others I presume) don't show up in the eps file.

This works in mpl 0.90.1, where the eps file does store the fonts.
%%BeginFont: Cmmi10

When running the same problem with 0.91.2, the fonts are not stored.
Either using ps.fonttype 3 or 42.

Anybody who can fix this?

Thanks, Mark

On Wed, Mar 19, 2008 at 11:21 AM, Bernhard Voigt > <Bernhard.Voigt@...1713... <mailto:Bernhard.Voigt@…1713…>> wrote:

    Hi Mark!

    The problem seems to be that the computer modern font (cm) is not
    included in the eps file. The snipped of the eps file I sent before
    defines the font cmmi10:

    %!PS-Adobe-3.0 Resource-Font
    %%Title: cmmi10
    %%Copyright: Copyright (C) 1994, Basil K. Malyshev. All Rights
    Reserved.012BaKoMa Fonts Colle
    ction, Level-B.
    %%Creator: Converted from TrueType by PPR
    .....
    /FontName /Cmmi10 def

    And later, when the \chi glyph should be drawn, the font is
    changed to:
    /Cmmi10 findfont
    16.0 scalefont
    setfont
    0.000000 4.921875 moveto
    /chi glyphshow

    Which is the same in your file, but your file only contains the
    Bitstreem Vera Sans font for the axis ticks. Cmmi10 is missing :frowning:

    Your pdf, however, does contain the cmmi10 font, you can check via
    file->properties->fonts.

    You should have the following in your matplotlibrc file (well, you
    said you have it, but let me repeat):
    mathtext.fontset : cm
    mathtext.fallback_to_cm : True
    ps.useafm : False
    ps.fonttype : 3

    Check the settings using the interpreter prompt:

    In [10]: p.rcParams['mathtext.fontset']
    Out[10]: 'cm'
    etc...

    Well, if they are all correctly set, it's probably a bug in the ps
    backend not including the mathtext font.

    A workaround would be to convert the pdf file to ps (either use
    command line options of acroread or print to file), edit the ps file
    to be a eps by changing the header to %!PS-Adobe-2.0 EPSF-2.0 and make
    sure the bounding box is specified (see
    http://www.postscript.org/FAQs/language/node82.html for details)

    Bernhard

    On Wed, Mar 19, 2008 at 10:22 AM, Mark Bakker <markbak@...287... > <mailto:markbak@…287…>> wrote:
    > Hello Mike -
    >
    > Thanks for taking a look at this.
    > Easy example:
    >
    > from pylab import *
    > plot([1,2,3])
    > text(1,1.5,r'\\chi')
    > savefig('d:/temp/test.eps')
    >
    > There shoud now be a line and the symbol chi.
    > Works great in the pdf file, not in the eps file.
    > Both are attached.
    >
    > Strangely enough at the end of the eps file there are statements:
    >
    > 0.000000 3.703125 moveto
    > /chi glyphshow
    >
    > Which looks to me like writing chi.
    > I have now tried this on 4 windows machines, with different
    installations of gsview, but it doesn't work on any.
    >
    > It works fine under mpl vs. 0.90.1. That has the same statement
    for chi, but defines chi internally inside the eps file (which is
    much bigger).
    >
    > Thanks, Mark
    >
    > On Tue, Mar 18, 2008 at 7:09 PM, mdroe <mdroe@...86... > <mailto:mdroe@…86…>> wrote:
    >
    > > It looks like it may be Windows-specific. I can create .eps
    files with
    > > math on mpl-0.91.2, Python 2.5, gs-7.07 on Linux without problems.
    > > Someone with a Windows installation may need to look at this.
    > >
    > > Just so I can have a deeper look -- can you please attach
    > >
    > > a) the Python source of a minimal plot that causes this problem
    > > b) your .eps file output (so I can compare it against mine).
    > >
    > > Mike
    > >
    >

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

My guess is that you are picking up an rc file where useafm is set to
True. Michael suggested checking this rc setting but I did not see
any response on this on list. Have you checked it? In the script
that is causing you trouble, print out the value

import matplotlib

print 'afm setting', matplotlib.rcParams['ps.useafm']

If this is True, then you need to find your matplotlibrc file and set
it to False.

I can't imagine a windows vs other platform issue that could cause
this since we do not use only matplotlib tools in our font conversion
pipeline

JDH

···

On Wed, Mar 19, 2008 at 7:43 AM, Mark Bakker <markbak@...287...> wrote:

I have confirmed that it is a bug in (at least the windows version) of mpl
0.91.2.
When saving eps files, and using mathtext, the cm fonts don't get saved, and
the
greek symbols (and others I presume) don't show up in the eps file.

This works in mpl 0.90.1, where the eps file does store the fonts.
%%BeginFont: Cmmi10

When running the same problem with 0.91.2, the fonts are not stored.
Either using ps.fonttype 3 or 42.

Anybody who can fix this?

Sorry, John, but here is my output, and it still doesn’t work.

from pylab import *
rcParams[‘mathtext.fontset’]
‘cm’
rcParams[‘mathtext.fallback_to_cm’]
True
rcParams[‘ps.useafm’]
False
rcParams[‘ps.fonttype’]
3
plot([1,2,3])
[<matplotlib.lines.Line2D instance at 0x029F0120>]
text(1,1.5,r’\chi')
<matplotlib.text.Text instance at 0x029F6968>
savefig(‘c:/temp/test.eps’)

On the same machine, I get the correct eps file with 0.90.1.
So it really isn’t my installation of GsView.

In the eps file created with 0.91.2, the cm fonts are not included, which I think is causing the problem.

What happens when you guys read the attached eps file (created with commands above)?
Do you see the chi symbol on the screen?

Thanks for looking into this,

Mark

test.eps (8.1 KB)

···

On Wed, Mar 19, 2008 at 2:18 PM, John Hunter <jdh2358@…287…> wrote:

On Wed, Mar 19, 2008 at 7:43 AM, Mark Bakker <markbak@…287…> wrote:

I have confirmed that it is a bug in (at least the windows version) of mpl

0.91.2.

When saving eps files, and using mathtext, the cm fonts don’t get saved, and

the

greek symbols (and others I presume) don’t show up in the eps file.

This works in mpl 0.90.1, where the eps file does store the fonts.

%%BeginFont: Cmmi10

When running the same problem with 0.91.2, the fonts are not stored.

Either using ps.fonttype 3 or 42.

Anybody who can fix this?

My guess is that you are picking up an rc file where useafm is set to

True. Michael suggested checking this rc setting but I did not see

any response on this on list. Have you checked it? In the script

that is causing you trouble, print out the value

import matplotlib

print ‘afm setting’, matplotlib.rcParams[‘ps.useafm’]

If this is True, then you need to find your matplotlibrc file and set

it to False.

I can’t imagine a windows vs other platform issue that could cause

this since we do not use only matplotlib tools in our font conversion

pipeline

JDH

I don't see the character in the plot you sent. So at least that's consistent. :wink:

However, I still can't get things to break locally (on Linux, at least), with all permutations of ps.fonttype, ps.useafm, ps.distiller, and mathtext.fontset.

Can you send your entire matplotlibrc file? Perhaps there is some other obscure setting that's interacting in a negative way.

Mike

Mark Bakker wrote:

···

Sorry, John, but here is my output, and it still doesn't work.

>>> from pylab import *
>>> rcParams['mathtext.fontset']
'cm'
>>> rcParams['mathtext.fallback_to_cm']
True
>>> rcParams['ps.useafm']
False
>>> rcParams['ps.fonttype']
3
>>> plot([1,2,3])
[<matplotlib.lines.Line2D instance at 0x029F0120>]
>>> text(1,1.5,r'\\chi')
<matplotlib.text.Text instance at 0x029F6968>
>>> savefig('c:/temp/test.eps')

On the same machine, I get the correct eps file with 0.90.1.
So it really isn't my installation of GsView.

In the eps file created with 0.91.2, the cm fonts are not included, which I think is causing the problem.

What happens when you guys read the attached eps file (created with commands above)?
Do you see the chi symbol on the screen?

Thanks for looking into this,

Mark

On Wed, Mar 19, 2008 at 2:18 PM, John Hunter <jdh2358@...287... > <mailto:jdh2358@…287…>> wrote:

    On Wed, Mar 19, 2008 at 7:43 AM, Mark Bakker <markbak@...287... > <mailto:markbak@…287…>> wrote:
    > I have confirmed that it is a bug in (at least the windows
    version) of mpl
    > 0.91.2.
    > When saving eps files, and using mathtext, the cm fonts don't
    get saved, and
    > the
    > greek symbols (and others I presume) don't show up in the eps file.
    >
    > This works in mpl 0.90.1, where the eps file does store the fonts.
    > %%BeginFont: Cmmi10
    >
    > When running the same problem with 0.91.2, the fonts are not stored.
    > Either using ps.fonttype 3 or 42.
    >
    > Anybody who can fix this?

    My guess is that you are picking up an rc file where useafm is set to
    True. Michael suggested checking this rc setting but I did not see
    any response on this on list. Have you checked it? In the script
    that is causing you trouble, print out the value

    import matplotlib

    print 'afm setting', matplotlib.rcParams['ps.useafm']

    If this is True, then you need to find your matplotlibrc file and set
    it to False.

    I can't imagine a windows vs other platform issue that could cause
    this since we do not use only matplotlib tools in our font conversion
    pipeline

    JDH

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA