On Apr 29, 2010, at 11:51 PM, Tony S Yu wrote:


On Apr 29, 2010, at 10:43 PM, Tony S Yu wrote:


On Apr 29, 2010, at 6:09 PM, Michael Droettboom wrote:

Those Computer Modern fonts (specifically the Bakoma distribution of them that matplotlib includes) use a custom character set mapping where many of the characters are in completely arbitrary locations.  For regular text, matplotlib expects a regular Unicode font (particularly to get the minus sign).  Since cmr10 doesn't have a standard encoding, it just won't work. 

Hey Mike,

Thanks for your reply. That makes sense.

An alternative work around (I presume) would be to install the computer modern unicode fonts (I made sure to install the ttf version). However, I'm having trouble getting MPL to find the fonts.

The installed font is listed when calling `mpl.font_manager.OSXInstalledFonts()`, but it's not found when calling `mpl.font_manager.findfont` (with various names that would make sense: cmunrm, CMU Serif, etc.)

Any ideas on what I'm doing wrong?

Sorry, I meant to reply to the list.

After clearing the fontlist cache, I was able to get this fix working.

Just to summarize:

* download unicode version of computer modern fonts (http://sourceforge.net/projects/cm-unicode/files/)---make sure to get the ttf version

* clear out the fontlist cache (rm ~/.matplotlib/fontList.cache)

* add the following to ~/matplotlib/matplotlibrc:

    font.family: serif
    font.serif: CMU Serif

* alternatively, you could leave the default as sans serif and use the computer modern sans serif (unicode version):

    font.sans-serif: CMU Sans Serif

These changes produce plots where the size of normal text matches that of mathtext.

Thanks for you help, Mike!

-Tony


Umm, ... last email on this topic, I promise.

Is there any reason the font family rc parameter is case sensitive, while the findfont input is case insensitive? In other words, replacing

font.serif: CMU Serif

with

font.serif: cmu serif

does not work. On the other hand, both of the following work:

>>> mpl.font_manager.findfont('cmu serif')
>>> mpl.font_manager.findfont('CMU Serif')

This caused me problems when debugging my earlier font troubles.

Best,
-Tony