font issues with eps and latex

I have been trying to deal with some font problems related to the new tex
capabilities in MPL. Let me summarize what MPL is doing, when text.usetex is
true in rc:

texmanager runs TeX (or LaTeX) on a string, and John has somehow extracted an
image of that string and its bbox information to intelligently layout and
render the text.

the ps backend will produce a transitional eps file with a bunch of psfrag
markers, along with an associated tex file. backend_ps runs latex on the tex
file, which embeds the eps, and replaces the markers with the actual text.
Now we have a ps file, which can be converted into an eps if desired with
ps2epsi, or maybe this could be changed to a call to ghostscript: gs
-dNOPAUSE -sDEVICE=epswrite -sOutputFile=tex_demo.eps tex_demo.ps. As far as
the user is concerned, you type savefig('foo.eps') and get foo.eps,
blissfully unaware of all the intermediate steps.

Here is my current problem. I embed an eps file generated with ps2epsi in a
new tex document. The dvi looks ok, but after dvips, the text in my figure
gets inverted and shifted. This seems to be a bigger problem when using latex
classes that do some font handling behind the scenes, for example, article
seems ok, but revtex4 and ha-prosper yield unacceptable results.

On the other hand, if I use ghostscript to generate the eps, I can embed the
files and the printed page looks fine, but the fonts look terrible on screen.
Here is a comment from the afpl website
http://www.cs.wisc.edu/~ghost/doc/AFPL/8.50/Issues.htm:

···

---
pswrite device generates low level PostScript.

pswrite and epswrite devices reduce everything to path, fill, stroke, clip
image, and imagemask operations. Although the resulting file prints OK it
produces unsatisfactory results when scaled, distilled or imported into
graphic editors. The file can easily exceed 4GB and hit file size limits in
some applications or operation systems. Handling of big files is slow.
---
The associated bug report (filed over 2 years ago) says this is a low priority
problem.

How can MPL deal with these non-MPL issues? I know John doesn't like the idea
of handling text in eps as images, but if we did, could that be a suitable
workaround? Does anyone have another suggestion?

Darren

Darren Dale <dd55@...143...> writes:
[snip]

the ps backend will produce a transitional eps file with a bunch of psfrag
markers, along with an associated tex file. backend_ps runs latex on the tex
file, which embeds the eps, and replaces the markers with the actual text.
Now we have a ps file, which can be converted into an eps if desired with
ps2epsi, or maybe this could be changed to a call to ghostscript: gs
-dNOPAUSE -sDEVICE=epswrite -sOutputFile=tex_demo.eps tex_demo.ps. As far as
the user is concerned, you type savefig('foo.eps') and get foo.eps,
blissfully unaware of all the intermediate steps.

http://www.tex.ac.uk/cgi-bin/texfaq2html?label=mpprologues

describes a similar situation, but they use dvips -E to generate the
eps file directly. Could you do that rather than using ghostscript?
Apart from anything else, it should be quicker.

Here is my current problem. I embed an eps file generated with ps2epsi in a
new tex document. The dvi looks ok, but after dvips, the text in my figure
gets inverted and shifted. This seems to be a bigger problem when using latex
classes that do some font handling behind the scenes, for example, article
seems ok, but revtex4 and ha-prosper yield unacceptable results.

As an alternative, could you use the .tex/.eps pair directly. This
would allow you to use the same font and text size in the figure
caption as in the main document.

On the other hand, if I use ghostscript to generate the eps, I can
embed the files and the printed page looks fine, but the fonts look
terrible on screen.

If you are using xdvi, then I found that too. I blamed it on
ghostscript being used to render the graphics with low resolution, or
not antialiasing the text.

Here is a comment from the afpl website
http://www.cs.wisc.edu/~ghost/doc/AFPL/8.50/Issues.htm:

---
pswrite device generates low level PostScript.

pswrite and epswrite devices reduce everything to path, fill, stroke, clip
image, and imagemask operations. Although the resulting file prints OK it
produces unsatisfactory results when scaled, distilled or imported into
graphic editors. The file can easily exceed 4GB and hit file size limits in
some applications or operation systems. Handling of big files is slow.
---
The associated bug report (filed over 2 years ago) says this is a low priority
problem.

How can MPL deal with these non-MPL issues? I know John doesn't like the idea
of handling text in eps as images, but if we did, could that be a suitable
workaround?

I agree with John here.

Does anyone have another suggestion?

Hope these suggestions might help.

Chris

PS One further thought I had is MetaPost.
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=MP Is it possible for
matplotlib to embed the tex expressions in the same way that metapost
does? This might not solve your problem however, as xdvi currently has
a problem displaying them - see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295205 for details.

PPS If you need something in a hurry (for your thesis?), can you
create the whole thing as a bitmap? or use the latex "ite" package to
position labels? If you do the latter, there is a patch I should send
you - otherwise it clashes with various packages.

Darren Dale <dd55@...143...> writes:
[snip]

> the ps backend will produce a transitional eps file with a bunch of
> psfrag markers, along with an associated tex file. backend_ps runs latex
> on the tex file, which embeds the eps, and replaces the markers with the
> actual text. Now we have a ps file, which can be converted into an eps if
> desired with ps2epsi, or maybe this could be changed to a call to
> ghostscript: gs -dNOPAUSE -sDEVICE=epswrite -sOutputFile=tex_demo.eps
> tex_demo.ps. As far as the user is concerned, you type savefig('foo.eps')
> and get foo.eps, blissfully unaware of all the intermediate steps.

http://www.tex.ac.uk/cgi-bin/texfaq2html?label=mpprologues

describes a similar situation, but they use dvips -E to generate the
eps file directly. Could you do that rather than using ghostscript?
Apart from anything else, it should be quicker.

I had tried this. -E does not seem to be very robust, I cant view the
resulting eps files, they appear to be corrupted.

> Here is my current problem. I embed an eps file generated with ps2epsi in
> a new tex document. The dvi looks ok, but after dvips, the text in my
> figure gets inverted and shifted. This seems to be a bigger problem when
> using latex classes that do some font handling behind the scenes, for
> example, article seems ok, but revtex4 and ha-prosper yield unacceptable
> results.

As an alternative, could you use the .tex/.eps pair directly. This
would allow you to use the same font and text size in the figure
caption as in the main document.

This is the way it was originally done. I think it is much better to have a
single nugget than to have a half complete figure. I think scientific
journals may have a problem with submitting these kinds of half complete
figures for publication.

> On the other hand, if I use ghostscript to generate the eps, I can
> embed the files and the printed page looks fine, but the fonts look
> terrible on screen.

If you are using xdvi, then I found that too. I blamed it on
ghostscript being used to render the graphics with low resolution, or
not antialiasing the text.

[...]

>
> How can MPL deal with these non-MPL issues? I know John doesn't like the
> idea of handling text in eps as images, but if we did, could that be a
> suitable workaround?

I agree with John here.

So do I. But I have a thesis, two papers, and two talks to write. I was hoping
practicality might temporarily win out, but I dont know for sure that such an
effort would even solve the problem.

> Does anyone have another suggestion?

Hope these suggestions might help.

Chris

PS One further thought I had is MetaPost.
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=MP Is it possible for
matplotlib to embed the tex expressions in the same way that metapost
does? This might not solve your problem however, as xdvi currently has
a problem displaying them - see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295205 for details.

PPS If you need something in a hurry (for your thesis?), can you
create the whole thing as a bitmap? or use the latex "ite" package to
position labels? If you do the latter, there is a patch I should send
you - otherwise it clashes with various packages.

Thank you for the suggestions, but they are both significant deviations from
what I already have in place, and I have to prepare a talk for June 13. In
the worst case scenario, I will just set usetex to false, and make some
temporary changes in my local installation to work around some font layout
issues that usetex had addressed.

Fonts, fonts, fonts. My new f-word.

···

On Thursday 02 June 2005 1:55 pm, you wrote:

--
Darren S. Dale

Bard Hall
Department of Materials Science and Engineering
Cornell University
Ithaca, NY. 14850

dd55@...143...
http://people.ccmr.cornell.edu/~dd55/