[Matplotlib-users] Re: usetex font problem

I'm moving this over to matplotlib-devel for the time being. There are a
couple of technical details I need to discuss that dont need to be broadcast
to matplotlib-user's 384 (!) subscribers. We are discussing how usetex
handles different font families.

Darren Dale wrote:
> Earlier this morning I changed the wiki page to explain this detail. Is
> it still unclear?

mmh. Perhaps a little summary table of the kind

font.family || font.latex.package || resulting font
-------------------------------------------------------
serif || various options

serif

sans

sans

etc.

Might help the dense amongst us make sense of the various possible results
without having to think, something at least I am not very good at.

:slight_smile: I'm pretty dense even after my third cup of coffee.

The table may not be necessary: I just discovered that we can drop the
font.latex.package rc setting, and instead respect the serif,
font.sans-serif, cursive and monospace font rc settings.

For example, if "times" is first in my font.serif list (or the first one found
that latex supports), this command can be run:

\renewcommand{\rmdefault}{ptm}

but if font.family is cursive in rc, then Zapf Chancery (pzc) is used instead.

Which entry in matplotlibrc should correspond to the computer modern fonts? Is
it "serif" for font.serif?

Also, I would like to drop support for the tex engine, and focus on latex
only. These font issues we are addressing are beyond my ability (and
interest) to support with tex, but they can be handled using the available
font packages with latex. Objections?

John, I learned today how to properly scale fonts, which might fix some of the
problems people have reported with text that is not being placed properly. It
requires using at least the scalefnt and fix-cm packages. I believe they are
included in every latex distribution. We currently do 10pt in latex, and then
scale everything afterwards, because that was the only way it seemed to work.
What we should do is just scale the fonts in latex and then we dont have to
monkey with the results. Do you object to this change?

Darren

···

On Sunday 29 January 2006 4:07 pm, you wrote:

Darren Dale wrote:

The table may not be necessary: I just discovered that we can drop the font.latex.package rc setting, and instead respect the serif, font.sans-serif, cursive and monospace font rc settings.

For example, if "times" is first in my font.serif list (or the first one found that latex supports), this command can be run:

\renewcommand{\rmdefault}{ptm}

but if font.family is cursive in rc, then Zapf Chancery (pzc) is used instead.

Which entry in matplotlibrc should correspond to the computer modern fonts? Is it "serif" for font.serif?

Also, I would like to drop support for the tex engine, and focus on latex only. These font issues we are addressing are beyond my ability (and interest) to support with tex, but they can be handled using the available font packages with latex. Objections?

I'm +1 on anything that simplifies this: while the functionality is fantastic, the current usability 'leaves to be desired' :). And many thanks for your combined efforts on this problem!

Best,

f

I don't see a need for TeX support, especially if it is taking very much effort.

I agree that font specification could be a little easier.

If a user was concerned with figure fonts matching the body fonts of a
LaTeX document, there should be a clear mapping from matplotlibrc
settings to which package to include in their LaTeX preamble and how
to set up their document.

Other than that, I don't care how its done and would want to make it
as easy as possible for the developer(s).

(Do you realize that it takes me several second of concentrated effort
to type LaTeX instead of latex and I don't really know why I keep
doing it?)

Ryan

···

On 1/29/06, Fernando Perez <Fernando.Perez@...76...> wrote:

Darren Dale wrote:

> The table may not be necessary: I just discovered that we can drop the
> font.latex.package rc setting, and instead respect the serif,
> font.sans-serif, cursive and monospace font rc settings.
>
> For example, if "times" is first in my font.serif list (or the first one found
> that latex supports), this command can be run:
>
> \renewcommand{\rmdefault}{ptm}
>
> but if font.family is cursive in rc, then Zapf Chancery (pzc) is used instead.
>
> Which entry in matplotlibrc should correspond to the computer modern fonts? Is
> it "serif" for font.serif?
>
> Also, I would like to drop support for the tex engine, and focus on latex
> only. These font issues we are addressing are beyond my ability (and
> interest) to support with tex, but they can be handled using the available
> font packages with latex. Objections?

I'm +1 on anything that simplifies this: while the functionality is fantastic,
the current usability 'leaves to be desired' :). And many thanks for your
combined efforts on this problem!

Best,

f

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

I just made a big commit to cvs. With these changes, the font.latex.package rc
setting is no longer needed, and should be removed from ones personal
matplotlibrc file.

I changed the texmanager to read the serif, sans-serif, monospace, and cursive
rc parameters. It looks until it finds a font that it recognizes, and
defaults to computer modern.

Here are the currently supported latex fonts:

- serif: Times, Palatino, Bookman, New Century Schoolbook, Charter, Computer
Modern Roman (Times and Palatino have their own math fonts, the others
default to computer modern math fonts)

- sans-serif: Helvetica, Avant Garde, Computer Modern Sans Serif (I added
Avant Garde to the matplotlibrc.template)

- monospace: Courier, Computer Modern Typewriter

- cursive: Zapf Chancery

I've tested all of these, and everything appears to be working. The
font.family setting is still respected, and cursive is now supported with
latex, but fantasy is not (raises a warning, defaults to serif). If you use
the usetex option, please kick the tires and let me know how it goes. Once
everything is satisfactory, I would like to request a minor version bump, so
I can update the wiki.

John, I made that change in backend_agg, so it uses the same information as
texmanager to generate its keys. I decided against scaling the fonts in
latex. There is a good reason to keep the scaling as it is: smaller
tex.cache. If I had changed it, I would have had to cache the same text
multiple times for each new fontsize.

Darren

Darren Dale wrote:

I just made a big commit to cvs. With these changes, the font.latex.package rc setting is no longer needed, and should be removed from ones personal matplotlibrc file.

I wonder if I'm doing something wrong. I built fresh from CVS on an Ubuntu box, nuked my tex.cache directory, and yet a simple plot(range(10)) gives me:

/usr/local/lib/python2.4/site-packages/matplotlib/texmanager.py in get_rgba(self=<matplotlib.texmanager.TexManager instance>, tex='0', fontsize=12.0, dpi=96.0, rgb=(0, 0, 0))
     385 # force=True to skip cacheing while debugging
     386 pngfile = self.make_png(tex, dpi, force=False)
--> 387 X = readpng(pngfile)
         X = undefined
         global readpng = <built-in method readpng of tuple object at 0x4071318c>
         pngfile = '/home/fperez/.matplotlib/tex.cache/f43bbaa78e0a6e5688e327d12df8b9ce_96.png'
     388 vers = self.get_dvipng_version()
     389 #print 'dvipng version', vers

RuntimeError: _image_module::readpng could not open PNG file /home/fperez/.matplotlib/tex.cache/f43bbaa78e0a6e5688e327d12df8b9ce_96.png for reading

The png is indeed not there at all. Am I missing something? if the png didn't get created, shouldn't make_png raise an exception instead?

I tried to compile the latex file by hand, but even that fails:

maqroll[tex.cache]> latex f43bbaa78e0a6e5688e327d12df8b9ce.tex
This is e-TeX, Version 3.14159-2.1 (Web2C 7.4.5)
entering extended mode
(./f43bbaa78e0a6e5688e327d12df8b9ce.tex
LaTeX2e <2001/06/01>
Babel <v3.7h> and hyphenation patterns for american, french, german, ngerman, b
ahasa, basque, catalan, croatian, czech, danish, dutch, finnish, greek, iceland
ic, irish, italian, latin, magyar, norsk, norsk, portuges, romanian, russian, s
lovak, slovene, spanish, swedish, turkish, ukrainian, nohyphenation, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 2001/04/21 v1.4e Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/size10.clo))
(/usr/share/texmf/tex/latex/misc/type1cm.sty)
(/usr/share/texmf/tex/latex/psnfss/helvet.sty
(/usr/share/texmf/tex/latex/graphics/keyval.sty))
(/usr/share/texmf/tex/latex/psnfss/courier.sty)

! LaTeX Error: File `fix-cm.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name: X

The problem is that fix-cm.sty is NOT part of a standard latex distribution. Did you add this yourself? I checked my destkop (Fedora 3 box):

abdul[src]> locate fix-cm
abdul[src]>

I grabbed fix-cm by hand from CTAN:

http://www.ctan.org/info?id=fix-cm

and things seem to work now, but I suspect you didn't intend people to have to go fishing into CTAN :slight_smile:

I'll keep testing and will let you know if I hit any other snags. Thanks a lot for all your work!

f

Cheers,

f

! LaTeX Error: File `fix-cm.sty' not found.

[...]

I grabbed fix-cm by hand from CTAN:

CTAN: Not Found

and things seem to work now, but I suspect you didn't intend people to have
to go fishing into CTAN :slight_smile:

Thanks Fernando. No, I do NOT want anyone to have to visit CTAN to make this
work. I added this when I was considering scaling the fonts in latex. Since I
have decided against doing so, fix-cm and scalefnt packages will not be
needed after all. cvs reflects the change.

Please tell me though, that the fontenc and textcomp packages ARE included.
They are not essential to the changes I made last night, but I think these
packages will fix the dvipng problem we had where a few of the glyphs were
not properly interpretted on screen and in png output.

Darren

···

On Monday 30 January 2006 12:47 am, Fernando Perez wrote:

Darren Dale wrote:

Thanks Fernando. No, I do NOT want anyone to have to visit CTAN to make this work. I added this when I was considering scaling the fonts in latex. Since I have decided against doing so, fix-cm and scalefnt packages will not be needed after all. cvs reflects the change.

Good, thanks.

Please tell me though, that the fontenc and textcomp packages ARE included. They are not essential to the changes I made last night, but I think these packages will fix the dvipng problem we had where a few of the glyphs were not properly interpretted on screen and in png output.

I suspect those are fine, because fix-cm was the only problem I hit, and this was on a fresh ubuntu install, with nothing in the way of manual tweaks. But it may be a good idea to wait and hear confirmation from users of other TeX distros (such as those on win32).

Cheers,

f