Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

texmanager doesn't handle list of names for font.family #2012

Merged
merged 3 commits into from May 15, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_ps.py
Expand Up @@ -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)

Expand Down
8 changes: 5 additions & 3 deletions lib/matplotlib/font_manager.py
Expand Up @@ -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']
Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit magic to me, but I can live with it...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. float(i) / float(len(families)) would be less magical. I'll change it to that.

return 1.0

def score_style(self, style1, style2):
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/pyplot.py
Expand Up @@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably longer than 79 chars?


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'] = [
Expand Down
14 changes: 8 additions & 6 deletions lib/matplotlib/texmanager.py
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion matplotlibrc.template
Expand Up @@ -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
Expand Down