There is now experimental support for custom fonts in math mode.

You'll need to set "mathtext.use_cm" to False, and then set up a mapping 
from each of the TeX font names to the name of your desired font.

It is assumed that the fonts are Unicode fonts -- it will use the same 
font for both Latin and Greek characters.  If your font doesn't have 
Greek characters, it will (optionally) fall back on the Computer Modern 
fonts.  There isn't (at present) a way to fall back to a Greek-only 
font.  (There would, IMHO, have to be a compelling reason to add that 
functionality, since there are too many font options to test already ;)

Here's an excerpt from matplotlib.template:

# The following settings allow you to select the fonts in math mode.
# They map from a TeX font name to a 3-tuple of the form:
#    (family, weight, style)
# These settings are only used if mathtext.use_cm is False, otherwise, the
# Bakoma TeX Computer Modern fonts are used.
#mathtext.cal : (['cursive'], 'normal', 'normal')
#mathtext.rm  : (['serif'], 'normal', 'normal')
#mathtext.tt  : (['monospace'], 'normal', 'normal')
#mathtext.it  : (['serif'], 'normal', 'oblique')
#mathtext.bf  : (['serif'], 'bold', 'normal')
#mathtext.sf  : (['sans-serif'], 'normal', 'normal')
#mathtext.use_cm : True
#mathtext.fallback_to_cm : True  # When True, use symbols from the 
Computer Modern
                                 # fonts when a symbol can not be found in one 
of
                                 # the user-specified math fonts.

Rob Hetland wrote:
> However, I often just want to put powers on units -- e.g., m^3 s^{-1}, 
> and serifed fonts look terrible as superscripts for sans fonts.

Agreed.

> Perhaps there is another way to get what I want?

Try the above, and let me know how it goes...

> Also, the main problem I find when mixing CM symbols (e.g., \epsilon) 
> with other fonts is that the CM fonts seem small.  Perhaps there is a 
> way to jack up the symbol size to that it matches the non-CM fonts in a 
> more reasonable way?

If the Unicode font has both Latin and Greek characters in it, those 
characters should play well together.  More generally, though, I agree, 
and one might run into that problem using some of the more obscure math 
operators.  Perhaps scaling one or the other font to get the x-heights 
to match might work.  I'll have to look into that further...

Thanks for spurring me on to get this custom font stuff together.

Cheers,
Mike

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to