Hi, I wondered why the matplotlib.font_manager.rcParams contains sometimes escaped minus signs in font names: >>> font_manager.rcParams['mathtext.sf'] 'sans\\-serif' >>>
>>> font_manager.findfont('sans-serif') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1327, in findfont font = fontManager.findfont(prop, **kw) File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1172, in findfont prop = FontProperties(prop) File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 673, in __init__ self.set_fontconfig_pattern(family) File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 893, in set_fontconfig_pattern for key, val in self._parse_fontconfig_pattern(pattern).items(): File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 685, in _parse_fontconfig_pattern return parse_fontconfig_pattern(pattern) File "/usr/lib64/python2.7/site-packages/matplotlib/fontconfig_pattern.py", line 127, in parse raise ValueError("Could not parse font string: '%s'\n%s" % (pattern, e)) ValueError: Could not parse font string: 'sans-serif' Expected end of text (at char 4), (line:1, col:5) >>> font_manager.findfont('sans\\-serif') '/usr/share/fonts/mathematica-fonts/Vera.ttf' >>> And there is nothing to read in the help string for this function, definitely a place where the escaping should be explained. >>> help(font_manager.findfont) >>> Anyway, I think the requirement for the escaping should be removed, it should be escaped internally in the routine. So why is it so? For historic reasons? ;-) Isn't the escaping a cause for the seemingly missing fonts, like reported here? http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg22860.html I am also getting: /usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmb10'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext])) /usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmtt10'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext])) /usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmss10'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext])) The font to be used is assembled from several fields in the rcParams. I guess from: >>> [x for x in font_manager.rcParams.keys() if x.startswith('font')] ['font.cursive', 'font.family', 'font.fantasy', 'font.monospace', 'font.sans-serif', 'font.serif', 'font.size', 'font.stretch', 'font.style', 'font.variant', 'font.weight'] >>> [x for x in font_manager.rcParams.values() if x.startswith('cm')] /usr/lib64/python2.7/site-packages/matplotlib/__init__.py:658: UserWarning: svg.embed_char_paths is deprecated and replaced with svg.fonttype; please use the latter. warnings.warn(self.msg_depr % (key, alt)) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'int' object has no attribute 'startswith' >>> [x for x in font_manager.rcParams.items() if x[1]=='cm'] [('mathtext.fontset', 'cm')] >>> What else is used to give out the 'cmb10', 'cmtt10' and 'cmss10'? >>> font_manager.findfont('cmb10') '/usr/share/fonts/mathematica-fonts/Vera.ttf' >>> font_manager.findfont('cmtt10') /usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmtt10'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext])) '/usr/share/fonts/mathematica-fonts/Vera.ttf' >>> font_manager.findfont('cmss10') /usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmss10'] not found. Falling back to Bitstream Vera Sans (prop.get_family(), self.defaultFamily[fontext])) '/usr/share/fonts/mathematica-fonts/Vera.ttf' >>> Thanks, Martin ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users