Finding fonts

When I plot, I get:

UserWarning: findfont: Font family ['sans-serif'] not found. Falling
back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))

My matplotlibrc file has:

font.sans-serif: Computer Modern Sans Serif
font.serif: Computer Modern Roman
font.monospace: Computer Modern Typewriter

Have I typed these names incorrectly? I recently (two days ago)
upgraded to the latest SVN of matplotlib and that is when the warning
started appearing. I have a working TeXLive distribution in linux, so
the fonts should exist on my computer.

The warning was recently introduced in SVN, but the behaviour shouldn't have changed -- it's just a little more "in your face" now that something may not be what you expect.

TeXLive doesn't usually install Truetype versions of the Computer Modern fonts. You can use the Computer Modern Bakoma fonts that come with matplotlib by using "cmr10", "cmss10" etc. (see mpl-data/fonts/ttf for a list of the available ones), or for fonts that are a little more friendly and have standard unicode character points, you may want to install these:

http://cm-unicode.sourceforge.net/

Or, you can side-step all this and set the rcParam "text.usetex" to True, which will render all the text in the plot with TeX itself.

Mike

···

On 05/26/2010 04:47 PM, T J wrote:

When I plot, I get:

UserWarning: findfont: Font family ['sans-serif'] not found. Falling
back to Bitstream Vera Sans
   (prop.get_family(), self.defaultFamily[fontext]))

My matplotlibrc file has:

font.sans-serif: Computer Modern Sans Serif
font.serif: Computer Modern Roman
font.monospace: Computer Modern Typewriter

Have I typed these names incorrectly? I recently (two days ago)
upgraded to the latest SVN of matplotlib and that is when the warning
started appearing. I have a working TeXLive distribution in linux, so
the fonts should exist on my computer.

Hmm...this is partly why I was confused in the first place. I
originally included the above lines in my matplotlibrc file because my
generated PDFs did not have all CM fonts, despite my text.usetex being
set to True.

    http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg09852.html

The recommendation there was that setting the various font.* rcParams
would fix this issue. And indeed, it did. After specifying the
fonts, my PDFs only included CM fonts.

Even now, my PDFs only contain CM fonts. So it seems that this is a
"useless" warning in the sense that findfont() is complaining about a
situation that won't manifest b/c text.usetex is True. Have I
understood this correctly?

···

On Wed, May 26, 2010 at 4:20 PM, Michael Droettboom <mdroe@...86...> wrote:

On 05/26/2010 04:47 PM, T J wrote:

When I plot, I get:

UserWarning: findfont: Font family ['sans-serif'] not found. Falling
back to Bitstream Vera Sans
(prop.get_family(), self.defaultFamily[fontext]))

My matplotlibrc file has:

font.sans-serif: Computer Modern Sans Serif
font.serif: Computer Modern Roman
font.monospace: Computer Modern Typewriter

Have I typed these names incorrectly? I recently (two days ago)
upgraded to the latest SVN of matplotlib and that is when the warning
started appearing. I have a working TeXLive distribution in linux, so
the fonts should exist on my computer.

The warning was recently introduced in SVN, but the behaviour shouldn't
have changed -- it's just a little more "in your face" now that
something may not be what you expect.

TeXLive doesn't usually install Truetype versions of the Computer Modern
fonts. You can use the Computer Modern Bakoma fonts that come with
matplotlib by using "cmr10", "cmss10" etc. (see mpl-data/fonts/ttf for a
list of the available ones), or for fonts that are a little more
friendly and have standard unicode character points, you may want to
install these:

http://cm-unicode.sourceforge.net/

Or, you can side-step all this and set the rcParam "text.usetex" to
True, which will render all the text in the plot with TeX itself.

Mike