Permalink
Browse files

Fixes a number of bugs introduced by cc61700. texmanager will now sti…

…ll pass when font.family is a list of strings (though there's no sane way for LaTeX to deal with that, but that's nothing new).
  • Loading branch information...
1 parent d5b078b commit 2ea3dcb9466630cd758ea5342ffd59558a08b31b @mdboom committed May 15, 2013
View
2 lib/matplotlib/backends/backend_ps.py
@@ -659,7 +659,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
color = '%1.3f,%1.3f,%1.3f'% gc.get_rgb()[:3]
fontcmd = {'sans-serif' : r'{\sffamily %s}',
'monospace' : r'{\ttfamily %s}'}.get(
- rcParams['font.family'], r'{\rmfamily %s}')
+ rcParams['font.family'][0], r'{\rmfamily %s}')
s = fontcmd % s
tex = r'\color[rgb]{%s} %s' % (color, s)
View
8 lib/matplotlib/font_manager.py
@@ -805,7 +805,9 @@ def set_family(self, family):
"""
Change the font family. May be either an alias (generic name
is CSS parlance), such as: 'serif', 'sans-serif', 'cursive',
- 'fantasy', or 'monospace', or a real font name.
+ 'fantasy', or 'monospace', a real font name or a list of real
+ font names. Real font names are not supported when
+ `text.usetex` is `True`.
"""
if family is None:
family = rcParams['font.family']
@@ -1064,9 +1066,9 @@ def score_family(self, families, family2):
options = [x.lower() for x in options]
if family2 in options:
idx = options.index(family2)
- return 0.1 * (float(idx) / len(options))
+ return 0.1 * ((float(idx) / len(options)) + float(i))
elif family1 == family2:
- return 0.0
+ return 0.1 * float(i)
return 1.0
def score_style(self, style1, style2):
View
6 lib/matplotlib/pyplot.py
@@ -278,11 +278,13 @@ def xkcd():
# This figure will be in regular style
fig2 = plt.figure()
"""
+ if rcParams['text.usetex']:
+ raise RuntimeError("xkcd mode is not compatible with text.usetex = True")
+
from matplotlib import patheffects
context = rc_context()
try:
- rcParams['text.usetex'] = False
- rcParams['font.family'] = 'Humor Sans'
+ rcParams['font.family'] = ['Humor Sans', 'Comic Sans MS']
rcParams['font.size'] = 14.0
rcParams['path.sketch'] = (1, 100, 2)
rcParams['path.effects'] = [
View
14 lib/matplotlib/texmanager.py
@@ -166,13 +166,15 @@ def __init__(self):
'available'))
mkdirs(self.texcache)
- ff = rcParams['font.family'].lower()
- if ff in self.font_families:
- self.font_family = ff
+ ff = rcParams['font.family']
+ if len(ff) == 1 and ff[0].lower() in self.font_families:
+ self.font_family = ff[0].lower()
else:
- mpl.verbose.report('The %s font family is not compatible with '
- 'LaTeX. serif will be used by default.' % ff,
- 'helpful')
+ mpl.verbose.report(
+ 'font.family must be one of (%s) when text.usetex is True. '
+ 'serif will be used by default.' %
+ ', '.join(self.font_families),
+ 'helpful')
self.font_family = 'serif'
fontconfig = [self.font_family]
View
3 matplotlibrc.template
@@ -101,7 +101,8 @@ backend : %(backend)s
# 'sans-serif' (e.g., Helvetica), 'cursive' (e.g., Zapf-Chancery),
# 'fantasy' (e.g., Western), and 'monospace' (e.g., Courier). Each of
# these font families has a default list of font names in decreasing
-# order of priority associated with them.
+# order of priority associated with them. When text.usetex is False,
+# font.family may also be one or more concrete font names.
#
# The font.style property has three values: normal (or roman), italic
# or oblique. The oblique style will be used for italic, if it is not

0 comments on commit 2ea3dcb

Please sign in to comment.