Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2012 from mdboom/texmanager-family-list

texmanager doesn't handle list of names for `font.family`
  • Loading branch information...
commit b5c340a6c8404a2e86a1321b45121b70d37c12d4 2 parents 7e7b532 + 7293060
@mdboom mdboom authored
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
11 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,12 @@ 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) / float(len(families))))
elif family1 == family2:
- return 0.0
+ # The score should be weighted by where in the
+ # list the font was found.
+ return float(i) / float(len(families))
return 1.0
def score_style(self, style1, style2):
View
7 lib/matplotlib/pyplot.py
@@ -278,11 +278,14 @@ 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
Please sign in to comment.
Something went wrong with that request. Please try again.